Skip to content

Commit f612adb

Browse files
Rewrite player & display name in player info packet in 1.12.2->1.13 (ViaVersion#4550)
Fixes Tablist plugins on some servers breaking since the game profile name sent is used to determine the scoreboard team which name we rewrite in other packets, also adds missing component rewriter calls to the display names (Not that important given its only translation keys, but we are already here). Co-authored-by: dewgs <[email protected]>
1 parent 6716bee commit f612adb

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/Protocol1_12_2To1_13.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import com.google.common.collect.Sets;
2121
import com.google.common.primitives.Ints;
22+
import com.google.gson.JsonElement;
2223
import com.google.gson.JsonObject;
2324
import com.google.gson.JsonParseException;
2425
import com.viaversion.viaversion.api.Via;
@@ -483,6 +484,31 @@ public void register() {
483484
displayName = rewriteTeamMemberName(displayName);
484485
wrapper.write(Types.STRING, displayName);
485486
});
487+
registerClientbound(ClientboundPackets1_12_1.PLAYER_INFO, wrapper -> {
488+
final int action = wrapper.passthrough(Types.VAR_INT);
489+
final int count = wrapper.passthrough(Types.VAR_INT);
490+
for (int i = 0; i < count; i++) {
491+
wrapper.passthrough(Types.UUID); // Player UUID
492+
if (action == 0) { // Add player
493+
final String playerName = wrapper.read(Types.STRING);
494+
wrapper.write(Types.STRING, rewriteTeamMemberName(playerName));
495+
wrapper.passthrough(Types.PROFILE_PROPERTY_ARRAY); // Profile properties
496+
wrapper.passthrough(Types.VAR_INT); // gamemode
497+
wrapper.passthrough(Types.VAR_INT); // ping
498+
final JsonElement displayName = wrapper.passthrough(Types.OPTIONAL_COMPONENT);
499+
if (displayName != null) {
500+
componentRewriter.processText(wrapper.user(), displayName);
501+
}
502+
} else if (action == 1 || action == 2) { // Update Gamemode/Latency
503+
wrapper.passthrough(Types.VAR_INT);
504+
} else if (action == 3) { // Update display name
505+
final JsonElement displayName = wrapper.passthrough(Types.OPTIONAL_COMPONENT);
506+
if (displayName != null) {
507+
componentRewriter.processText(wrapper.user(), displayName);
508+
}
509+
}
510+
}
511+
});
486512

487513
componentRewriter.registerTitle(ClientboundPackets1_12_1.SET_TITLES);
488514

0 commit comments

Comments
 (0)