Browse Source

potential feature for per-player hologram names

master
Gatt 2 years ago
parent
commit
4da537e978
33 changed files with 302 additions and 42 deletions
  1. +1
    -0
      .travis.yml
  2. +1
    -1
      api/pom.xml
  3. +34
    -0
      api/src/main/java/net/jitse/npclib/api/NPC.java
  4. +2
    -1
      api/src/main/java/net/jitse/npclib/internal/MinecraftVersion.java
  5. +46
    -1
      api/src/main/java/net/jitse/npclib/internal/NPCBase.java
  6. +2
    -0
      api/src/main/java/net/jitse/npclib/internal/NPCPacketHandler.java
  7. +1
    -1
      nms/pom.xml
  8. +1
    -1
      nms/v1_10_R1/pom.xml
  9. +17
    -2
      nms/v1_10_R1/src/main/java/net/jitse/npclib/nms/v1_10_R1/NPC_v1_10_R1.java
  10. +1
    -1
      nms/v1_11_R1/pom.xml
  11. +17
    -2
      nms/v1_11_R1/src/main/java/net/jitse/npclib/nms/v1_11_R1/NPC_v1_11_R1.java
  12. +1
    -1
      nms/v1_12_R1/pom.xml
  13. +17
    -2
      nms/v1_12_R1/src/main/java/net/jitse/npclib/nms/v1_12_R1/NPC_v1_12_R1.java
  14. +1
    -1
      nms/v1_13_R1/pom.xml
  15. +17
    -2
      nms/v1_13_R1/src/main/java/net/jitse/npclib/nms/v1_13_R1/NPC_v1_13_R1.java
  16. +1
    -1
      nms/v1_13_R2/pom.xml
  17. +16
    -2
      nms/v1_13_R2/src/main/java/net/jitse/npclib/nms/v1_13_R2/NPC_v1_13_R2.java
  18. +1
    -1
      nms/v1_14_R1/pom.xml
  19. +16
    -2
      nms/v1_14_R1/src/main/java/net/jitse/npclib/nms/v1_14_R1/NPC_v1_14_R1.java
  20. +1
    -1
      nms/v1_15_R1/pom.xml
  21. +16
    -2
      nms/v1_15_R1/src/main/java/net/jitse/npclib/nms/v1_15_R1/NPC_v1_15_R1.java
  22. +1
    -1
      nms/v1_16_R1/pom.xml
  23. +16
    -2
      nms/v1_16_R1/src/main/java/net/jitse/npclib/nms/v1_16_R1/NPC_v1_16_R1.java
  24. +1
    -1
      nms/v1_8_R2/pom.xml
  25. +18
    -2
      nms/v1_8_R2/src/main/java/net/jitse/npclib/nms/v1_8_R2/NPC_v1_8_R2.java
  26. +1
    -1
      nms/v1_8_R3/pom.xml
  27. +16
    -2
      nms/v1_8_R3/src/main/java/net/jitse/npclib/nms/v1_8_R3/NPC_v1_8_R3.java
  28. +1
    -1
      nms/v1_9_R1/pom.xml
  29. +17
    -2
      nms/v1_9_R1/src/main/java/net/jitse/npclib/nms/v1_9_R1/NPC_v1_9_R1.java
  30. +1
    -1
      nms/v1_9_R2/pom.xml
  31. +18
    -2
      nms/v1_9_R2/src/main/java/net/jitse/npclib/nms/v1_9_R2/NPC_v1_9_R2.java
  32. +1
    -1
      plugin/pom.xml
  33. +1
    -1
      pom.xml

+ 1
- 0
.travis.yml View File

@ -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

+ 1
- 1
api/pom.xml View File

@ -8,7 +8,7 @@
<parent>
<artifactId>npclib</artifactId>
<groupId>net.jitse</groupId>
<version>2.9-SNAPSHOT</version>
<version>2.10-SNAPSHOT</version>
</parent>
<artifactId>npclib-api</artifactId>


+ 34
- 0
api/src/main/java/net/jitse/npclib/api/NPC.java View File

