For 2.3-SNAPSHOT, text update method (#11)!

This commit is contained in:
Jitse Boonstra
2019-10-29 12:43:54 +01:00
parent d9558eef63
commit 5650cbd1e2
32 changed files with 287 additions and 471 deletions
+11 -11
View File
@@ -8,23 +8,23 @@
<parent>
<groupId>net.jitse</groupId>
<artifactId>npclib</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.3-SNAPSHOT</version>
</parent>
<artifactId>npclib-nms</artifactId>
<modules>
<module>v1_8_R1</module>
<!-- <module>v1_8_R2</module>-->
<!-- <module>v1_8_R3</module>-->
<!-- <module>v1_9_R1</module>-->
<!-- <module>v1_9_R2</module>-->
<!-- <module>v1_10_R1</module>-->
<!-- <module>v1_11_R1</module>-->
<!-- <module>v1_12_R1</module>-->
<!-- <module>v1_13_R1</module>-->
<!-- <module>v1_13_R2</module>-->
<!-- <module>v1_14_R1</module>-->
<module>v1_8_R2</module>
<module>v1_8_R3</module>
<module>v1_9_R1</module>
<module>v1_9_R2</module>
<module>v1_10_R1</module>
<module>v1_11_R1</module>
<module>v1_12_R1</module>
<module>v1_13_R1</module>
<module>v1_13_R2</module>
<module>v1_14_R1</module>
</modules>
<dependencies>
+1 -1
View File
@@ -8,7 +8,7 @@
<parent>
<groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.3-SNAPSHOT</version>
</parent>
<artifactId>npclib-nms-v1_10_R1</artifactId>
@@ -6,7 +6,7 @@ package net.jitse.npclib.nms.v1_10_R1;
import net.jitse.npclib.NPCLib;
import net.jitse.npclib.api.state.NPCSlot;
import net.jitse.npclib.hologram._Hologram;
import net.jitse.npclib.hologram.Hologram;
import net.jitse.npclib.internal.MinecraftVersion;
import net.jitse.npclib.internal.NPCBase;
import net.jitse.npclib.nms.v1_10_R1.packets.*;
@@ -27,7 +27,6 @@ import java.util.UUID;
*/
public class NPC_v1_10_R1 extends NPCBase {
private _Hologram hologram;
private PacketPlayOutNamedEntitySpawn packetPlayOutNamedEntitySpawn;
private PacketPlayOutScoreboardTeam packetPlayOutScoreboardTeamRegister;
private PacketPlayOutPlayerInfo packetPlayOutPlayerInfoAdd, packetPlayOutPlayerInfoRemove;
@@ -41,8 +40,7 @@ public class NPC_v1_10_R1 extends NPCBase {
@Override
public void createPackets() {
this.hologram = new _Hologram(location.clone().subtract(0, 0.5, 0), text);
hologram.generatePackets(MinecraftVersion.V1_10_R1);
this.hologram = new Hologram(MinecraftVersion.V1_10_R1, location.clone().subtract(0, 0.5, 0), text);
PacketPlayOutPlayerInfoWrapper packetPlayOutPlayerInfoWrapper = new PacketPlayOutPlayerInfoWrapper();
@@ -82,8 +80,7 @@ public class NPC_v1_10_R1 extends NPCBase {
playerConnection.sendPacket(packetPlayOutNamedEntitySpawn);
playerConnection.sendPacket(packetPlayOutEntityHeadRotation);
hologram.spawn(player);
hologram.show(player);
Bukkit.getScheduler().runTaskLater(instance.getPlugin(), () ->
playerConnection.sendPacket(packetPlayOutPlayerInfoRemove), 50);
@@ -95,7 +92,8 @@ public class NPC_v1_10_R1 extends NPCBase {
playerConnection.sendPacket(packetPlayOutEntityDestroy);
playerConnection.sendPacket(packetPlayOutPlayerInfoRemove);
hologram.destroy(player);
hologram.hide(player);
}
@Override
+1 -1
View File
@@ -8,7 +8,7 @@
<parent>
<groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.3-SNAPSHOT</version>
</parent>
<artifactId>npclib-nms-v1_11_R1</artifactId>
@@ -6,7 +6,7 @@ package net.jitse.npclib.nms.v1_11_R1;
import net.jitse.npclib.NPCLib;
import net.jitse.npclib.api.state.NPCSlot;
import net.jitse.npclib.hologram._Hologram;
import net.jitse.npclib.hologram.Hologram;
import net.jitse.npclib.internal.MinecraftVersion;
import net.jitse.npclib.internal.NPCBase;
import net.jitse.npclib.nms.v1_11_R1.packets.*;
@@ -27,7 +27,6 @@ import java.util.UUID;
*/
public class NPC_v1_11_R1 extends NPCBase {
private _Hologram hologram;
private PacketPlayOutNamedEntitySpawn packetPlayOutNamedEntitySpawn;
private PacketPlayOutScoreboardTeam packetPlayOutScoreboardTeamRegister;
private PacketPlayOutPlayerInfo packetPlayOutPlayerInfoAdd, packetPlayOutPlayerInfoRemove;
@@ -41,8 +40,7 @@ public class NPC_v1_11_R1 extends NPCBase {
@Override
public void createPackets() {
this.hologram = new _Hologram(location.clone().add(0, 0.5, 0), text);
hologram.generatePackets(MinecraftVersion.V1_11_R1);
this.hologram = new Hologram(MinecraftVersion.V1_11_R1, location.clone().add(0, 0.5, 0), text);
PacketPlayOutPlayerInfoWrapper packetPlayOutPlayerInfoWrapper = new PacketPlayOutPlayerInfoWrapper();
@@ -82,8 +80,7 @@ public class NPC_v1_11_R1 extends NPCBase {
playerConnection.sendPacket(packetPlayOutNamedEntitySpawn);
playerConnection.sendPacket(packetPlayOutEntityHeadRotation);
hologram.spawn(player);
hologram.show(player);
Bukkit.getScheduler().runTaskLater(instance.getPlugin(), () ->
playerConnection.sendPacket(packetPlayOutPlayerInfoRemove), 50);
@@ -95,7 +92,8 @@ public class NPC_v1_11_R1 extends NPCBase {
playerConnection.sendPacket(packetPlayOutEntityDestroy);
playerConnection.sendPacket(packetPlayOutPlayerInfoRemove);
hologram.destroy(player);
hologram.hide(player);
}
@Override
+1 -1
View File
@@ -8,7 +8,7 @@
<parent>
<groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.3-SNAPSHOT</version>
</parent>
<artifactId>npclib-nms-v1_12_R1</artifactId>
@@ -6,7 +6,7 @@ package net.jitse.npclib.nms.v1_12_R1;
import net.jitse.npclib.NPCLib;
import net.jitse.npclib.api.state.NPCSlot;
import net.jitse.npclib.hologram._Hologram;
import net.jitse.npclib.hologram.Hologram;
import net.jitse.npclib.internal.MinecraftVersion;
import net.jitse.npclib.internal.NPCBase;
import net.jitse.npclib.nms.v1_12_R1.packets.*;
@@ -26,7 +26,7 @@ import java.util.UUID;
* @author Jitse Boonstra
*/
public class NPC_v1_12_R1 extends NPCBase {
private _Hologram hologram;
private PacketPlayOutNamedEntitySpawn packetPlayOutNamedEntitySpawn;
private PacketPlayOutScoreboardTeam packetPlayOutScoreboardTeamRegister;
private PacketPlayOutPlayerInfo packetPlayOutPlayerInfoAdd, packetPlayOutPlayerInfoRemove;
@@ -40,8 +40,7 @@ public class NPC_v1_12_R1 extends NPCBase {
@Override
public void createPackets() {
this.hologram = new _Hologram(location.clone().add(0, 0.5, 0), text);
hologram.generatePackets(MinecraftVersion.V1_12_R1);
this.hologram = new Hologram(MinecraftVersion.V1_12_R1, location.clone().add(0, 0.5, 0), text);
PacketPlayOutPlayerInfoWrapper packetPlayOutPlayerInfoWrapper = new PacketPlayOutPlayerInfoWrapper();
@@ -81,7 +80,7 @@ public class NPC_v1_12_R1 extends NPCBase {
playerConnection.sendPacket(packetPlayOutNamedEntitySpawn);
playerConnection.sendPacket(packetPlayOutEntityHeadRotation);
hologram.spawn(player);
hologram.show(player);
Bukkit.getScheduler().runTaskLater(instance.getPlugin(), () ->
playerConnection.sendPacket(packetPlayOutPlayerInfoRemove), 50);
@@ -93,7 +92,8 @@ public class NPC_v1_12_R1 extends NPCBase {
playerConnection.sendPacket(packetPlayOutEntityDestroy);
playerConnection.sendPacket(packetPlayOutPlayerInfoRemove);
hologram.destroy(player);
hologram.hide(player);
}
@Override
+1 -1
View File
@@ -8,7 +8,7 @@
<parent>
<groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.3-SNAPSHOT</version>
</parent>
<artifactId>npclib-nms-v1_13_R1</artifactId>
@@ -6,7 +6,7 @@ package net.jitse.npclib.nms.v1_13_R1;
import net.jitse.npclib.NPCLib;
import net.jitse.npclib.api.state.NPCSlot;
import net.jitse.npclib.hologram._Hologram;
import net.jitse.npclib.hologram.Hologram;
import net.jitse.npclib.internal.MinecraftVersion;
import net.jitse.npclib.internal.NPCBase;
import net.jitse.npclib.nms.v1_13_R1.packets.*;
@@ -27,7 +27,6 @@ import java.util.UUID;
*/
public class NPC_v1_13_R1 extends NPCBase {
private _Hologram hologram;
private PacketPlayOutNamedEntitySpawn packetPlayOutNamedEntitySpawn;
private PacketPlayOutScoreboardTeam packetPlayOutScoreboardTeamRegister;
private PacketPlayOutPlayerInfo packetPlayOutPlayerInfoAdd, packetPlayOutPlayerInfoRemove;
@@ -41,8 +40,7 @@ public class NPC_v1_13_R1 extends NPCBase {
@Override
public void createPackets() {
this.hologram = new _Hologram(location.clone().add(0, 0.5, 0), text);
hologram.generatePackets(MinecraftVersion.V1_13_R1);
this.hologram = new Hologram(MinecraftVersion.V1_13_R1, location.clone().add(0, 0.5, 0), text);
PacketPlayOutPlayerInfoWrapper packetPlayOutPlayerInfoWrapper = new PacketPlayOutPlayerInfoWrapper();
@@ -82,7 +80,7 @@ public class NPC_v1_13_R1 extends NPCBase {
playerConnection.sendPacket(packetPlayOutNamedEntitySpawn);
playerConnection.sendPacket(packetPlayOutEntityHeadRotation);
hologram.spawn(player);
hologram.show(player);
Bukkit.getScheduler().runTaskLater(instance.getPlugin(), () ->
playerConnection.sendPacket(packetPlayOutPlayerInfoRemove), 50);
@@ -94,7 +92,8 @@ public class NPC_v1_13_R1 extends NPCBase {
playerConnection.sendPacket(packetPlayOutEntityDestroy);
playerConnection.sendPacket(packetPlayOutPlayerInfoRemove);
hologram.destroy(player);
hologram.hide(player);
}
@Override
+1 -1
View File
@@ -8,7 +8,7 @@
<parent>
<groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.3-SNAPSHOT</version>
</parent>
<artifactId>npclib-nms-v1_13_R2</artifactId>
@@ -6,7 +6,7 @@ package net.jitse.npclib.nms.v1_13_R2;
import net.jitse.npclib.NPCLib;
import net.jitse.npclib.api.state.NPCSlot;
import net.jitse.npclib.hologram._Hologram;
import net.jitse.npclib.hologram.Hologram;
import net.jitse.npclib.internal.MinecraftVersion;
import net.jitse.npclib.internal.NPCBase;
import net.jitse.npclib.nms.v1_13_R2.packets.*;
@@ -27,7 +27,6 @@ import java.util.UUID;
*/
public class NPC_v1_13_R2 extends NPCBase {
private _Hologram hologram;
private PacketPlayOutNamedEntitySpawn packetPlayOutNamedEntitySpawn;
private PacketPlayOutScoreboardTeam packetPlayOutScoreboardTeamRegister;
private PacketPlayOutPlayerInfo packetPlayOutPlayerInfoAdd, packetPlayOutPlayerInfoRemove;
@@ -41,8 +40,7 @@ public class NPC_v1_13_R2 extends NPCBase {
@Override
public void createPackets() {
this.hologram = new _Hologram(location.clone().add(0, 0.5, 0), text);
hologram.generatePackets(MinecraftVersion.V1_13_R2);
this.hologram = new Hologram(MinecraftVersion.V1_13_R2, location.clone().add(0, 0.5, 0), text);
PacketPlayOutPlayerInfoWrapper packetPlayOutPlayerInfoWrapper = new PacketPlayOutPlayerInfoWrapper();
@@ -82,8 +80,7 @@ public class NPC_v1_13_R2 extends NPCBase {
playerConnection.sendPacket(packetPlayOutNamedEntitySpawn);
playerConnection.sendPacket(packetPlayOutEntityHeadRotation);
hologram.spawn(player);
hologram.show(player);
Bukkit.getScheduler().runTaskLater(instance.getPlugin(), () ->
playerConnection.sendPacket(packetPlayOutPlayerInfoRemove), 50);
@@ -95,7 +92,8 @@ public class NPC_v1_13_R2 extends NPCBase {
playerConnection.sendPacket(packetPlayOutEntityDestroy);
playerConnection.sendPacket(packetPlayOutPlayerInfoRemove);
hologram.destroy(player);
hologram.hide(player);
}
@Override
+1 -1
View File
@@ -8,7 +8,7 @@
<parent>
<groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.3-SNAPSHOT</version>
</parent>
<artifactId>npclib-nms-v1_14_R1</artifactId>
@@ -2,7 +2,7 @@ package net.jitse.npclib.nms.v1_14_R1;
import net.jitse.npclib.NPCLib;
import net.jitse.npclib.api.state.NPCSlot;
import net.jitse.npclib.hologram._Hologram;
import net.jitse.npclib.hologram.Hologram;
import net.jitse.npclib.internal.MinecraftVersion;
import net.jitse.npclib.internal.NPCBase;
import net.jitse.npclib.nms.v1_14_R1.packets.*;
@@ -23,7 +23,6 @@ import java.util.UUID;
*/
public class NPC_v1_14_R1 extends NPCBase {
private _Hologram hologram;
private PacketPlayOutNamedEntitySpawn packetPlayOutNamedEntitySpawn;
private PacketPlayOutScoreboardTeam packetPlayOutScoreboardTeamRegister;
private PacketPlayOutPlayerInfo packetPlayOutPlayerInfoAdd, packetPlayOutPlayerInfoRemove;
@@ -37,8 +36,7 @@ public class NPC_v1_14_R1 extends NPCBase {
@Override
public void createPackets() {
this.hologram = new _Hologram(location.clone().add(0, 0.5, 0), text);
hologram.generatePackets(MinecraftVersion.V1_14_R1);
this.hologram = new Hologram(MinecraftVersion.V1_14_R1, location.clone().add(0, 0.5, 0), text);
PacketPlayOutPlayerInfoWrapper packetPlayOutPlayerInfoWrapper = new PacketPlayOutPlayerInfoWrapper();
@@ -78,8 +76,7 @@ public class NPC_v1_14_R1 extends NPCBase {
playerConnection.sendPacket(packetPlayOutNamedEntitySpawn);
playerConnection.sendPacket(packetPlayOutEntityHeadRotation);
hologram.spawn(player);
hologram.show(player);
Bukkit.getScheduler().runTaskLater(instance.getPlugin(), () ->
playerConnection.sendPacket(packetPlayOutPlayerInfoRemove), 50);
@@ -91,7 +88,8 @@ public class NPC_v1_14_R1 extends NPCBase {
playerConnection.sendPacket(packetPlayOutEntityDestroy);
playerConnection.sendPacket(packetPlayOutPlayerInfoRemove);
hologram.destroy(player);
hologram.hide(player);
}
@Override
+1 -1
View File
@@ -8,7 +8,7 @@
<parent>
<groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.3-SNAPSHOT</version>
</parent>
<artifactId>npclib-nms-v1_8_R1</artifactId>
@@ -6,8 +6,9 @@ package net.jitse.npclib.nms.v1_8_R1;
import net.jitse.npclib.NPCLib;
import net.jitse.npclib.api.state.NPCSlot;
import net.jitse.npclib.hologram.Hologram;
import net.jitse.npclib.internal.MinecraftVersion;
import net.jitse.npclib.internal.NPCBase;
import net.jitse.npclib.nms.v1_8_R1.hologram.Hologram_v1_8_R1;
import net.jitse.npclib.nms.v1_8_R1.packets.*;
import net.minecraft.server.v1_8_R1.*;
import org.bukkit.Bukkit;
@@ -39,7 +40,7 @@ public class NPC_v1_8_R1 extends NPCBase {
@Override
public void createPackets() {
this.hologram = new Hologram_v1_8_R1(location.clone().add(0, 0.5, 0), text);
this.hologram = new Hologram(MinecraftVersion.V1_8_R1, location.clone().add(0, 0.5, 0), text);
PacketPlayOutPlayerInfoWrapper packetPlayOutPlayerInfoWrapper = new PacketPlayOutPlayerInfoWrapper();
@@ -1,122 +0,0 @@
package net.jitse.npclib.nms.v1_8_R1.hologram;
import net.jitse.npclib.hologram.HologramBase;
import net.minecraft.server.v1_8_R1.*;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_8_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_8_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
public class Hologram_v1_8_R1 extends HologramBase {
private List<EntityArmorStand> nmsArmorStands;
private List<PacketPlayOutSpawnEntityLiving> showPackets;
private List<PacketPlayOutEntityDestroy> hidePackets;
public Hologram_v1_8_R1(Location start, List<String> text) {
super(start, text);
}
@Override
public void createPackets() {
Location top = start.clone().add(0, DELTA * text.size(), 0);
List<EntityArmorStand> nmsArmorStands = new ArrayList<>();
List<PacketPlayOutSpawnEntityLiving> showPackets = new ArrayList<>();
List<PacketPlayOutEntityDestroy> hidePackets = new ArrayList<>();
for (String line : text) {
EntityArmorStand armorStand = new EntityArmorStand(((CraftWorld) top.getWorld()).getHandle());
armorStand.setLocation(top.getX(), top.getY(), top.getZ(), 0, 0);
armorStand.setCustomName(line);
armorStand.setCustomNameVisible(true);
armorStand.setGravity(false);
armorStand.setSmall(true);
armorStand.setInvisible(true);
armorStand.setBasePlate(false);
armorStand.setArms(false);
nmsArmorStands.add(armorStand);
PacketPlayOutSpawnEntityLiving lineShowPacket = new PacketPlayOutSpawnEntityLiving(armorStand);
PacketPlayOutEntityDestroy lineHidePacket = new PacketPlayOutEntityDestroy(armorStand.getId());
showPackets.add(lineShowPacket);
hidePackets.add(lineHidePacket);
top.subtract(0, DELTA, 0);
}
this.nmsArmorStands = nmsArmorStands;
this.showPackets = showPackets;
this.hidePackets = hidePackets;
}
@Override
public void sendShowPackets(Player player) {
PlayerConnection connection = ((CraftPlayer) player).getHandle().playerConnection;
for (int i = 0; i < text.size(); i++) {
if (text.get(i).isEmpty()) continue; // No need to spawn the line.
connection.sendPacket(showPackets.get(i));
}
}
@Override
public void sendHidePackets(Player player) {
PlayerConnection connection = ((CraftPlayer) player).getHandle().playerConnection;
for (int i = 0; i < text.size(); i++) {
if (text.get(i).isEmpty()) continue; // No need to hide the line (as it was never spawned).
connection.sendPacket(hidePackets.get(i));
}
}
@Override
public void updateText(List<String> text) {
List<Packet> toSend = new ArrayList<>();
if (this.text.size() != text.size())
throw new IllegalArgumentException("When updating the text, the old and new text should have the same amount of lines");
for (int i = 0; i < text.size(); i++) {
EntityArmorStand armorStand = nmsArmorStands.get(i);
String oldLine = this.text.get(i);
String newLine = text.get(i);
armorStand.getDataWatcher().watch(2, newLine); // Update the DataWatcher object.
if (oldLine.equals(newLine)) {
continue; // No need to update.
} else if (newLine.isEmpty() && !oldLine.isEmpty()) {
// Check if line was empty before, if not, remove the hologram line.
toSend.add(hidePackets.get(i));
} else if (!newLine.isEmpty() && oldLine.isEmpty()) {
// Check if line was empty before, if it was, create the hologram line.
PacketPlayOutSpawnEntityLiving lineShowPacket = new PacketPlayOutSpawnEntityLiving(armorStand);
toSend.add(lineShowPacket);
} else {
// If the line was not empty before and it isn't now, update its text.
PacketPlayOutEntityMetadata metadataPacket = new PacketPlayOutEntityMetadata(armorStand.getId(), armorStand.getDataWatcher(), true);
toSend.add(metadataPacket);
}
}
for (UUID uuid : shown) {
Player player = Bukkit.getPlayer(uuid);
if (player == null || !player.isOnline()) {
throw new IllegalStateException("Tried to update hologram for offline player");
}
PlayerConnection connection = ((CraftPlayer) player).getHandle().playerConnection;
for (Packet packet : toSend) {
connection.sendPacket(packet);
}
}
this.text = text; // At last, update the text in this hologram object.
}
}
+1 -1
View File
@@ -8,7 +8,7 @@
<parent>
<groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.3-SNAPSHOT</version>
</parent>
<artifactId>npclib-nms-v1_8_R2</artifactId>
@@ -6,7 +6,7 @@ package net.jitse.npclib.nms.v1_8_R2;
import net.jitse.npclib.NPCLib;
import net.jitse.npclib.api.state.NPCSlot;
import net.jitse.npclib.hologram._Hologram;
import net.jitse.npclib.hologram.Hologram;
import net.jitse.npclib.internal.MinecraftVersion;
import net.jitse.npclib.internal.NPCBase;
import net.jitse.npclib.nms.v1_8_R2.packets.*;
@@ -27,7 +27,6 @@ import java.util.UUID;
*/
public class NPC_v1_8_R2 extends NPCBase {
private _Hologram hologram;
private PacketPlayOutNamedEntitySpawn packetPlayOutNamedEntitySpawn;
private PacketPlayOutScoreboardTeam packetPlayOutScoreboardTeamRegister;
private PacketPlayOutPlayerInfo packetPlayOutPlayerInfoAdd, packetPlayOutPlayerInfoRemove;
@@ -41,8 +40,7 @@ public class NPC_v1_8_R2 extends NPCBase {
@Override
public void createPackets() {
this.hologram = new _Hologram(location.clone().add(0, 0.5, 0), text);
hologram.generatePackets(MinecraftVersion.V1_8_R2);
this.hologram = new Hologram(MinecraftVersion.V1_8_R2, location.clone().add(0, 0.5, 0), text);
PacketPlayOutPlayerInfoWrapper packetPlayOutPlayerInfoWrapper = new PacketPlayOutPlayerInfoWrapper();
@@ -82,7 +80,7 @@ public class NPC_v1_8_R2 extends NPCBase {
playerConnection.sendPacket(packetPlayOutNamedEntitySpawn);
playerConnection.sendPacket(packetPlayOutEntityHeadRotation);
hologram.spawn(player);
hologram.show(player);
Bukkit.getScheduler().runTaskLater(instance.getPlugin(), () ->
playerConnection.sendPacket(packetPlayOutPlayerInfoRemove), 50);
@@ -94,7 +92,7 @@ public class NPC_v1_8_R2 extends NPCBase {
playerConnection.sendPacket(packetPlayOutEntityDestroy);
playerConnection.sendPacket(packetPlayOutPlayerInfoRemove);
hologram.destroy(player);
hologram.hide(player);
}
@Override
+1 -1
View File
@@ -8,7 +8,7 @@
<parent>
<groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.3-SNAPSHOT</version>
</parent>
<artifactId>npclib-nms-v1_8_R3</artifactId>
@@ -6,7 +6,7 @@ package net.jitse.npclib.nms.v1_8_R3;
import net.jitse.npclib.NPCLib;
import net.jitse.npclib.api.state.NPCSlot;
import net.jitse.npclib.hologram._Hologram;
import net.jitse.npclib.hologram.Hologram;
import net.jitse.npclib.internal.MinecraftVersion;
import net.jitse.npclib.internal.NPCBase;
import net.jitse.npclib.nms.v1_8_R3.packets.*;
@@ -27,7 +27,6 @@ import java.util.UUID;
*/
public class NPC_v1_8_R3 extends NPCBase {
private _Hologram hologram;
private PacketPlayOutNamedEntitySpawn packetPlayOutNamedEntitySpawn;
private PacketPlayOutScoreboardTeam packetPlayOutScoreboardTeamRegister;
private PacketPlayOutPlayerInfo packetPlayOutPlayerInfoAdd, packetPlayOutPlayerInfoRemove;
@@ -41,8 +40,7 @@ public class NPC_v1_8_R3 extends NPCBase {
@Override
public void createPackets() {
this.hologram = new _Hologram(location.clone().add(0, 0.5, 0), text);
hologram.generatePackets(MinecraftVersion.V1_8_R3);
this.hologram = new Hologram(MinecraftVersion.V1_8_R3, location.clone().add(0, 0.5, 0), text);
PacketPlayOutPlayerInfoWrapper packetPlayOutPlayerInfoWrapper = new PacketPlayOutPlayerInfoWrapper();
@@ -82,8 +80,7 @@ public class NPC_v1_8_R3 extends NPCBase {
playerConnection.sendPacket(packetPlayOutNamedEntitySpawn);
playerConnection.sendPacket(packetPlayOutEntityHeadRotation);
hologram.spawn(player);
hologram.show(player);
Bukkit.getScheduler().runTaskLater(instance.getPlugin(), () ->
playerConnection.sendPacket(packetPlayOutPlayerInfoRemove), 50);
@@ -95,7 +92,8 @@ public class NPC_v1_8_R3 extends NPCBase {
playerConnection.sendPacket(packetPlayOutEntityDestroy);
playerConnection.sendPacket(packetPlayOutPlayerInfoRemove);
hologram.destroy(player);
hologram.hide(player);
}
@Override
+1 -1
View File
@@ -8,7 +8,7 @@
<parent>
<groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.3-SNAPSHOT</version>
</parent>
<artifactId>npclib-nms-v1_9_R1</artifactId>
@@ -6,7 +6,7 @@ package net.jitse.npclib.nms.v1_9_R1;
import net.jitse.npclib.NPCLib;
import net.jitse.npclib.api.state.NPCSlot;
import net.jitse.npclib.hologram._Hologram;
import net.jitse.npclib.hologram.Hologram;
import net.jitse.npclib.internal.MinecraftVersion;
import net.jitse.npclib.internal.NPCBase;
import net.jitse.npclib.nms.v1_9_R1.packets.*;
@@ -27,7 +27,6 @@ import java.util.UUID;
*/
public class NPC_v1_9_R1 extends NPCBase {
private _Hologram hologram;
private PacketPlayOutNamedEntitySpawn packetPlayOutNamedEntitySpawn;
private PacketPlayOutScoreboardTeam packetPlayOutScoreboardTeamRegister;
private PacketPlayOutPlayerInfo packetPlayOutPlayerInfoAdd, packetPlayOutPlayerInfoRemove;
@@ -41,8 +40,7 @@ public class NPC_v1_9_R1 extends NPCBase {
@Override
public void createPackets() {
this.hologram = new _Hologram(location.clone().subtract(0, 0.5, 0), text);
hologram.generatePackets(MinecraftVersion.V1_9_R1);
this.hologram = new Hologram(MinecraftVersion.V1_9_R1, location.clone().subtract(0, 0.5, 0), text);
PacketPlayOutPlayerInfoWrapper packetPlayOutPlayerInfoWrapper = new PacketPlayOutPlayerInfoWrapper();
@@ -82,7 +80,7 @@ public class NPC_v1_9_R1 extends NPCBase {
playerConnection.sendPacket(packetPlayOutNamedEntitySpawn);
playerConnection.sendPacket(packetPlayOutEntityHeadRotation);
hologram.spawn(player);
hologram.show(player);
Bukkit.getScheduler().runTaskLater(instance.getPlugin(), () ->
playerConnection.sendPacket(packetPlayOutPlayerInfoRemove), 50);
@@ -94,7 +92,8 @@ public class NPC_v1_9_R1 extends NPCBase {
playerConnection.sendPacket(packetPlayOutEntityDestroy);
playerConnection.sendPacket(packetPlayOutPlayerInfoRemove);
hologram.destroy(player);
hologram.hide(player);
}
@Override
+1 -1
View File
@@ -8,7 +8,7 @@
<parent>
<groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.3-SNAPSHOT</version>
</parent>
<artifactId>npclib-nms-v1_9_R2</artifactId>
@@ -6,7 +6,7 @@ package net.jitse.npclib.nms.v1_9_R2;
import net.jitse.npclib.NPCLib;
import net.jitse.npclib.api.state.NPCSlot;
import net.jitse.npclib.hologram._Hologram;
import net.jitse.npclib.hologram.Hologram;
import net.jitse.npclib.internal.MinecraftVersion;
import net.jitse.npclib.internal.NPCBase;
import net.jitse.npclib.nms.v1_9_R2.packets.*;
@@ -27,7 +27,6 @@ import java.util.UUID;
*/
public class NPC_v1_9_R2 extends NPCBase {
private _Hologram hologram;
private PacketPlayOutNamedEntitySpawn packetPlayOutNamedEntitySpawn;
private PacketPlayOutScoreboardTeam packetPlayOutScoreboardTeamRegister;
private PacketPlayOutPlayerInfo packetPlayOutPlayerInfoAdd, packetPlayOutPlayerInfoRemove;
@@ -41,8 +40,7 @@ public class NPC_v1_9_R2 extends NPCBase {
@Override
public void createPackets() {
this.hologram = new _Hologram(location.clone().subtract(0, 0.5, 0), text);
hologram.generatePackets(MinecraftVersion.V1_9_R2);
this.hologram = new Hologram(MinecraftVersion.V1_9_R2, location.clone().subtract(0, 0.5, 0), text);
PacketPlayOutPlayerInfoWrapper packetPlayOutPlayerInfoWrapper = new PacketPlayOutPlayerInfoWrapper();
@@ -82,8 +80,7 @@ public class NPC_v1_9_R2 extends NPCBase {
playerConnection.sendPacket(packetPlayOutNamedEntitySpawn);
playerConnection.sendPacket(packetPlayOutEntityHeadRotation);
hologram.spawn(player);
hologram.show(player);
Bukkit.getScheduler().runTaskLater(instance.getPlugin(), () ->
playerConnection.sendPacket(packetPlayOutPlayerInfoRemove), 50);
@@ -95,7 +92,8 @@ public class NPC_v1_9_R2 extends NPCBase {
playerConnection.sendPacket(packetPlayOutEntityDestroy);
playerConnection.sendPacket(packetPlayOutPlayerInfoRemove);
hologram.destroy(player);
hologram.hide(player);
}
@Override