From 0ce85946a0156957a74ddb141f5e4102e7b7e14d Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Thu, 17 Feb 2022 22:57:57 +1300 Subject: [PATCH] Fix #638, and make setCustomNameVisible work for setNameVisible, I should really fix permissions for this. --- .../libraryaddict/disguise/disguisetypes/Disguise.java | 5 +++++ .../disguise/disguisetypes/FlagWatcher.java | 9 +++++++++ .../disguise/disguisetypes/watchers/PlayerWatcher.java | 4 +--- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/Disguise.java b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/Disguise.java index f64e979e..1fbd8c88 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/Disguise.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/Disguise.java @@ -868,6 +868,11 @@ public abstract class Disguise { 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 ((getEntity() instanceof Boat || getEntity() instanceof AbstractHorse) && (getWatcher() instanceof BoatWatcher || getWatcher() instanceof AbstractHorseWatcher)) { diff --git a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/FlagWatcher.java b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/FlagWatcher.java index ccd6e368..fd82dacc 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/FlagWatcher.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/FlagWatcher.java @@ -707,10 +707,19 @@ public class FlagWatcher { } public void setCustomNameVisible(boolean display) { + if (getDisguise().isPlayerDisguise()) { + ((PlayerDisguise) getDisguise()).setNameVisible(display); + return; + } + if (DisguiseConfig.isArmorstandsName() && DisguiseConfig.isOverrideCustomNames()) { display = false; } + setInternalCustomNameVisible(display); + } + + protected void setInternalCustomNameVisible(boolean display) { setData(MetaIndex.ENTITY_CUSTOM_NAME_VISIBLE, display); sendData(MetaIndex.ENTITY_CUSTOM_NAME_VISIBLE); } diff --git a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/PlayerWatcher.java b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/PlayerWatcher.java index 339a4d69..0a860c1b 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/PlayerWatcher.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/PlayerWatcher.java @@ -4,6 +4,7 @@ import com.comphenix.protocol.wrappers.WrappedGameProfile; import com.comphenix.protocol.wrappers.nbt.NbtCompound; import com.comphenix.protocol.wrappers.nbt.NbtFactory; import me.libraryaddict.disguise.DisguiseConfig; +import me.libraryaddict.disguise.LibsDisguises; import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.MetaIndex; 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_HAND, (byte) 1); // I may be left handed, but the others are right - - setInteralCustomName(""); - setCustomNameVisible(false); } public boolean isDisplayedInTab() {