From 6d4cb3b18f559d1bdb4afd818daab575752460f9 Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Tue, 17 Aug 2021 13:30:10 -0400 Subject: [PATCH] Fix TabList population Bug reported by JakubBien on Discord --- .../connection/backend/BackendPlaySessionHandler.java | 3 ++- .../velocitypowered/proxy/tablist/VelocityTabList.java | 8 +++----- .../proxy/tablist/VelocityTabListLegacy.java | 4 +--- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BackendPlaySessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BackendPlaySessionHandler.java index 240c655f0..39cc3738a 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BackendPlaySessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BackendPlaySessionHandler.java @@ -211,7 +211,8 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler { @Override public boolean handle(PlayerListItem packet) { - return !serverConn.getPlayer().getTabList().processBackendPacket(packet); + serverConn.getPlayer().getTabList().processBackendPacket(packet); + return false; } @Override 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 fabd00f5a..68015be65 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/tablist/VelocityTabList.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/tablist/VelocityTabList.java @@ -129,9 +129,8 @@ public class VelocityTabList implements TabList { * Processes a tab list entry packet from the backend. * * @param packet the packet to process - * @return {@code true} to forward the packet on, {@code false} otherwise */ - public boolean processBackendPacket(PlayerListItem packet) { + public void processBackendPacket(PlayerListItem packet) { // Packets are already forwarded on, so no need to do that here for (PlayerListItem.Item item : packet.getItems()) { UUID uuid = item.getUuid(); @@ -150,13 +149,13 @@ public class VelocityTabList implements TabList { if (name == null || properties == null) { throw new IllegalStateException("Got null game profile for ADD_PLAYER"); } - return entries.putIfAbsent(item.getUuid(), (VelocityTabListEntry) TabListEntry.builder() + entries.putIfAbsent(item.getUuid(), (VelocityTabListEntry) TabListEntry.builder() .tabList(this) .profile(new GameProfile(uuid, name, properties)) .displayName(item.getDisplayName()) .latency(item.getLatency()) .gameMode(item.getGameMode()) - .build()) == null; + .build()); } case PlayerListItem.REMOVE_PLAYER: entries.remove(uuid); @@ -187,7 +186,6 @@ public class VelocityTabList implements TabList { break; } } - return true; } void updateEntry(int action, TabListEntry entry) { diff --git a/proxy/src/main/java/com/velocitypowered/proxy/tablist/VelocityTabListLegacy.java b/proxy/src/main/java/com/velocitypowered/proxy/tablist/VelocityTabListLegacy.java index 485874682..95bfe6df1 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/tablist/VelocityTabListLegacy.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/tablist/VelocityTabListLegacy.java @@ -72,7 +72,7 @@ public class VelocityTabListLegacy extends VelocityTabList { } @Override - public boolean processBackendPacket(PlayerListItem packet) { + public void processBackendPacket(PlayerListItem packet) { Item item = packet.getItems().get(0); // Only one item per packet in 1.7 switch (packet.getAction()) { @@ -102,8 +102,6 @@ public class VelocityTabListLegacy extends VelocityTabList { // For 1.7 there is only add and remove break; } - - return true; } @Override