Fix name not updated when setting name visible or deadmau, and hopefully fix empty names showing

This commit is contained in:
libraryaddict 2021-02-01 20:49:27 +13:00
parent ba9eba508b
commit 249b02aa85

View File

@ -143,8 +143,12 @@ public class PlayerDisguise extends TargetedDisguise {
return DisguiseConfig.isScoreboardNames(); return DisguiseConfig.isScoreboardNames();
} }
/**
* 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() : DisguiseConfig.isScoreboardNames() && getName().isEmpty() ? "LD_NoName" : getName();
} }
public UUID getUUID() { public UUID getUUID() {
@ -210,6 +214,10 @@ public class PlayerDisguise extends TargetedDisguise {
getWatcher().setInternalUpsideDown(upsideDown); getWatcher().setInternalUpsideDown(upsideDown);
if (gameProfile != null) {
gameProfile = ReflectionManager.getGameProfileWithThisSkin(uuid, getProfileName(), getGameProfile());
}
if (isDisguiseInUse()) { if (isDisguiseInUse()) {
resendDisguise(DisguiseConfig.isArmorstandsName() ? getName() : "Dinnerbone", true); resendDisguise(DisguiseConfig.isArmorstandsName() ? getName() : "Dinnerbone", true);
} else { } else {
@ -226,6 +234,10 @@ public class PlayerDisguise extends TargetedDisguise {
this.deadmau5Ears = deadmau5Ears; this.deadmau5Ears = deadmau5Ears;
if (gameProfile != null) {
gameProfile = ReflectionManager.getGameProfileWithThisSkin(uuid, getProfileName(), getGameProfile());
}
if (isDisguiseInUse()) { if (isDisguiseInUse()) {
resendDisguise(DisguiseConfig.isArmorstandsName() ? getName() : "deadmau5", true); resendDisguise(DisguiseConfig.isArmorstandsName() ? getName() : "deadmau5", true);
} else { } else {
@ -468,8 +480,7 @@ public class PlayerDisguise extends TargetedDisguise {
} }
}; };
WrappedGameProfile gameProfile = DisguiseUtilities WrappedGameProfile gameProfile = DisguiseUtilities.getProfileFromMojang(this.skinToUse, currentLookup, DisguiseConfig.isContactMojangServers());
.getProfileFromMojang(this.skinToUse, currentLookup, DisguiseConfig.isContactMojangServers());
if (gameProfile != null) { if (gameProfile != null) {
setSkin(gameProfile); setSkin(gameProfile);
@ -516,7 +527,10 @@ public class PlayerDisguise extends TargetedDisguise {
} }
private void refreshDisguise() { private void refreshDisguise() {
if (DisguiseUtilities.isDisguiseInUse(this)) { if (!DisguiseUtilities.isDisguiseInUse(this)) {
return;
}
if (isDisplayedInTab()) { if (isDisplayedInTab()) {
PacketContainer addTab = DisguiseUtilities.getTabPacket(this, PlayerInfoAction.ADD_PLAYER); PacketContainer addTab = DisguiseUtilities.getTabPacket(this, PlayerInfoAction.ADD_PLAYER);
@ -539,7 +553,6 @@ public class PlayerDisguise extends TargetedDisguise {
DisguiseUtilities.refreshTrackers(this); DisguiseUtilities.refreshTrackers(this);
} }
}
@Override @Override
public PlayerWatcher getWatcher() { public PlayerWatcher getWatcher() {
@ -634,8 +647,7 @@ public class PlayerDisguise extends TargetedDisguise {
} }
}; };
WrappedGameProfile gameProfile = DisguiseUtilities WrappedGameProfile gameProfile = DisguiseUtilities.getProfileFromMojang(this.skinToUse, currentLookup, DisguiseConfig.isContactMojangServers());
.getProfileFromMojang(this.skinToUse, currentLookup, DisguiseConfig.isContactMojangServers());
if (gameProfile != null) { if (gameProfile != null) {
setSkin(gameProfile); setSkin(gameProfile);