Updates for v1.3.

This commit is contained in:
Jitse Boonstra 2018-11-25 14:10:56 +01:00
parent e0f7ed2ab7
commit a6e8c0f4ce
19 changed files with 67 additions and 58 deletions

View File

@ -3,27 +3,33 @@ NPCLib Basic non-player character library.<br>
[![Release](https://jitpack.io/v/JitseB/NPCLib.svg)](https://github.com/JitseB/NPCLib/releases) [![Release](https://jitpack.io/v/JitseB/NPCLib.svg)](https://github.com/JitseB/NPCLib/releases)
[![Build Status](https://travis-ci.com/JitseB/NPCLib.svg?branch=master)](https://travis-ci.com/JitseB/NPCLib) [![Build Status](https://travis-ci.com/JitseB/NPCLib.svg?branch=master)](https://travis-ci.com/JitseB/NPCLib)
[![JDK](https://img.shields.io/badge/Using-Java%208-blue.svg)](http://jdk.java.net/8/) [![JDK](https://img.shields.io/badge/Using-Java%208-blue.svg)](http://jdk.java.net/8/)
[![Versions](https://img.shields.io/badge/MC-1.8%20--%201.13-blue.svg)](https://github.com/JitseB/NPCLib/releases) [![Versions](https://img.shields.io/badge/MC-1.8%20--%201.13.2-blue.svg)](https://github.com/JitseB/NPCLib/releases)
= =
This is an API made specifically for spigot servers (Minecraft). Current supported versions: **1.8 - 1.13**. Lightweight replacement for Citizens. NPCLib only uses packets instead of registering the entity in the actual Minecraft server. This is an API made specifically for spigot servers (Minecraft). Current supported versions: **1.8 - 1.13.2**. Lightweight replacement for Citizens. NPCLib only uses packets instead of registering the entity in the actual Minecraft server.
**Resource**: https://www.spigotmc.org/resources/npclib.55884/ **SpigotMC Resource** https://www.spigotmc.org/resources/npclib.55884/
**Thread**: https://www.spigotmc.org/threads/npclib--basic-non-player-character-library.314460/ **SpigotMC Thread** https://www.spigotmc.org/threads/npclib--basic-non-player-character-library.314460/
**Preview**: https://youtu.be/LqwdqIxPIvE
**Preview** (click to play video)
[![YouTube Video](http://img.youtube.com/vi/LqwdqIxPIvE/0.jpg)](http://www.youtube.com/watch?v=LqwdqIxPIvE "NPCLib Basic non-player character library (Minecraft).")
## Donate ## Donate
[![PayPal](https://cdn.rawgit.com/twolfson/paypal-github-button/1.0.0/dist/button.svg)](https://paypal.me/jitseboonstra) [![PayPal](https://cdn.rawgit.com/twolfson/paypal-github-button/1.0.0/dist/button.svg)](https://paypal.me/jitseboonstra)
Alternatively, you can help the project by starring the repository or telling others about NPCLib :smile: Alternatively, you can help the project by starring the repository or telling others about NPCLib. :smile:
## Usage ## Developers
It is recommended to shade `NPCLib-API-v*.jar` into your plugin. ### Usage
Alternatively, you may put `NPCLib-Plugin-v*.jar` under your `plugins` folder. By using this option, you do not need to shade the API JAR anymore. Though, do not forget to add `NPCLib` as a dependency in your `plugin.yml`!
You can download the latest release [here](https://github.com/JitseB/NPCLib/releases/latest). It is recommended to shade `npclib-api-v*.jar` into your plugin.
Alternatively, you can put `npclib-plugin-v*.jar` under your `plugins` folder. By doing this, you no longer need to shade the API JAR. Though, do not forget to add `NPCLib` as a dependency in your `plugin.yml`!
[Click here](https://github.com/JitseB/NPCLib/releases/latest) to download the latest release.
```Java ```Java
// First we define our (global) library variable. // First we define our (global) library variable.
@ -33,26 +39,35 @@ You can download the latest release [here](https://github.com/JitseB/NPCLib/rele
```Java ```Java
// Creating an NPC. // Creating a new NPC instance.
NPC npc = lib.createNPC(skin, lines); NPC npc = lib.createNPC(skin, lines);
// The generate the packets for the NPC. // Then let the library generate the necessary packets.
npc.create(location); npc.create(location);
// Then *finally* you can show/hide it to/from players. // You are all set! You can now show/hide it to/from players.
npc.show(player); npc.show(player);
npc.hide(player); npc.hide(player);
// If you do not use the NPC anymore, destroy the NPC accordingly. // If you do not wish to use the NPC anymore, destroy it accordingly.
npc.destroy(); npc.destroy();
``` ```
Usable events: `NPCSpawnEvent`, `NPCDestroyEvent` and `NPCInteractEvent`. ### Events
Events you may want to use are `NPCSpawnEvent`, `NPCDestroyEvent` and `NPCInteractEvent`.
### Building your own version
1. [Download](https://github.com/JitseB/NPCLib/archive/master.zip) or clone this repository.
2. Build the plugin using `sh build.sh`. Alternatively, you can build the API JAR manually using `mvn clean install`.
You can build the plugin using `mvn clean install -pPlugin`.
## License and plugins using NPCLib ## License and plugins using NPCLib
NPCLib is licensed under the [MIT license](https://github.com/JitseB/NPCLib/blob/master/LICENSE.md). NPCLib is licensed under the [MIT license](https://github.com/JitseB/NPCLib/blob/master/LICENSE.md).
Developers are free to use NPCLib for both private and commercial use. Though, it would be nice to acknowledge me. Developers are free to use NPCLib for both private and commercial use. However, it would be nice to acknowledge me.
You (the developer) can also contact me if you wish to be added to the list below. You (the developer) can also contact me if you wish to be added to the list below.

View File

@ -7,7 +7,7 @@
<parent> <parent>
<groupId>net.jitse</groupId> <groupId>net.jitse</groupId>
<artifactId>npclib</artifactId> <artifactId>npclib</artifactId>
<version>1.2.2</version> <version>1.3</version>
</parent> </parent>
<artifactId>npclib-api</artifactId> <artifactId>npclib-api</artifactId>
@ -73,10 +73,16 @@
<version>${project.version}</version> <version>${project.version}</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency>
<groupId>net.jitse</groupId>
<artifactId>npclib-nms-v1_13_R2</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>
<defaultGoal>clean install</defaultGoal> <defaultGoal>clean install</defaultGoal>
<finalName>NPCLib-API-v${project.version}</finalName> <finalName>npclib-api-v${project.version}</finalName>
</build> </build>
</project> </project>

View File

@ -1,10 +1,11 @@
echo "Building NPCLib jars..." #!/bin/bash
echo "Building JARs..."
ls jars >> /dev/null 2>&1 || mkdir jars ls jars >> /dev/null 2>&1 || mkdir jars
echo "Building NPCLib-API.jar..." echo "Building npclib-api.jar..."
mvn clean install >> /dev/null 2>&1 && cp ./api/target/*.jar ./jars && echo "Finished building NPCLib-API.jar." || echo "Failed building NPCLib-API.jar. Please rebuild manually!" /usr/local/apache-maven-3.5.4/bin/mvn clean install >> /dev/null 2>&1 && cp ./api/target/*.jar ./jars && echo "Finished building NPCLib API" || echo "Failed building NPCLib API. Please rebuild manually"
echo "Building NPCLib-Plugin.jar..." echo "Building npclib-plugin.jar..."
mvn clean install -Pplugin >> /dev/null 2>&1 && cp ./target/*.jar ./jars && echo "Finished building NPCLib-Plugin.jar." || echo "Failed building NPCLib-Plugin.jar. Please rebuild manually!" /usr/local/apache-maven-3.5.4/bin/mvn clean install -Pplugin >> /dev/null 2>&1 && cp ./target/*.jar ./jars && echo "Finished building NPCLib plugin" || echo "Failed building NPCLib plugin. Please rebuild manually"
echo "Finished building NPCLib jars!"

View File

@ -7,7 +7,7 @@
<parent> <parent>
<groupId>net.jitse</groupId> <groupId>net.jitse</groupId>
<artifactId>npclib</artifactId> <artifactId>npclib</artifactId>
<version>1.2.2</version> <version>1.3</version>
</parent> </parent>
<artifactId>npclib-commons</artifactId> <artifactId>npclib-commons</artifactId>
@ -16,7 +16,7 @@
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId> <artifactId>spigot</artifactId>
<version>1.13-R0.1-SNAPSHOT</version> <version>1.13.2-R0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -77,7 +77,7 @@ public class PlayerListener implements Listener {
// This will cause issues otherwise (e.g. custom skin disappearing). // This will cause issues otherwise (e.g. custom skin disappearing).
double hideDistance = npc.getAutoHideDistance(); double hideDistance = npc.getAutoHideDistance();
double distanceSquared = player.getLocation().distanceSquared(npc.getLocation()); double distanceSquared = player.getLocation().distanceSquared(npc.getLocation());
boolean inRange = distanceSquared <= (hideDistance * hideDistance) || distanceSquared <= (Bukkit.getViewDistance() << 4); boolean inRange = distanceSquared <= (hideDistance * hideDistance) && distanceSquared <= (Bukkit.getViewDistance() << 4);
if (npc.getAutoHidden().contains(player.getUniqueId())) { if (npc.getAutoHidden().contains(player.getUniqueId())) {
// Check if the player and NPC are within the range to sendShowPackets it again. // Check if the player and NPC are within the range to sendShowPackets it again.
if (inRange) { if (inRange) {

View File

@ -5,13 +5,8 @@
package net.jitse.npclib.nms.holograms; package net.jitse.npclib.nms.holograms;
import com.comphenix.tinyprotocol.Reflection; import com.comphenix.tinyprotocol.Reflection;
import net.minecraft.server.v1_13_R1.EntityArmorStand;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Nameable;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.craftbukkit.v1_13_R1.entity.CraftArmorStand;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.ArrayList; import java.util.ArrayList;

View File

@ -7,7 +7,7 @@
<parent> <parent>
<groupId>net.jitse</groupId> <groupId>net.jitse</groupId>
<artifactId>npclib</artifactId> <artifactId>npclib</artifactId>
<version>1.2.2</version> <version>1.3</version>
</parent> </parent>
<artifactId>npclib-nms</artifactId> <artifactId>npclib-nms</artifactId>

View File

@ -7,7 +7,7 @@
<parent> <parent>
<groupId>net.jitse</groupId> <groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId> <artifactId>npclib-nms</artifactId>
<version>1.2.2</version> <version>1.3</version>
</parent> </parent>
<artifactId>npclib-nms-v1_10_R1</artifactId> <artifactId>npclib-nms-v1_10_R1</artifactId>

View File

@ -7,7 +7,7 @@
<parent> <parent>
<groupId>net.jitse</groupId> <groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId> <artifactId>npclib-nms</artifactId>
<version>1.2.2</version> <version>1.3</version>
</parent> </parent>
<artifactId>npclib-nms-v1_11_R1</artifactId> <artifactId>npclib-nms-v1_11_R1</artifactId>

View File

@ -7,7 +7,7 @@
<parent> <parent>
<groupId>net.jitse</groupId> <groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId> <artifactId>npclib-nms</artifactId>
<version>1.2.2</version> <version>1.3</version>
</parent> </parent>
<artifactId>npclib-nms-v1_12_R1</artifactId> <artifactId>npclib-nms-v1_12_R1</artifactId>

View File

@ -1,8 +1,4 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<!--
~ Copyright (c) 2018 Jitse Boonstra
-->
<project <project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
@ -11,7 +7,7 @@
<parent> <parent>
<groupId>net.jitse</groupId> <groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId> <artifactId>npclib-nms</artifactId>
<version>1.2.2</version> <version>1.3</version>
</parent> </parent>
<artifactId>npclib-nms-v1_13_R1</artifactId> <artifactId>npclib-nms-v1_13_R1</artifactId>

View File

@ -1,8 +1,4 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<!--
~ Copyright (c) 2018 Jitse Boonstra
-->
<project <project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
@ -11,7 +7,7 @@
<parent> <parent>
<groupId>net.jitse</groupId> <groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId> <artifactId>npclib-nms</artifactId>
<version>1.2.2</version> <version>1.3</version>
</parent> </parent>
<artifactId>npclib-nms-v1_13_R2</artifactId> <artifactId>npclib-nms-v1_13_R2</artifactId>
@ -20,7 +16,7 @@
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId> <artifactId>spigot</artifactId>
<version>1.13.1-R0.1-SNAPSHOT</version> <version>1.13.2-R0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -7,7 +7,7 @@
<parent> <parent>
<groupId>net.jitse</groupId> <groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId> <artifactId>npclib-nms</artifactId>
<version>1.2.2</version> <version>1.3</version>
</parent> </parent>
<artifactId>npclib-nms-v1_8_R1</artifactId> <artifactId>npclib-nms-v1_8_R1</artifactId>

View File

@ -7,7 +7,7 @@
<parent> <parent>
<groupId>net.jitse</groupId> <groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId> <artifactId>npclib-nms</artifactId>
<version>1.2.2</version> <version>1.3</version>
</parent> </parent>
<artifactId>npclib-nms-v1_8_R2</artifactId> <artifactId>npclib-nms-v1_8_R2</artifactId>

View File

@ -7,7 +7,7 @@
<parent> <parent>
<groupId>net.jitse</groupId> <groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId> <artifactId>npclib-nms</artifactId>
<version>1.2.2</version> <version>1.3</version>
</parent> </parent>
<artifactId>npclib-nms-v1_8_R3</artifactId> <artifactId>npclib-nms-v1_8_R3</artifactId>

View File

@ -7,7 +7,7 @@
<parent> <parent>
<groupId>net.jitse</groupId> <groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId> <artifactId>npclib-nms</artifactId>
<version>1.2.2</version> <version>1.3</version>
</parent> </parent>
<artifactId>npclib-nms-v1_9_R1</artifactId> <artifactId>npclib-nms-v1_9_R1</artifactId>

View File

@ -7,7 +7,7 @@
<parent> <parent>
<groupId>net.jitse</groupId> <groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId> <artifactId>npclib-nms</artifactId>
<version>1.2.2</version> <version>1.3</version>
</parent> </parent>
<artifactId>npclib-nms-v1_9_R2</artifactId> <artifactId>npclib-nms-v1_9_R2</artifactId>

View File

@ -7,14 +7,14 @@
<parent> <parent>
<groupId>net.jitse</groupId> <groupId>net.jitse</groupId>
<artifactId>npclib</artifactId> <artifactId>npclib</artifactId>
<version>1.2.2</version> <version>1.3</version>
</parent> </parent>
<artifactId>npclib-plugin</artifactId> <artifactId>npclib-plugin</artifactId>
<build> <build>
<directory>../target</directory> <directory>../target</directory>
<finalName>NPCLib-Plugin-v${project.parent.version}</finalName> <finalName>npclib-plugin-v${project.parent.version}</finalName>
<resources> <resources>
<resource> <resource>
<directory>src/main/resources</directory> <directory>src/main/resources</directory>

View File

@ -8,10 +8,10 @@
<groupId>net.jitse</groupId> <groupId>net.jitse</groupId>
<artifactId>npclib</artifactId> <artifactId>npclib</artifactId>
<version>1.2.2</version> <version>1.3</version>
<name>NPCLib</name> <name>NPCLib</name>
<url>https://github.com/JitseB/npclib</url> <url>https://github.com/JitseB/NPCLib</url>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@ -37,7 +37,7 @@
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId> <artifactId>spigot-api</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version> <version>1.13.2-R0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
</dependencies> </dependencies>