Change nametag visibility to use &r and fix an issue where the tablist packet was wrong
This commit is contained in:
parent
ef4539a3a1
commit
1790032f75
@ -1167,9 +1167,9 @@ public abstract class Disguise {
|
|||||||
}, 2);
|
}, 2);
|
||||||
|
|
||||||
if (isHidePlayer() && getEntity() instanceof Player) {
|
if (isHidePlayer() && getEntity() instanceof Player) {
|
||||||
PacketContainer addTab = new PacketContainer(PacketType.Play.Server.PLAYER_INFO);
|
PacketContainer removeTab = new PacketContainer(PacketType.Play.Server.PLAYER_INFO);
|
||||||
addTab.getPlayerInfoAction().write(0, PlayerInfoAction.REMOVE_PLAYER);
|
removeTab.getPlayerInfoAction().write(0, PlayerInfoAction.REMOVE_PLAYER);
|
||||||
addTab.getPlayerInfoDataLists().write(0, Collections.singletonList(
|
removeTab.getPlayerInfoDataLists().write(0, Collections.singletonList(
|
||||||
new PlayerInfoData(ReflectionManager.getGameProfile((Player) getEntity()), 0, NativeGameMode.SURVIVAL, WrappedChatComponent.fromText(""))));
|
new PlayerInfoData(ReflectionManager.getGameProfile((Player) getEntity()), 0, NativeGameMode.SURVIVAL, WrappedChatComponent.fromText(""))));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -1178,7 +1178,7 @@ public abstract class Disguise {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, addTab);
|
ProtocolLibrary.getProtocolManager().sendServerPacket(player, removeTab);
|
||||||
}
|
}
|
||||||
} catch (InvocationTargetException e) {
|
} catch (InvocationTargetException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -30,7 +30,7 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||||||
* Has someone set name visible explicitly?
|
* Has someone set name visible explicitly?
|
||||||
*/
|
*/
|
||||||
private boolean explicitNameVisible = false;
|
private boolean explicitNameVisible = false;
|
||||||
private final UUID uuid = UUID.randomUUID();
|
private final UUID uuid = ReflectionManager.getRandomUUID();
|
||||||
private transient DisguiseUtilities.DScoreTeam scoreboardName;
|
private transient DisguiseUtilities.DScoreTeam scoreboardName;
|
||||||
@Getter
|
@Getter
|
||||||
private boolean deadmau5Ears;
|
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
|
* The actual name that'll be sent in the game profile, not the name that they're known as
|
||||||
*/
|
*/
|
||||||
public String getProfileName() {
|
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() {
|
public UUID getUUID() {
|
||||||
|
@ -1775,9 +1775,9 @@ public class DisguiseUtilities {
|
|||||||
if (mainTeam == null) {
|
if (mainTeam == null) {
|
||||||
mainTeam = scoreboard.registerNewTeam("LD_NoName");
|
mainTeam = scoreboard.registerNewTeam("LD_NoName");
|
||||||
mainTeam.setOption(Option.NAME_TAG_VISIBILITY, OptionStatus.NEVER);
|
mainTeam.setOption(Option.NAME_TAG_VISIBILITY, OptionStatus.NEVER);
|
||||||
mainTeam.addEntry("");
|
mainTeam.addEntry("§r");
|
||||||
} else if (!mainTeam.hasEntry("")) {
|
} else if (!mainTeam.hasEntry("§r")) {
|
||||||
mainTeam.addEntry("");
|
mainTeam.addEntry("§r");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,9 +165,6 @@ public class PacketHandlerSpawn implements IPacketHandler {
|
|||||||
PlayerDisguise playerDisguise = (PlayerDisguise) disguise;
|
PlayerDisguise playerDisguise = (PlayerDisguise) disguise;
|
||||||
boolean visibleOrNewCompat = playerDisguise.isNameVisible() || DisguiseConfig.isScoreboardNames();
|
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();
|
int entityId = disguisedEntity.getEntityId();
|
||||||
PlayerSkinHandler.PlayerSkin skin;
|
PlayerSkinHandler.PlayerSkin skin;
|
||||||
|
|
||||||
@ -178,7 +175,8 @@ public class PacketHandlerSpawn implements IPacketHandler {
|
|||||||
// Add player to the list, necessary to spawn them
|
// Add player to the list, necessary to spawn them
|
||||||
sendTab.getModifier().write(0, ReflectionManager.getEnumPlayerInfoAction(0));
|
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);
|
sendTab.getModifier().write(1, playerList);
|
||||||
|
|
||||||
packets.addPacket(sendTab);
|
packets.addPacket(sendTab);
|
||||||
@ -201,7 +199,7 @@ public class PacketHandlerSpawn implements IPacketHandler {
|
|||||||
PacketContainer spawnPlayer = new PacketContainer(PacketType.Play.Server.NAMED_ENTITY_SPAWN);
|
PacketContainer spawnPlayer = new PacketContainer(PacketType.Play.Server.NAMED_ENTITY_SPAWN);
|
||||||
|
|
||||||
spawnPlayer.getIntegers().write(0, entityId); // Id
|
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());
|
double dist = observer.getLocation().distanceSquared(disguisedEntity.getLocation());
|
||||||
|
|
||||||
|
@ -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
|
* 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();
|
UUID uuid = UUID.randomUUID();
|
||||||
|
|
||||||
if (DisguiseConfig.getUUIDGeneratedVersion() == 4) {
|
if (DisguiseConfig.getUUIDGeneratedVersion() == 4) {
|
||||||
|
Loading…
Reference in New Issue
Block a user