13
0
geforkt von Mirrors/Velocity

Don't force-add a tab list entry if it already exists

Dieser Commit ist enthalten in:
Andrew Steinborn 2021-07-09 10:11:15 -04:00
Ursprung 0e0a14498f
Commit ea577019b8
3 geänderte Dateien mit 8 neuen und 7 gelöschten Zeilen

Datei anzeigen

@ -211,8 +211,7 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler {
@Override @Override
public boolean handle(PlayerListItem packet) { public boolean handle(PlayerListItem packet) {
serverConn.getPlayer().getTabList().processBackendPacket(packet); return !serverConn.getPlayer().getTabList().processBackendPacket(packet);
return false; //Forward packet to player
} }
@Override @Override

Datei anzeigen

@ -129,8 +129,9 @@ public class VelocityTabList implements TabList {
* Processes a tab list entry packet from the backend. * Processes a tab list entry packet from the backend.
* *
* @param packet the packet to process * @param packet the packet to process
* @return {@code true} to forward the packet on, {@code false} otherwise
*/ */
public void processBackendPacket(PlayerListItem packet) { public boolean processBackendPacket(PlayerListItem packet) {
// Packets are already forwarded on, so no need to do that here // Packets are already forwarded on, so no need to do that here
for (PlayerListItem.Item item : packet.getItems()) { for (PlayerListItem.Item item : packet.getItems()) {
UUID uuid = item.getUuid(); UUID uuid = item.getUuid();
@ -149,14 +150,13 @@ public class VelocityTabList implements TabList {
if (name == null || properties == null) { if (name == null || properties == null) {
throw new IllegalStateException("Got null game profile for ADD_PLAYER"); throw new IllegalStateException("Got null game profile for ADD_PLAYER");
} }
entries.put(item.getUuid(), (VelocityTabListEntry) TabListEntry.builder() return entries.putIfAbsent(item.getUuid(), (VelocityTabListEntry) TabListEntry.builder()
.tabList(this) .tabList(this)
.profile(new GameProfile(uuid, name, properties)) .profile(new GameProfile(uuid, name, properties))
.displayName(item.getDisplayName()) .displayName(item.getDisplayName())
.latency(item.getLatency()) .latency(item.getLatency())
.gameMode(item.getGameMode()) .gameMode(item.getGameMode())
.build()); .build()) == null;
break;
} }
case PlayerListItem.REMOVE_PLAYER: case PlayerListItem.REMOVE_PLAYER:
entries.remove(uuid); entries.remove(uuid);
@ -187,6 +187,7 @@ public class VelocityTabList implements TabList {
break; break;
} }
} }
return true;
} }
void updateEntry(int action, TabListEntry entry) { void updateEntry(int action, TabListEntry entry) {

Datei anzeigen

@ -72,7 +72,7 @@ public class VelocityTabListLegacy extends VelocityTabList {
} }
@Override @Override
public void processBackendPacket(PlayerListItem packet) { public boolean processBackendPacket(PlayerListItem packet) {
Item item = packet.getItems().get(0); // Only one item per packet in 1.7 Item item = packet.getItems().get(0); // Only one item per packet in 1.7
switch (packet.getAction()) { switch (packet.getAction()) {
@ -103,6 +103,7 @@ public class VelocityTabListLegacy extends VelocityTabList {
break; break;
} }
return true;
} }
@Override @Override