From e47fc9765d56c0ae02ace7c8e4baeb1d88da42f9 Mon Sep 17 00:00:00 2001 From: Eric Date: Wed, 1 May 2019 12:28:17 +0200 Subject: [PATCH] UUID of hologram and shop item should be unique --- .../java/de/epiceric/shopchest/nms/ArmorStandWrapper.java | 5 +++-- src/main/java/de/epiceric/shopchest/shop/ShopItem.java | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/de/epiceric/shopchest/nms/ArmorStandWrapper.java b/src/main/java/de/epiceric/shopchest/nms/ArmorStandWrapper.java index d1b0dfb..fba1059 100644 --- a/src/main/java/de/epiceric/shopchest/nms/ArmorStandWrapper.java +++ b/src/main/java/de/epiceric/shopchest/nms/ArmorStandWrapper.java @@ -16,11 +16,12 @@ public class ArmorStandWrapper { private final Class packetPlayOutEntityTeleportClass = Utils.getNMSClass("PacketPlayOutEntityTeleport"); private final Class dataWatcherClass = Utils.getNMSClass("DataWatcher"); + private final UUID uuid = UUID.randomUUID(); + private ShopChest plugin; private Object entity; private Location location; private String customName; - private UUID uuid; private int entityId = -1; public ArmorStandWrapper(ShopChest plugin, Location location, String customName, boolean interactable) { @@ -34,7 +35,7 @@ public class ArmorStandWrapper { if (visible) { Object dataWatcher = Utils.createDataWatcher(customName, null); entityId = Utils.getFreeEntityId(); - Utils.sendPacket(plugin, Utils.createPacketSpawnEntity(plugin, entityId, UUID.randomUUID(), location, EntityType.ARMOR_STAND), player); + Utils.sendPacket(plugin, Utils.createPacketSpawnEntity(plugin, entityId, uuid, location, EntityType.ARMOR_STAND), player); Utils.sendPacket(plugin, packetPlayOutEntityMetadataClass.getConstructor(int.class, dataWatcherClass, boolean.class) .newInstance(entityId, dataWatcher, true), player); } else if (entityId != -1) { diff --git a/src/main/java/de/epiceric/shopchest/shop/ShopItem.java b/src/main/java/de/epiceric/shopchest/shop/ShopItem.java index 1358cf4..fddbf1a 100644 --- a/src/main/java/de/epiceric/shopchest/shop/ShopItem.java +++ b/src/main/java/de/epiceric/shopchest/shop/ShopItem.java @@ -21,6 +21,7 @@ public class ShopItem { private final Set viewers = Collections.newSetFromMap(new ConcurrentHashMap()); private final ItemStack itemStack; private final Location location; + private final UUID uuid = UUID.randomUUID(); private int entityId = -1; @@ -91,7 +92,7 @@ public class ShopItem { Object nmsItemStack = craftItemStackClass.getMethod("asNMSCopy", ItemStack.class).invoke(null, itemStack); Object dataWatcher = Utils.createDataWatcher(null, nmsItemStack); entityId = Utils.getFreeEntityId(); - Utils.sendPacket(plugin, Utils.createPacketSpawnEntity(plugin, entityId, UUID.randomUUID(), location, EntityType.DROPPED_ITEM), p); + Utils.sendPacket(plugin, Utils.createPacketSpawnEntity(plugin, entityId, uuid, location, EntityType.DROPPED_ITEM), p); Utils.sendPacket(plugin, packetPlayOutEntityMetadataClass.getConstructor(int.class, dataWatcherClass, boolean.class).newInstance(entityId, dataWatcher, true), p); if (Utils.getMajorVersion() < 14) { Utils.sendPacket(plugin, packetPlayOutEntityVelocityClass.getConstructor(int.class, double.class, double.class, double.class).newInstance(entityId, 0D, 0D, 0D), p);