From 17fcefcbca67fb29f21d4c24829661ef29f6754d Mon Sep 17 00:00:00 2001 From: Bjorn <75190918+BjornTheProgrammer@users.noreply.github.com> Date: Sun, 22 Sep 2024 02:16:23 -0700 Subject: [PATCH] Fix #3234 --- .../protocol/injector/collection/PacketListenerSet.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/comphenix/protocol/injector/collection/PacketListenerSet.java b/src/main/java/com/comphenix/protocol/injector/collection/PacketListenerSet.java index fbde95212..2acc9b655 100644 --- a/src/main/java/com/comphenix/protocol/injector/collection/PacketListenerSet.java +++ b/src/main/java/com/comphenix/protocol/injector/collection/PacketListenerSet.java @@ -1,5 +1,6 @@ package com.comphenix.protocol.injector.collection; +import java.util.Iterator; import java.util.Set; import javax.annotation.Nullable; @@ -45,7 +46,9 @@ public PacketListenerSet(PacketTypeListenerSet mainThreadPacketTypes, ErrorRepor public void addListener(PacketListener packetListener) { ListeningWhitelist listeningWhitelist = getListeningWhitelist(packetListener); - for (PacketType packetType : listeningWhitelist.getTypes()) { + for (Iterator packet = listeningWhitelist.getTypes().iterator(); packet.hasNext();) { + PacketType packetType = packet.next(); + Set supportedPacketTypes = (packetType.getSender() == Sender.SERVER) ? PacketRegistry.getServerPacketTypes() : PacketRegistry.getClientPacketTypes(); @@ -56,7 +59,7 @@ public void addListener(PacketListener packetListener) { .build()); // remove unknown packet types - listeningWhitelist.getTypes().remove(packetType); + packet.remove(); } }