From a018973eebe65bd51cbe4bdea2b48973155c4c23 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Mon, 11 May 2020 17:58:32 +1200 Subject: [PATCH] Deny setCustomNameVisible if overriden custom names --- .../disguise/disguisetypes/FlagWatcher.java | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/FlagWatcher.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/FlagWatcher.java index 5f885964..045151af 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/FlagWatcher.java +++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/FlagWatcher.java @@ -359,16 +359,13 @@ public class FlagWatcher { public void setCustomName(String name) { if (!getDisguise().isPlayerDisguise() && DisguiseConfig.isArmorstandsName() && DisguiseConfig.isOverrideCustomNames()) { - if (NmsVersion.v1_13.isSupported()) { - if (!hasValue(MetaIndex.ENTITY_CUSTOM_NAME)) { - setData(MetaIndex.ENTITY_CUSTOM_NAME, Optional.empty()); - sendData(MetaIndex.ENTITY_CUSTOM_NAME); - } - } else { - if (!hasValue(MetaIndex.ENTITY_CUSTOM_NAME_OLD)) { - setData(MetaIndex.ENTITY_CUSTOM_NAME_OLD, ""); - sendData(MetaIndex.ENTITY_CUSTOM_NAME_OLD); - } + MetaIndex custom = + NmsVersion.v1_13.isSupported() ? MetaIndex.ENTITY_CUSTOM_NAME : MetaIndex.ENTITY_CUSTOM_NAME_OLD; + + if (!hasValue(custom)) { + setData(custom, custom.getDefault()); + sendData(MetaIndex.ENTITY_CUSTOM_NAME); + setCustomNameVisible(false); } if (Strings.isNullOrEmpty(name)) { @@ -483,6 +480,10 @@ public class FlagWatcher { } public void setCustomNameVisible(boolean display) { + if (DisguiseConfig.isArmorstandsName() && DisguiseConfig.isOverrideCustomNames()) { + display = false; + } + setData(MetaIndex.ENTITY_CUSTOM_NAME_VISIBLE, display); sendData(MetaIndex.ENTITY_CUSTOM_NAME_VISIBLE); }