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