From 404462044a381a06b9aecf89a91e802fb01e1734 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sun, 2 Oct 2022 22:56:50 +0200 Subject: [PATCH] Test tablist with remove Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/tablist/Tablist.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/de/steamwar/bungeecore/tablist/Tablist.java b/src/de/steamwar/bungeecore/tablist/Tablist.java index ad400cb..338a38d 100644 --- a/src/de/steamwar/bungeecore/tablist/Tablist.java +++ b/src/de/steamwar/bungeecore/tablist/Tablist.java @@ -110,6 +110,7 @@ public class Tablist extends MessageToMessageDecoder { // Main list handling int i = 0; List add = new ArrayList<>(); + List remove = new ArrayList<>(); for (; i < tablist.size() && i < 80; i++) { PlayerListItem.Item tabItem; if(current.size() > i) { @@ -128,20 +129,23 @@ public class Tablist extends MessageToMessageDecoder { tabItem.setProperties(item.getProperties()); tabItem.setDisplayName(item.getDisplayName()); add.add(tabItem); + if(current.size() > i) { + remove.add(tabItem); + } } else if(!item.getDisplayName().equals(tabItem.getDisplayName())) { tabItem.setDisplayName(item.getDisplayName()); update.add(tabItem); } } - sendTabPacket(update, PlayerListItem.Action.UPDATE_DISPLAY_NAME); - sendTabPacket(add, PlayerListItem.Action.ADD_PLAYER); // Excess removal - List remove = new ArrayList<>(); while(i < current.size()) { remove.add(current.remove(i)); } + sendTabPacket(remove, PlayerListItem.Action.REMOVE_PLAYER); + sendTabPacket(update, PlayerListItem.Action.UPDATE_DISPLAY_NAME); + sendTabPacket(add, PlayerListItem.Action.ADD_PLAYER); } public void onServerSwitch() {