From 2dadc7e3602e885bb2efe14fb79ee904cf824386 Mon Sep 17 00:00:00 2001 From: ayunami2000 Date: Fri, 29 Apr 2022 01:39:28 -0400 Subject: [PATCH 1/2] Fix horrible bug --- .../features/hologram/HologramHandler.java | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/src/protocolsupportlegacysupport/features/hologram/HologramHandler.java b/src/protocolsupportlegacysupport/features/hologram/HologramHandler.java index 1758a27..1c318af 100755 --- a/src/protocolsupportlegacysupport/features/hologram/HologramHandler.java +++ b/src/protocolsupportlegacysupport/features/hologram/HologramHandler.java @@ -2,7 +2,6 @@ import java.util.ArrayList; import java.util.Collections; -import java.util.Iterator; import java.util.List; import org.bukkit.Bukkit; @@ -86,21 +85,13 @@ private void initConnection(Connection connection) { return initArmorStand(getTracker(connection), packet.getIntegers().read(0), packet.getDoubles()); }); registerHandler(PacketType.Play.Server.ENTITY_DESTROY, (connection, packet) -> { - List entityIds = new ArrayList<>(packet.getIntLists().read(0)); + int entityId = packet.getIntegers().read(0); ArmorStandTracker tracker = getTracker(connection); - List packets = new ArrayList<>(); - Iterator entityIdsIter = entityIds.iterator(); - while (entityIdsIter.hasNext()) { - Integer entityId = entityIdsIter.next(); - if (tracker.has(entityId)) { - tracker.destroy(packets, entityId); - } else { - entityIdsIter.remove(); - } - } - if (!entityIds.isEmpty()) { - packets.add(PacketUtils.createEntityDestroyPacket(entityIds)); + if (!tracker.has(entityId)) { + return null; } + List packets = new ArrayList<>(); + getTracker(connection).destroy(packets, entityId); return packets; }); registerHandler(PacketType.Play.Server.ENTITY_METADATA, (connection, packet) -> { From 754b14ce6e782140e04ecf2a049b841642b94acd Mon Sep 17 00:00:00 2001 From: ayunami2000 Date: Fri, 29 Apr 2022 02:10:01 -0400 Subject: [PATCH 2/2] lmao i actually broke it on my first try, this is the actual verified fix :tm: --- .../features/hologram/HologramHandler.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/protocolsupportlegacysupport/features/hologram/HologramHandler.java b/src/protocolsupportlegacysupport/features/hologram/HologramHandler.java index 1c318af..bfca86f 100755 --- a/src/protocolsupportlegacysupport/features/hologram/HologramHandler.java +++ b/src/protocolsupportlegacysupport/features/hologram/HologramHandler.java @@ -2,6 +2,7 @@ import java.util.ArrayList; import java.util.Collections; +import java.util.Iterator; import java.util.List; import org.bukkit.Bukkit; @@ -85,13 +86,19 @@ private void initConnection(Connection connection) { return initArmorStand(getTracker(connection), packet.getIntegers().read(0), packet.getDoubles()); }); registerHandler(PacketType.Play.Server.ENTITY_DESTROY, (connection, packet) -> { - int entityId = packet.getIntegers().read(0); + List entityIds = new ArrayList<>(packet.getIntLists().read(0)); ArmorStandTracker tracker = getTracker(connection); - if (!tracker.has(entityId)) { - return null; - } List packets = new ArrayList<>(); - getTracker(connection).destroy(packets, entityId); + Iterator entityIdsIter = entityIds.iterator(); + while (entityIdsIter.hasNext()) { + Integer entityId = entityIdsIter.next(); + if (tracker.has(entityId)) { + tracker.destroy(packets, entityId); + } + } + if (!entityIds.isEmpty()) { + packets.add(PacketUtils.createEntityDestroyPacket(entityIds)); + } return packets; }); registerHandler(PacketType.Play.Server.ENTITY_METADATA, (connection, packet) -> {