Archiviert
1
0

Test tablist with remove

Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Lixfel 2022-10-02 22:56:50 +02:00
Ursprung ed9aa9082d
Commit 404462044a

Datei anzeigen

@ -110,6 +110,7 @@ public class Tablist extends MessageToMessageDecoder<PacketWrapper> {
// Main list handling
int i = 0;
List<PlayerListItem.Item> add = new ArrayList<>();
List<PlayerListItem.Item> 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<PacketWrapper> {
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<PlayerListItem.Item> 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() {