diff --git a/proxy/src/main/java/com/velocitypowered/proxy/tablist/VelocityTabList.java b/proxy/src/main/java/com/velocitypowered/proxy/tablist/VelocityTabList.java index 58103eb07..c60ebe6fa 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/tablist/VelocityTabList.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/tablist/VelocityTabList.java @@ -89,14 +89,16 @@ public class VelocityTabList implements TabList { * MinecraftConnection#flush()}. */ public void clearAll() { - List items = new ArrayList<>(); - for (TabListEntry value : entries.values()) { + Collection listEntries = entries.values(); + if (listEntries.isEmpty()) { + return; + } + List items = new ArrayList<>(listEntries.size()); + for (TabListEntry value : listEntries) { items.add(PlayerListItem.Item.from(value)); } entries.clear(); - if (!items.isEmpty()) { - connection.delayedWrite(new PlayerListItem(PlayerListItem.REMOVE_PLAYER, items)); - } + connection.delayedWrite(new PlayerListItem(PlayerListItem.REMOVE_PLAYER, items)); } @Override