From 0af0d6c5f9da52e0366ab4c85748c4c3999a794a Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sat, 11 Mar 2023 17:12:45 +0100 Subject: [PATCH] Fix rare TinyProtocol issues --- .../src/com/comphenix/tinyprotocol/TinyProtocol.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/SpigotCore_Main/src/com/comphenix/tinyprotocol/TinyProtocol.java b/SpigotCore_Main/src/com/comphenix/tinyprotocol/TinyProtocol.java index b1bbb00..7957a0f 100644 --- a/SpigotCore_Main/src/com/comphenix/tinyprotocol/TinyProtocol.java +++ b/SpigotCore_Main/src/com/comphenix/tinyprotocol/TinyProtocol.java @@ -80,7 +80,7 @@ public class TinyProtocol implements Listener { } public void addFilter(Class packetType, BiFunction filter) { - packetFilters.computeIfAbsent(packetType, c -> new ArrayList<>(1)).add(filter); + packetFilters.computeIfAbsent(packetType, c -> Collections.synchronizedList(new ArrayList<>(1))).add(filter); } public void removeFilter(Class packetType, BiFunction filter) { @@ -128,6 +128,9 @@ public class TinyProtocol implements Listener { return new SecurityException("Could not find channel for player " + player.getName()); })); + if(!channel.isActive()) + return; + synchronized (playerInterceptors) { playerInterceptors.put(player, this); } -- 2.39.2