13
0
geforkt von Mirrors/Velocity

Merge pull request #288 from Gabik21/fix-1.7-weirdness

Fix tablist behaving wrong with colors (1.7) (Fixes #282)
Dieser Commit ist enthalten in:
Andrew Steinborn 2020-04-07 11:51:21 -04:00 committet von GitHub
Commit 4374f1e4d6
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23

Datei anzeigen

@ -60,29 +60,25 @@ public class VelocityTabListLegacy extends VelocityTabList {
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
Component displayName = LegacyComponentSerializer.legacy().deserialize(item.getName());
String strippedName = PlainComponentSerializer.INSTANCE.serialize(displayName);
switch (packet.getAction()) { switch (packet.getAction()) {
case PlayerListItem.ADD_PLAYER: case PlayerListItem.ADD_PLAYER:
if (nameMapping.containsKey(strippedName)) { // ADD_PLAYER also used for updating ping if (nameMapping.containsKey(item.getName())) { // ADD_PLAYER also used for updating ping
VelocityTabListEntry entry = entries.get(nameMapping.get(strippedName)); VelocityTabListEntry entry = entries.get(nameMapping.get(item.getName()));
if (entry != null) { if (entry != null) {
entry.setLatency(item.getLatency()); entry.setLatency(item.getLatency());
} }
} else { } else {
UUID uuid = UUID.randomUUID(); // Use a fake uuid to preserve function of custom entries UUID uuid = UUID.randomUUID(); // Use a fake uuid to preserve function of custom entries
nameMapping.put(strippedName, uuid); nameMapping.put(item.getName(), uuid);
entries.put(uuid, (VelocityTabListEntry) TabListEntry.builder() entries.put(uuid, (VelocityTabListEntry) TabListEntry.builder()
.tabList(this) .tabList(this)
.profile(new GameProfile(uuid, strippedName, ImmutableList.of())) .profile(new GameProfile(uuid, item.getName(), ImmutableList.of()))
.displayName(displayName)
.latency(item.getLatency()) .latency(item.getLatency())
.build()); .build());
} }
break; break;
case PlayerListItem.REMOVE_PLAYER: case PlayerListItem.REMOVE_PLAYER:
UUID removedUuid = nameMapping.remove(strippedName); UUID removedUuid = nameMapping.remove(item.getName());
if (removedUuid != null) { if (removedUuid != null) {
entries.remove(removedUuid); entries.remove(removedUuid);
} }