From 64567c155609f07957e5612012bb57084ae2fdc9 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sat, 18 Jun 2022 14:32:25 +0200 Subject: [PATCH] Fix softreload issues Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/tablist/Tablist.java | 7 +++++-- src/de/steamwar/bungeecore/tablist/TablistManager.java | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/de/steamwar/bungeecore/tablist/Tablist.java b/src/de/steamwar/bungeecore/tablist/Tablist.java index a382c8d..53c2bbe 100644 --- a/src/de/steamwar/bungeecore/tablist/Tablist.java +++ b/src/de/steamwar/bungeecore/tablist/Tablist.java @@ -47,7 +47,7 @@ public class Tablist extends MessageToMessageDecoder { private static final UUID[] uuids = IntStream.range(0, 80).mapToObj(i -> UUID.randomUUID()).toArray(UUID[]::new); private static final String[] names = IntStream.range(0, 80).mapToObj(i -> " »SW« " + i).toArray(String[]::new); private static final String TAB_TEAM = "»SW-Tab"; - private static final Team teamPacket = new Team(TAB_TEAM, (byte) 0, ComponentSerializer.toString(TextComponent.fromLegacyText("")), ComponentSerializer.toString(TextComponent.fromLegacyText("")), ComponentSerializer.toString(TextComponent.fromLegacyText("")), "never", "never", 21, (byte)0x00, names); + private static final Team teamPacket = new Team(TAB_TEAM, (byte) 0, ComponentSerializer.toString(TextComponent.fromLegacyText("")), ComponentSerializer.toString(TextComponent.fromLegacyText("")), ComponentSerializer.toString(TextComponent.fromLegacyText("")), "always", "always", 21, (byte)0x00, names); private final Map directTabItems; private final Set npcs = new HashSet<>(); @@ -150,11 +150,14 @@ public class Tablist extends MessageToMessageDecoder { } } - public void remove() { + public void disable() { sendTabPacket(current, PlayerListItem.Action.REMOVE_PLAYER); current.clear(); sendNpcPacket(npcs.stream().map(npc -> directTabItems.get(npc).getUsername()).collect(Collectors.toList()), true); npcs.clear(); + + if(connection != null) + connection.getCh().getHandle().pipeline().remove(this); } @Override diff --git a/src/de/steamwar/bungeecore/tablist/TablistManager.java b/src/de/steamwar/bungeecore/tablist/TablistManager.java index ef1c627..0f02f55 100644 --- a/src/de/steamwar/bungeecore/tablist/TablistManager.java +++ b/src/de/steamwar/bungeecore/tablist/TablistManager.java @@ -78,7 +78,7 @@ public class TablistManager extends BasicListener { public void disable() { synchronized (tablists) { - tablists.forEach((player, tablist) -> tablist.remove()); + tablists.forEach((player, tablist) -> tablist.disable()); tablists.clear(); } }