Change nametag visibility to use &r and fix an issue where the tablist packet was wrong

This commit is contained in:
libraryaddict 2021-02-11 17:56:20 +13:00
parent ef4539a3a1
commit 1790032f75
5 changed files with 14 additions and 15 deletions

View File

@ -1167,9 +1167,9 @@ public abstract class Disguise {
}, 2);
if (isHidePlayer() && getEntity() instanceof Player) {
PacketContainer addTab = new PacketContainer(PacketType.Play.Server.PLAYER_INFO);
addTab.getPlayerInfoAction().write(0, PlayerInfoAction.REMOVE_PLAYER);
addTab.getPlayerInfoDataLists().write(0, Collections.singletonList(
PacketContainer removeTab = new PacketContainer(PacketType.Play.Server.PLAYER_INFO);
removeTab.getPlayerInfoAction().write(0, PlayerInfoAction.REMOVE_PLAYER);
removeTab.getPlayerInfoDataLists().write(0, Collections.singletonList(
new PlayerInfoData(ReflectionManager.getGameProfile((Player) getEntity()), 0, NativeGameMode.SURVIVAL, WrappedChatComponent.fromText(""))));
try {
@ -1178,7 +1178,7 @@ public abstract class Disguise {
continue;
}
ProtocolLibrary.getProtocolManager().sendServerPacket(player, addTab);
ProtocolLibrary.getProtocolManager().sendServerPacket(player, removeTab);
}
} catch (InvocationTargetException e) {
e.printStackTrace();

View File

@ -30,7 +30,7 @@ public class PlayerDisguise extends TargetedDisguise {
* Has someone set name visible explicitly?
*/
private boolean explicitNameVisible = false;
private final UUID uuid = UUID.randomUUID();
private final UUID uuid = ReflectionManager.getRandomUUID();
private transient DisguiseUtilities.DScoreTeam scoreboardName;
@Getter
private boolean deadmau5Ears;
@ -147,7 +147,8 @@ public class PlayerDisguise extends TargetedDisguise {
* The actual name that'll be sent in the game profile, not the name that they're known as
*/
public String getProfileName() {
return isUpsideDown() ? "Dinnerbone" : isDeadmau5Ears() ? "deadmau5" : hasScoreboardName() ? getScoreboardName().getPlayer() : getName();
return isUpsideDown() ? "Dinnerbone" :
isDeadmau5Ears() ? "deadmau5" : hasScoreboardName() ? getScoreboardName().getPlayer() : getName().isEmpty() ? "§r" : getName();
}
public UUID getUUID() {

View File

@ -1775,9 +1775,9 @@ public class DisguiseUtilities {
if (mainTeam == null) {
mainTeam = scoreboard.registerNewTeam("LD_NoName");
mainTeam.setOption(Option.NAME_TAG_VISIBILITY, OptionStatus.NEVER);
mainTeam.addEntry("");
} else if (!mainTeam.hasEntry("")) {
mainTeam.addEntry("");
mainTeam.addEntry("§r");
} else if (!mainTeam.hasEntry("§r")) {
mainTeam.addEntry("§r");
}
}

View File

@ -165,9 +165,6 @@ public class PacketHandlerSpawn implements IPacketHandler {
PlayerDisguise playerDisguise = (PlayerDisguise) disguise;
boolean visibleOrNewCompat = playerDisguise.isNameVisible() || DisguiseConfig.isScoreboardNames();
WrappedGameProfile spawnProfile = visibleOrNewCompat ? playerDisguise.getGameProfile() : ReflectionManager
.getGameProfileWithThisSkin(UUID.randomUUID(), playerDisguise.isNameVisible() ? playerDisguise.getName() : "", playerDisguise.getGameProfile());
int entityId = disguisedEntity.getEntityId();
PlayerSkinHandler.PlayerSkin skin;
@ -178,7 +175,8 @@ public class PacketHandlerSpawn implements IPacketHandler {
// Add player to the list, necessary to spawn them
sendTab.getModifier().write(0, ReflectionManager.getEnumPlayerInfoAction(0));
List playerList = Collections.singletonList(ReflectionManager.getPlayerInfoData(sendTab.getHandle(), spawnProfile));
List playerList = Collections.singletonList(ReflectionManager.getPlayerInfoData(sendTab.getHandle(), ReflectionManager
.getGameProfileWithThisSkin(playerDisguise.getUUID(), playerDisguise.getProfileName(), playerDisguise.getGameProfile())));
sendTab.getModifier().write(1, playerList);
packets.addPacket(sendTab);
@ -201,7 +199,7 @@ public class PacketHandlerSpawn implements IPacketHandler {
PacketContainer spawnPlayer = new PacketContainer(PacketType.Play.Server.NAMED_ENTITY_SPAWN);
spawnPlayer.getIntegers().write(0, entityId); // Id
spawnPlayer.getModifier().write(1, spawnProfile.getUUID());
spawnPlayer.getModifier().write(1, playerDisguise.getUUID());
double dist = observer.getLocation().distanceSquared(disguisedEntity.getLocation());

View File

@ -720,7 +720,7 @@ public class ReflectionManager {
/**
* Used for generating a UUID with a custom version instead of the default 4. Workaround for China's NetEase servers
*/
private static UUID getRandomUUID() {
public static UUID getRandomUUID() {
UUID uuid = UUID.randomUUID();
if (DisguiseConfig.getUUIDGeneratedVersion() == 4) {