Fix #638, and make setCustomNameVisible work for setNameVisible, I should really fix permissions for this.

This commit is contained in:
libraryaddict 2022-02-17 22:57:57 +13:00
parent 49fe9d51f0
commit 0ce85946a0
3 changed files with 15 additions and 3 deletions

View File

@ -868,6 +868,11 @@ public abstract class Disguise {
getWatcher().setBackupValue(flag, backup == null ? null : backup.getDefault()); getWatcher().setBackupValue(flag, backup == null ? null : backup.getDefault());
} }
if (getEntity() instanceof Player && !getWatcher().hasCustomName()) {
getWatcher().setInteralCustomName("");
getWatcher().setInternalCustomNameVisible(false);
}
// If a horse is disguised as a horse, it should obey parent no gravity rule // If a horse is disguised as a horse, it should obey parent no gravity rule
if ((getEntity() instanceof Boat || getEntity() instanceof AbstractHorse) && if ((getEntity() instanceof Boat || getEntity() instanceof AbstractHorse) &&
(getWatcher() instanceof BoatWatcher || getWatcher() instanceof AbstractHorseWatcher)) { (getWatcher() instanceof BoatWatcher || getWatcher() instanceof AbstractHorseWatcher)) {

View File

@ -707,10 +707,19 @@ public class FlagWatcher {
} }
public void setCustomNameVisible(boolean display) { public void setCustomNameVisible(boolean display) {
if (getDisguise().isPlayerDisguise()) {
((PlayerDisguise) getDisguise()).setNameVisible(display);
return;
}
if (DisguiseConfig.isArmorstandsName() && DisguiseConfig.isOverrideCustomNames()) { if (DisguiseConfig.isArmorstandsName() && DisguiseConfig.isOverrideCustomNames()) {
display = false; display = false;
} }
setInternalCustomNameVisible(display);
}
protected void setInternalCustomNameVisible(boolean display) {
setData(MetaIndex.ENTITY_CUSTOM_NAME_VISIBLE, display); setData(MetaIndex.ENTITY_CUSTOM_NAME_VISIBLE, display);
sendData(MetaIndex.ENTITY_CUSTOM_NAME_VISIBLE); sendData(MetaIndex.ENTITY_CUSTOM_NAME_VISIBLE);
} }

View File

@ -4,6 +4,7 @@ import com.comphenix.protocol.wrappers.WrappedGameProfile;
import com.comphenix.protocol.wrappers.nbt.NbtCompound; import com.comphenix.protocol.wrappers.nbt.NbtCompound;
import com.comphenix.protocol.wrappers.nbt.NbtFactory; import com.comphenix.protocol.wrappers.nbt.NbtFactory;
import me.libraryaddict.disguise.DisguiseConfig; import me.libraryaddict.disguise.DisguiseConfig;
import me.libraryaddict.disguise.LibsDisguises;
import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.MetaIndex; import me.libraryaddict.disguise.disguisetypes.MetaIndex;
import me.libraryaddict.disguise.disguisetypes.PlayerDisguise; import me.libraryaddict.disguise.disguisetypes.PlayerDisguise;
@ -19,9 +20,6 @@ public class PlayerWatcher extends LivingWatcher {
setData(MetaIndex.PLAYER_SKIN, MetaIndex.PLAYER_SKIN.getDefault()); setData(MetaIndex.PLAYER_SKIN, MetaIndex.PLAYER_SKIN.getDefault());
setData(MetaIndex.PLAYER_HAND, (byte) 1); // I may be left handed, but the others are right setData(MetaIndex.PLAYER_HAND, (byte) 1); // I may be left handed, but the others are right
setInteralCustomName("");
setCustomNameVisible(false);
} }
public boolean isDisplayedInTab() { public boolean isDisplayedInTab() {