@ -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<String> 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<String> uniqueLines, Player targetPlayer, boolean update);
/**
*
* @param targetPlayer The target player
* @return the lines that the targetPlayer will see, if null; default lines.
*/
List<String> getPlayerLines(Player targetPlayer);
/**
* Set the NPC's location.
* Use this method before using {@link NPC#create}.


+ 2
- 1
api/src/main/java/net/jitse/npclib/internal/MinecraftVersion.java View File

@ -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();


+ 46
- 1
api/src/main/java/net/jitse/npclib/internal/NPCBase.java View File

@ -49,6 +49,10 @@ public abstract class NPCBase implements NPC, NPCPacketHandler {
protected final Map<NPCSlot, ItemStack> items = new EnumMap<>(NPCSlot.class);
// Storage for per-player text;
protected final Map<UUID, List<String>> uniqueText = new HashMap<>();
protected final Map<UUID, Hologram> textDisplayHolograms = new HashMap<>();
public NPCBase(NPCLib instance, List<String> text) {
this.instance = instance;
this.text = text == null ? Collections.emptyList() : text;
@ -60,6 +64,42 @@ 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<String> uniqueLines, Player targetPlayer) {
uniqueText.put(targetPlayer.getUniqueId(), uniqueLines);
return this;
}
@Override
public NPC setPlayerLines(List<String> uniqueLines, Player targetPlayer, boolean update) {
List<String> 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
}
Hologram hologram = getPlayerHologram(targetPlayer); //
List<Object> updatePackets = hologram.getUpdatePackets(getPlayerLines(targetPlayer));
hologram.update(targetPlayer, updatePackets);
hologram.show(targetPlayer);
}
return this;
}
@Override
public List<String> getPlayerLines(Player targetPlayer) {
return uniqueText.getOrDefault(targetPlayer.getUniqueId(), text);
}
@Override
public UUID getUniqueId() {
return uuid;
@ -303,11 +343,16 @@ public abstract class NPCBase implements NPC, NPCPacketHandler {
@Override
public NPC setText(List<String> text) {
List<Object> updatePackets = hologram.getUpdatePackets(text);
uniqueText.clear();
for (UUID shownUuid : shown) {
Player player = Bukkit.getPlayer(shownUuid);
if (player != null && isShown(player)) {
Hologram originalhologram = getPlayerHologram(player);
originalhologram.hide(player); // essentially destroy the hologram
textDisplayHolograms.remove(player.getUniqueId()); // remove the old obj
Hologram hologram = getPlayerHologram(player); // let it regenerate
List<Object> updatePackets = hologram.getUpdatePackets(getPlayerLines(player));
hologram.update(player, updatePackets);
}
}


+ 2
- 0
api/src/main/java/net/jitse/npclib/internal/NPCPacketHandler.java View File

@ -15,6 +15,8 @@ interface NPCPacketHandler {
void createPackets();
void createPackets(Player player);
void sendShowPackets(Player player);
void sendHidePackets(Player player);


+ 1
- 1
nms/pom.xml View File

@ -8,7 +8,7 @@
<parent>
<groupId>net.jitse</groupId>
<artifactId>npclib</artifactId>
<version>2.9-SNAPSHOT</version>
<version>2.10-SNAPSHOT</version>
</parent>
<artifactId>npclib-nms</artifactId>


+ 1
- 1
nms/v1_10_R1/pom.xml View File

@ -8,7 +8,7 @@
<parent>
<groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId>
<version>2.9-SNAPSHOT</version>
<version>2.10-SNAPSHOT</version>
</parent>
<artifactId>npclib-nms-v1_10_R1</artifactId>


+ 17
- 2
nms/v1_10_R1/src/main/java/net/jitse/npclib/nms/v1_10_R1/NPC_v1_10_R1.java View File

@ -38,9 +38,24 @@ public class NPC_v1_10_R1 extends NPCBase {
super(instance, lines);
}
@Override
public Hologram getPlayerHologram(Player player) {
Hologram holo = super.getPlayerHologram(player);
if (holo == null){
holo = new Hologram(MinecraftVersion.V1_10_R1, location.clone().add(0, 0.5, 0), getPlayerLines(player));
}
super.textDisplayHolograms.put(player.getUniqueId(), holo);
return holo;
}
@Override
public void createPackets() {
this.hologram = new Hologram(MinecraftVersion.V1_10_R1, location.clone().subtract(0, 0.5, 0), text);
Bukkit.getOnlinePlayers().forEach(this::createPackets);
}
@Override
public void createPackets(Player player) {
PacketPlayOutPlayerInfoWrapper packetPlayOutPlayerInfoWrapper = new PacketPlayOutPlayerInfoWrapper();
@ -74,7 +89,7 @@ public class NPC_v1_10_R1 extends NPCBase {
playerConnection.sendPacket(packetPlayOutNamedEntitySpawn);
playerConnection.sendPacket(packetPlayOutEntityHeadRotation);
hologram.show(player);
getPlayerHologram(player).show(player);
// Removing the player info after 10 seconds.
Bukkit.getScheduler().runTaskLater(instance.getPlugin(), () ->


+ 1
- 1
nms/v1_11_R1/pom.xml View File

@ -8,7 +8,7 @@
<parent>
<groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId>
<version>2.9-SNAPSHOT</version>
<version>2.10-SNAPSHOT</version>
</parent>
<artifactId>npclib-nms-v1_11_R1</artifactId>


+ 17
- 2
nms/v1_11_R1/src/main/java/net/jitse/npclib/nms/v1_11_R1/NPC_v1_11_R1.java View File

@ -38,9 +38,24 @@ public class NPC_v1_11_R1 extends NPCBase {
super(instance, lines);
}
@Override
public Hologram getPlayerHologram(Player player) {
Hologram holo = super.getPlayerHologram(player);
if (holo == null){
holo = new Hologram(MinecraftVersion.V1_11_R1, location.clone().add(0, 0.5, 0), getPlayerLines(player));
}
super.textDisplayHolograms.put(player.getUniqueId(), holo);
return holo;
}
@Override
public void createPackets() {
this.hologram = new Hologram(MinecraftVersion.V1_11_R1, location.clone().add(0, 0.5, 0), text);
Bukkit.getOnlinePlayers().forEach(this::createPackets);
}
@Override
public void createPackets(Player player) {
PacketPlayOutPlayerInfoWrapper packetPlayOutPlayerInfoWrapper = new PacketPlayOutPlayerInfoWrapper();
@ -74,7 +89,7 @@ public class NPC_v1_11_R1 extends NPCBase {
playerConnection.sendPacket(packetPlayOutNamedEntitySpawn);
playerConnection.sendPacket(packetPlayOutEntityHeadRotation);
hologram.show(player);
getPlayerHologram(player).show(player);
// Removing the player info after 10 seconds.
Bukkit.getScheduler().runTaskLater(instance.getPlugin(), () ->


+ 1
- 1
nms/v1_12_R1/pom.xml View File

@ -8,7 +8,7 @@
<parent>
<groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId>
<version>2.9-SNAPSHOT</version>
<version>2.10-SNAPSHOT</version>
</parent>
<artifactId>npclib-nms-v1_12_R1</artifactId>


+ 17
- 2
nms/v1_12_R1/src/main/java/net/jitse/npclib/nms/v1_12_R1/NPC_v1_12_R1.java View File

@ -38,9 +38,24 @@ public class NPC_v1_12_R1 extends NPCBase {
super(instance, lines);
}
@Override
public Hologram getPlayerHologram(Player player) {
Hologram holo = super.getPlayerHologram(player);
if (holo == null){
holo = new Hologram(MinecraftVersion.V1_12_R1, location.clone().add(0, 0.5, 0), getPlayerLines(player));
}
super.textDisplayHolograms.put(player.getUniqueId(), holo);
return holo;
}
@Override
public void createPackets() {
this.hologram = new Hologram(MinecraftVersion.V1_12_R1, location.clone().add(0, 0.5, 0), text);
Bukkit.getOnlinePlayers().forEach(this::createPackets);
}
@Override
public void createPackets(Player player) {
PacketPlayOutPlayerInfoWrapper packetPlayOutPlayerInfoWrapper = new PacketPlayOutPlayerInfoWrapper();
@ -74,7 +89,7 @@ public class NPC_v1_12_R1 extends NPCBase {
playerConnection.sendPacket(packetPlayOutNamedEntitySpawn);
playerConnection.sendPacket(packetPlayOutEntityHeadRotation);
hologram.show(player);
getPlayerHologram(player).show(player);
// Removing the player info after 10 seconds.
Bukkit.getScheduler().runTaskLater(instance.getPlugin(), () ->


+ 1
- 1
nms/v1_13_R1/pom.xml View File

@ -8,7 +8,7 @@
<parent>
<groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId>
<version>2.9-SNAPSHOT</version>
<version>2.10-SNAPSHOT</version>
</parent>
<artifactId>npclib-nms-v1_13_R1</artifactId>


+ 17
- 2
nms/v1_13_R1/src/main/java/net/jitse/npclib/nms/v1_13_R1/NPC_v1_13_R1.java View File

@ -38,9 +38,24 @@ public class NPC_v1_13_R1 extends NPCBase {
super(instance, lines);
}
@Override
public Hologram getPlayerHologram(Player player) {
Hologram holo = super.getPlayerHologram(player);
if (holo == null){
holo = new Hologram(MinecraftVersion.V1_13_R1, location.clone().add(0, 0.5, 0), getPlayerLines(player));
}
super.textDisplayHolograms.put(player.getUniqueId(), holo);
return holo;
}
@Override
public void createPackets() {
this.hologram = new Hologram(MinecraftVersion.V1_13_R1, location.clone().add(0, 0.5, 0), text);
Bukkit.getOnlinePlayers().forEach(this::createPackets);
}
@Override
public void createPackets(Player player) {
PacketPlayOutPlayerInfoWrapper packetPlayOutPlayerInfoWrapper = new PacketPlayOutPlayerInfoWrapper();
@ -74,7 +89,7 @@ public class NPC_v1_13_R1 extends NPCBase {
playerConnection.sendPacket(packetPlayOutNamedEntitySpawn);
playerConnection.sendPacket(packetPlayOutEntityHeadRotation);
hologram.show(player);
getPlayerHologram(player).show(player);
// Removing the player info after 10 seconds.
Bukkit.getScheduler().runTaskLater(instance.getPlugin(), () ->


+ 1
- 1
nms/v1_13_R2/pom.xml View File

@ -8,7 +8,7 @@
<parent>
<groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId>
<version>2.9-SNAPSHOT</version>
<version>2.10-SNAPSHOT</version>
</parent>
<artifactId>npclib-nms-v1_13_R2</artifactId>


+ 16
- 2
nms/v1_13_R2/src/main/java/net/jitse/npclib/nms/v1_13_R2/NPC_v1_13_R2.java View File

@ -37,10 +37,24 @@ public class NPC_v1_13_R2 extends NPCBase {
public NPC_v1_13_R2(NPCLib instance, List<String> lines) {
super(instance, lines);
}
@Override
public Hologram getPlayerHologram(Player player) {
Hologram holo = super.getPlayerHologram(player);
if (holo == null){
holo = new Hologram(MinecraftVersion.V1_13_R2, location.clone().add(0, 0.5, 0), getPlayerLines(player));
}
super.textDisplayHolograms.put(player.getUniqueId(), holo);
return holo;
}
@Override
public void createPackets() {
this.hologram = new Hologram(MinecraftVersion.V1_13_R2, location.clone().add(0, 0.5, 0), text);
Bukkit.getOnlinePlayers().forEach(this::createPackets);
}
@Override
public void createPackets(Player player) {
PacketPlayOutPlayerInfoWrapper packetPlayOutPlayerInfoWrapper = new PacketPlayOutPlayerInfoWrapper();
@ -74,7 +88,7 @@ public class NPC_v1_13_R2 extends NPCBase {
playerConnection.sendPacket(packetPlayOutNamedEntitySpawn);
playerConnection.sendPacket(packetPlayOutEntityHeadRotation);
hologram.show(player);
getPlayerHologram(player).show(player);
// Removing the player info after 10 seconds.
Bukkit.getScheduler().runTaskLater(instance.getPlugin(), () ->


+ 1
- 1
nms/v1_14_R1/pom.xml View File

@ -8,7 +8,7 @@
<parent>
<groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId>
<version>2.9-SNAPSHOT</version>
<version>2.10-SNAPSHOT</version>
</parent>
<artifactId>npclib-nms-v1_14_R1</artifactId>


+ 16
- 2
nms/v1_14_R1/src/main/java/net/jitse/npclib/nms/v1_14_R1/NPC_v1_14_R1.java View File

@ -33,10 +33,24 @@ public class NPC_v1_14_R1 extends NPCBase {
public NPC_v1_14_R1(NPCLib instance, List<String> lines) {
super(instance, lines);
}
@Override
public Hologram getPlayerHologram(Player player) {
Hologram holo = super.getPlayerHologram(player);
if (holo == null){
holo = new Hologram(MinecraftVersion.V1_14_R1, location.clone().add(0, 0.5, 0), getPlayerLines(player));
}
super.textDisplayHolograms.put(player.getUniqueId(), holo);
return holo;
}
@Override
public void createPackets() {
this.hologram = new Hologram(MinecraftVersion.V1_14_R1, location.clone().add(0, 0.5, 0), text);
Bukkit.getOnlinePlayers().forEach(this::createPackets);
}
@Override
public void createPackets(Player player) {
PacketPlayOutPlayerInfoWrapper packetPlayOutPlayerInfoWrapper = new PacketPlayOutPlayerInfoWrapper();
@ -70,7 +84,7 @@ public class NPC_v1_14_R1 extends NPCBase {
playerConnection.sendPacket(packetPlayOutNamedEntitySpawn);
playerConnection.sendPacket(packetPlayOutEntityHeadRotation);
hologram.show(player);
getPlayerHologram(player).show(player);
// Removing the player info after 10 seconds.
Bukkit.getScheduler().runTaskLater(instance.getPlugin(), () ->


+ 1
- 1
nms/v1_15_R1/pom.xml View File

@ -8,7 +8,7 @@
<parent>
<groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId>
<version>2.9-SNAPSHOT</version>
<version>2.10-SNAPSHOT</version>
</parent>
<artifactId>npclib-nms-v1_15_R1</artifactId>


+ 16
- 2
nms/v1_15_R1/src/main/java/net/jitse/npclib/nms/v1_15_R1/NPC_v1_15_R1.java View File

@ -33,10 +33,24 @@ public class NPC_v1_15_R1 extends NPCBase {
public NPC_v1_15_R1(NPCLib instance, List<String> lines) {
super(instance, lines);
}
@Override
public Hologram getPlayerHologram(Player player) {
Hologram holo = super.getPlayerHologram(player);
if (holo == null){
holo = new Hologram(MinecraftVersion.V1_15_R1, location.clone().add(0, 0.5, 0), getPlayerLines(player));
}
super.textDisplayHolograms.put(player.getUniqueId(), holo);
return holo;
}
@Override
public void createPackets() {
this.hologram = new Hologram(MinecraftVersion.V1_15_R1, location.clone().add(0, 0.5, 0), text);
Bukkit.getOnlinePlayers().forEach(this::createPackets);
}
@Override
public void createPackets(Player player) {
PacketPlayOutPlayerInfoWrapper packetPlayOutPlayerInfoWrapper = new PacketPlayOutPlayerInfoWrapper();
@ -71,7 +85,7 @@ public class NPC_v1_15_R1 extends NPCBase {
playerConnection.sendPacket(packetPlayOutEntityHeadRotation);
sendMetadataPacket(player);
hologram.show(player);
getPlayerHologram(player).show(player);
// Removing the player info after 10 seconds.
Bukkit.getScheduler().runTaskLater(instance.getPlugin(), () ->


+ 1
- 1
nms/v1_16_R1/pom.xml View File

@ -8,7 +8,7 @@
<parent>
<groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId>
<version>2.9-SNAPSHOT</version>
<version>2.10-SNAPSHOT</version>
</parent>
<artifactId>npclib-nms-v1_16_R1</artifactId>


+ 16
- 2
nms/v1_16_R1/src/main/java/net/jitse/npclib/nms/v1_16_R1/NPC_v1_16_R1.java View File

@ -36,10 +36,24 @@ public class NPC_v1_16_R1 extends NPCBase {
public NPC_v1_16_R1(NPCLib instance, List<String> lines) {
super(instance, lines);
}
@Override
public Hologram getPlayerHologram(Player player) {
Hologram holo = super.getPlayerHologram(player);
if (holo == null){
holo = new Hologram(MinecraftVersion.V1_16_R1, location.clone().add(0, 0.5, 0), getPlayerLines(player));
}
super.textDisplayHolograms.put(player.getUniqueId(), holo);
return holo;
}
@Override
public void createPackets() {
this.hologram = new Hologram(MinecraftVersion.V1_15_R1, location.clone().add(0, 0.5, 0), text);
Bukkit.getOnlinePlayers().forEach(this::createPackets);
}
@Override
public void createPackets(Player player) {
PacketPlayOutPlayerInfoWrapper packetPlayOutPlayerInfoWrapper = new PacketPlayOutPlayerInfoWrapper();
@ -74,7 +88,7 @@ public class NPC_v1_16_R1 extends NPCBase {
playerConnection.sendPacket(packetPlayOutEntityHeadRotation);
sendMetadataPacket(player);
hologram.show(player);
getPlayerHologram(player).show(player);
// Removing the player info after 10 seconds.
Bukkit.getScheduler().runTaskLater(instance.getPlugin(), () ->


+ 1
- 1
nms/v1_8_R2/pom.xml View File

@ -8,7 +8,7 @@
<parent>
<groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId>
<version>2.9-SNAPSHOT</version>
<version>2.10-SNAPSHOT</version>
</parent>
<artifactId>npclib-nms-v1_8_R2</artifactId>


+ 18
- 2
nms/v1_8_R2/src/main/java/net/jitse/npclib/nms/v1_8_R2/NPC_v1_8_R2.java View File

@ -38,9 +38,24 @@ public class NPC_v1_8_R2 extends NPCBase {
super(instance, lines);
}
@Override
public Hologram getPlayerHologram(Player player) {
Hologram holo = super.getPlayerHologram(player);
if (holo == null){
holo = new Hologram(MinecraftVersion.V1_8_R2, location.clone().add(0, 0.5, 0), getPlayerLines(player));
}
super.textDisplayHolograms.put(player.getUniqueId(), holo);
return holo;
}
@Override
public void createPackets() {
this.hologram = new Hologram(MinecraftVersion.V1_8_R2, location.clone().add(0, 0.5, 0), text);
Bukkit.getOnlinePlayers().forEach(this::createPackets);
}
@Override
public void createPackets(Player player) {
PacketPlayOutPlayerInfoWrapper packetPlayOutPlayerInfoWrapper = new PacketPlayOutPlayerInfoWrapper();
@ -64,6 +79,7 @@ public class NPC_v1_8_R2 extends NPCBase {
this.packetPlayOutEntityDestroy = new PacketPlayOutEntityDestroy(entityId); // First packet to send.
}
@Override
public void sendShowPackets(Player player) {
PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().playerConnection;
@ -74,7 +90,7 @@ public class NPC_v1_8_R2 extends NPCBase {
playerConnection.sendPacket(packetPlayOutNamedEntitySpawn);
playerConnection.sendPacket(packetPlayOutEntityHeadRotation);
hologram.show(player);
getPlayerHologram(player).show(player);
// Removing the player info after 10 seconds.
Bukkit.getScheduler().runTaskLater(instance.getPlugin(), () ->


+ 1
- 1
nms/v1_8_R3/pom.xml View File

@ -8,7 +8,7 @@
<parent>
<groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId>
<version>2.9-SNAPSHOT</version>
<version>2.10-SNAPSHOT</version>
</parent>
<artifactId>npclib-nms-v1_8_R3</artifactId>


+ 16
- 2
nms/v1_8_R3/src/main/java/net/jitse/npclib/nms/v1_8_R3/NPC_v1_8_R3.java View File

@ -38,9 +38,23 @@ public class NPC_v1_8_R3 extends NPCBase {
super(instance, lines);
}
@Override
public Hologram getPlayerHologram(Player player) {
Hologram holo = super.getPlayerHologram(player);
if (holo == null){
holo = new Hologram(MinecraftVersion.V1_8_R3, location.clone().add(0, 0.5, 0), getPlayerLines(player));
}
super.textDisplayHolograms.put(player.getUniqueId(), holo);
return holo;
}
@Override
public void createPackets() {
this.hologram = new Hologram(MinecraftVersion.V1_8_R3, location.clone().add(0, 0.5, 0), text);
Bukkit.getOnlinePlayers().forEach(this::createPackets);
}
@Override
public void createPackets(Player player) {
PacketPlayOutPlayerInfoWrapper packetPlayOutPlayerInfoWrapper = new PacketPlayOutPlayerInfoWrapper();
@ -74,7 +88,7 @@ public class NPC_v1_8_R3 extends NPCBase {
playerConnection.sendPacket(packetPlayOutNamedEntitySpawn);
playerConnection.sendPacket(packetPlayOutEntityHeadRotation);
hologram.show(player);
getPlayerHologram(player).show(player);
// Removing the player info after 10 seconds.
Bukkit.getScheduler().runTaskLater(instance.getPlugin(), () ->


+ 1
- 1
nms/v1_9_R1/pom.xml View File

@ -8,7 +8,7 @@
<parent>
<groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId>
<version>2.9-SNAPSHOT</version>
<version>2.10-SNAPSHOT</version>
</parent>
<artifactId>npclib-nms-v1_9_R1</artifactId>


+ 17
- 2
nms/v1_9_R1/src/main/java/net/jitse/npclib/nms/v1_9_R1/NPC_v1_9_R1.java View File

@ -38,9 +38,24 @@ public class NPC_v1_9_R1 extends NPCBase {
super(instance, lines);
}
@Override
public Hologram getPlayerHologram(Player player) {
Hologram holo = super.getPlayerHologram(player);
if (holo == null){
holo = new Hologram(MinecraftVersion.V1_9_R1, location.clone().add(0, 0.5, 0), getPlayerLines(player));
}
super.textDisplayHolograms.put(player.getUniqueId(), holo);
return holo;
}
@Override
public void createPackets() {
this.hologram = new Hologram(MinecraftVersion.V1_9_R1, location.clone().subtract(0, 0.5, 0), text);
Bukkit.getOnlinePlayers().forEach(this::createPackets);
}
@Override
public void createPackets(Player player) {
PacketPlayOutPlayerInfoWrapper packetPlayOutPlayerInfoWrapper = new PacketPlayOutPlayerInfoWrapper();
@ -74,7 +89,7 @@ public class NPC_v1_9_R1 extends NPCBase {
playerConnection.sendPacket(packetPlayOutNamedEntitySpawn);
playerConnection.sendPacket(packetPlayOutEntityHeadRotation);
hologram.show(player);
getPlayerHologram(player).show(player);
// Removing the player info after 10 seconds.
Bukkit.getScheduler().runTaskLater(instance.getPlugin(), () ->


+ 1
- 1
nms/v1_9_R2/pom.xml View File

@ -8,7 +8,7 @@
<parent>
<groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId>
<version>2.9-SNAPSHOT</version>
<version>2.10-SNAPSHOT</version>
</parent>
<artifactId>npclib-nms-v1_9_R2</artifactId>


+ 18
- 2
nms/v1_9_R2/src/main/java/net/jitse/npclib/nms/v1_9_R2/NPC_v1_9_R2.java View File

@ -38,9 +38,25 @@ public class NPC_v1_9_R2 extends NPCBase {
super(instance, lines);
}
@Override
public Hologram getPlayerHologram(Player player) {
Hologram holo = super.getPlayerHologram(player);
if (holo == null){
holo = new Hologram(MinecraftVersion.V1_9_R2, location.clone().add(0, 0.5, 0), getPlayerLines(player));
}
super.textDisplayHolograms.put(player.getUniqueId(), holo);
return holo;
}
@Override
public void createPackets() {
this.hologram = new Hologram(MinecraftVersion.V1_9_R2, location.clone().subtract(0, 0.5, 0), text);
Bukkit.getOnlinePlayers().forEach(this::createPackets);
}
@Override
public void createPackets(Player player) {
PacketPlayOutPlayerInfoWrapper packetPlayOutPlayerInfoWrapper = new PacketPlayOutPlayerInfoWrapper();
@ -74,7 +90,7 @@ public class NPC_v1_9_R2 extends NPCBase {
playerConnection.sendPacket(packetPlayOutNamedEntitySpawn);
playerConnection.sendPacket(packetPlayOutEntityHeadRotation);
hologram.show(player);
getPlayerHologram(player).show(player);
// Removing the player info after 10 seconds.
Bukkit.getScheduler().runTaskLater(instance.getPlugin(), () ->


+ 1
- 1
plugin/pom.xml View File

@ -8,7 +8,7 @@
<parent>
<groupId>net.jitse</groupId>
<artifactId>npclib</artifactId>
<version>2.9-SNAPSHOT</version>
<version>2.10-SNAPSHOT</version>
</parent>
<artifactId>npclib-plugin</artifactId>


+ 1
- 1
pom.xml View File

@ -7,7 +7,7 @@
<groupId>net.jitse</groupId>
<artifactId>npclib</artifactId>
<version>2.9-SNAPSHOT</version>
<version>2.10-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>


Loading…
Cancel
Save