Skip to content

Commit

Permalink
Fix long player name issues (#1480)
Browse files Browse the repository at this point in the history
Signed-off-by: Pablo Herrera <[email protected]>
  • Loading branch information
Pablete1234 authored Jan 13, 2025
1 parent d6b4255 commit a84e89f
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
import org.jetbrains.annotations.Nullable;
import tc.oc.pgm.util.StringUtils;
import tc.oc.pgm.util.nms.EnumPlayerInfoAction;

public interface EntityPackets {
Expand Down Expand Up @@ -57,8 +58,9 @@ default Packet spawnFreezeEntity(Player player, int entityId, boolean legacy) {
default FakeEntity fakePlayer(Player original, ChatColor color) {
UUID uuid = UUID.randomUUID();
String team = uuid.toString().substring(0, 16);
// Add a reset to differentiate it from the real player name
String playerName = color + original.getName();
// Add color to void matching real name. Cut to avoid exceeding 16 chars
String playerName = color + StringUtils.substring(original.getName(), 0, 14);
String suffix = StringUtils.substring(original.getName(), 14, 16);
return new FakeEntity.Impl(allocateEntityId()) {
@Override
public Packet spawn(Location location, Vector velocity) {
Expand All @@ -69,7 +71,7 @@ public Packet spawn(Location location, Vector velocity) {
tabInfo,
TAB_PACKETS.spawnPlayerPacket(entityId(), uuid, location, original),
TAB_PACKETS.teamCreatePacket(
team, team, color + "", "", false, false, List.of(playerName)));
team, team, color + "", suffix, false, false, List.of(playerName)));
}

@Override
Expand Down

0 comments on commit a84e89f

Please sign in to comment.