Merge pull request 'Fix TinyProtocol spurious ConcurrentModificationExceptions' (#24) from SpigotCore/TInyProtocolConcurrentModEx into main

Reviewed-on: https://steamwar.de/devlabs/SteamWar/SteamWar/pulls/24
Reviewed-by: YoyoNow <jwsteam@nidido.de>
This commit is contained in:
Lixfel
2024-11-10 17:29:21 +01:00
@@ -36,6 +36,7 @@ import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.plugin.Plugin;
import java.util.*;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.function.BiFunction;
import java.util.logging.Level;
@@ -102,7 +103,7 @@ public class TinyProtocol implements Listener {
}
public void addFilter(Class<?> packetType, BiFunction<Player, Object, Object> filter) {
packetFilters.computeIfAbsent(packetType, c -> Collections.synchronizedList(new ArrayList<>(1))).add(filter);
packetFilters.computeIfAbsent(packetType, c -> new CopyOnWriteArrayList<>()).add(filter);
}
public void removeFilter(Class<?> packetType, BiFunction<Player, Object, Object> filter) {