From c2338fe3d08ae3ec1a0bb0bebe828ddbc3bba1b0 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sat, 18 Jun 2022 18:55:34 +0200 Subject: [PATCH] Fix npcs #2 Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/tablist/Tablist.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/de/steamwar/bungeecore/tablist/Tablist.java b/src/de/steamwar/bungeecore/tablist/Tablist.java index 958952c..be8d920 100644 --- a/src/de/steamwar/bungeecore/tablist/Tablist.java +++ b/src/de/steamwar/bungeecore/tablist/Tablist.java @@ -148,8 +148,8 @@ public class Tablist extends MessageToMessageDecoder { synchronized (directTabItems) { directTabItems.clear(); sendNpcPacket(npcs.stream().map(npc -> directTabItems.get(npc).getUsername()).collect(Collectors.toList()), true); + npcs.clear(); } - npcs.clear(); if(connection != null) { connection.getCh().getHandle().pipeline().addBefore(PipelineUtils.BOSS_HANDLER, "steamwar-tablist", this); @@ -162,8 +162,8 @@ public class Tablist extends MessageToMessageDecoder { current.clear(); synchronized (directTabItems) { sendNpcPacket(npcs.stream().map(npc -> directTabItems.get(npc).getUsername()).collect(Collectors.toList()), true); + npcs.clear(); } - npcs.clear(); if(connection != null) connection.getCh().getHandle().pipeline().remove(this); @@ -209,12 +209,15 @@ public class Tablist extends MessageToMessageDecoder { } break; case REMOVE_PLAYER: + List names = new ArrayList<>(); for(PlayerListItem.Item item : list.getItems()) { synchronized (directTabItems) { - directTabItems.remove(item.getUuid()); + PlayerListItem.Item directItem = directTabItems.remove(item.getUuid()); + if(npcs.remove(item.getUuid())) + names.add(directItem.getUsername()); } - npcs.remove(item.getUuid()); } + sendNpcPacket(names, true); break; } }