diff --git a/.travis.yml b/.travis.yml
index 7dec16a..1ce051b 100755
--- a/.travis.yml
+++ b/.travis.yml
@@ -18,5 +18,6 @@ install:
- ls $HOME/.m2/repository/org/spigotmc/spigot/1.13.2-R0.1-SNAPSHOT >> /dev/null 2>&1 || java -jar BuildTools.jar --rev 1.13.2 >> /dev/null 2>&1
- ls $HOME/.m2/repository/org/spigotmc/spigot/1.14.4-R0.1-SNAPSHOT >> /dev/null 2>&1 || java -jar BuildTools.jar --rev 1.14.4 >> /dev/null 2>&1
- ls $HOME/.m2/repository/org/spigotmc/spigot/1.15.2-R0.1-SNAPSHOT >> /dev/null 2>&1 || java -jar BuildTools.jar --rev 1.15.2 >> /dev/null 2>&1
+ - ls $HOME/.m2/repository/org/spigotmc/spigot/1.16.1-R0.1-SNAPSHOT >> /dev/null 2>&1 || java -jar BuildTools.jar --rev 1.16.1 >> /dev/null 2>&1
script:
- mvn clean install
\ No newline at end of file
diff --git a/api/pom.xml b/api/pom.xml
index a0ce66b..395cfb2 100644
--- a/api/pom.xml
+++ b/api/pom.xml
@@ -8,7 +8,7 @@
npclib
net.jitse
- 2.9-SNAPSHOT
+ 2.10-SNAPSHOT
npclib-api
diff --git a/api/src/main/java/net/jitse/npclib/api/NPC.java b/api/src/main/java/net/jitse/npclib/api/NPC.java
index 3836644..1173487 100644
--- a/api/src/main/java/net/jitse/npclib/api/NPC.java
+++ b/api/src/main/java/net/jitse/npclib/api/NPC.java
@@ -8,6 +8,7 @@ import net.jitse.npclib.api.skin.Skin;
import net.jitse.npclib.api.state.NPCAnimation;
import net.jitse.npclib.api.state.NPCSlot;
import net.jitse.npclib.api.state.NPCState;
+import net.jitse.npclib.hologram.Hologram;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
@@ -18,6 +19,39 @@ import java.util.UUID;
public interface NPC {
+ /**
+ *
+ * @param player
+ * @return unique hologram for that user
+ */
+ Hologram getPlayerHologram(Player player);
+
+ /**
+ *
+ * @param uniqueLines The text that the targetPlayer will see
+ * @param targetPlayer The target player
+ * @return object instance
+ * @author Gatt
+ */
+ NPC setPlayerLines(List uniqueLines, Player targetPlayer);
+
+ /**
+ *
+ * @param uniqueLines The text that the targetPlayer will see
+ * @param targetPlayer The target player
+ * @param update whether or not to send the update packets
+ * @return object instance
+ * @author Gatt
+ */
+ NPC setPlayerLines(List uniqueLines, Player targetPlayer, boolean update);
+
+ /**
+ *
+ * @param targetPlayer The target player
+ * @return the lines that the targetPlayer will see, if null; default lines.
+ */
+ List getPlayerLines(Player targetPlayer);
+
/**
* Set the NPC's location.
* Use this method before using {@link NPC#create}.
diff --git a/api/src/main/java/net/jitse/npclib/internal/MinecraftVersion.java b/api/src/main/java/net/jitse/npclib/internal/MinecraftVersion.java
index e174c98..db98d68 100644
--- a/api/src/main/java/net/jitse/npclib/internal/MinecraftVersion.java
+++ b/api/src/main/java/net/jitse/npclib/internal/MinecraftVersion.java
@@ -16,7 +16,8 @@ public enum MinecraftVersion {
V1_13_R1,
V1_13_R2,
V1_14_R1,
- V1_15_R1;
+ V1_15_R1,
+ V1_16_R1;
public boolean isAboveOrEqual(MinecraftVersion compare) {
return ordinal() >= compare.ordinal();
diff --git a/api/src/main/java/net/jitse/npclib/internal/NPCBase.java b/api/src/main/java/net/jitse/npclib/internal/NPCBase.java
index 05b0856..b2f5159 100644
--- a/api/src/main/java/net/jitse/npclib/internal/NPCBase.java
+++ b/api/src/main/java/net/jitse/npclib/internal/NPCBase.java
@@ -45,10 +45,15 @@ public abstract class NPCBase implements NPC, NPCPacketHandler {
protected List text;
protected Location location;
protected Skin skin;
- protected Hologram hologram;
+
+ //protected Hologram hologram;
protected final Map items = new EnumMap<>(NPCSlot.class);
+ // Storage for per-player text;
+ protected final Map> uniqueText = new HashMap<>();
+ protected final Map textDisplayHolograms = new HashMap<>();
+
public NPCBase(NPCLib instance, List text) {
this.instance = instance;
this.text = text == null ? Collections.emptyList() : text;
@@ -60,6 +65,43 @@ public abstract class NPCBase implements NPC, NPCPacketHandler {
return instance;
}
+ @Override
+ public Hologram getPlayerHologram(Player player){
+ Hologram playerHologram = textDisplayHolograms.getOrDefault(player.getUniqueId(), null);
+ return playerHologram;
+ }
+
+ @Override
+ public NPC setPlayerLines(List uniqueLines, Player targetPlayer) {
+ uniqueText.put(targetPlayer.getUniqueId(), uniqueLines);
+ return this;
+ }
+
+ @Override
+ public NPC setPlayerLines(List uniqueLines, Player targetPlayer, boolean update) {
+ List originalLines = getPlayerLines(targetPlayer);
+ setPlayerLines(uniqueLines, targetPlayer);
+ if (update){
+ if (originalLines.size() != uniqueLines.size()){ // recreate the entire hologram
+ Hologram originalhologram = getPlayerHologram(targetPlayer);
+ originalhologram.hide(targetPlayer); // essentially destroy the hologram
+ textDisplayHolograms.remove(targetPlayer.getUniqueId()); // remove the old obj
+ }
+
+ if (isShown(targetPlayer)) { //only show hologram if the player is in range
+ Hologram hologram = getPlayerHologram(targetPlayer);
+ List