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
public boolean handle(PlayerListItem packet) {
serverConn.getPlayer().getTabList().processBackendPacket(packet);
return false; //Forward packet to player
return !serverConn.getPlayer().getTabList().processBackendPacket(packet);
}
@Override

Datei anzeigen

@ -129,8 +129,9 @@ 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 void processBackendPacket(PlayerListItem packet) {
public boolean 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();
@ -149,14 +150,13 @@ public class VelocityTabList implements TabList {
if (name == null || properties == null) {
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)
.profile(new GameProfile(uuid, name, properties))
.displayName(item.getDisplayName())
.latency(item.getLatency())
.gameMode(item.getGameMode())
.build());
break;
.build()) == null;
}
case PlayerListItem.REMOVE_PLAYER:
entries.remove(uuid);
@ -187,6 +187,7 @@ public class VelocityTabList implements TabList {
break;
}
}
return true;
}
void updateEntry(int action, TabListEntry entry) {

Datei anzeigen

@ -72,7 +72,7 @@ public class VelocityTabListLegacy extends VelocityTabList {
}
@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
switch (packet.getAction()) {
@ -103,6 +103,7 @@ public class VelocityTabListLegacy extends VelocityTabList {
break;
}
return true;
}
@Override