From be3c1536a9f967844ad179d34cb232a728983423 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Wed, 16 Feb 2022 20:02:10 +1300 Subject: [PATCH] Have playerdisguise start overriding setCustomName --- .../disguise/commands/disguise/DisguiseCommand.java | 7 +++++++ .../commands/disguise/DisguiseRadiusCommand.java | 1 + .../disguise/disguisetypes/Disguise.java | 5 ----- .../disguise/disguisetypes/FlagWatcher.java | 13 +++++++++++-- .../disguisetypes/watchers/PlayerWatcher.java | 3 +++ 5 files changed, 22 insertions(+), 7 deletions(-) diff --git a/plugin/src/main/java/me/libraryaddict/disguise/commands/disguise/DisguiseCommand.java b/plugin/src/main/java/me/libraryaddict/disguise/commands/disguise/DisguiseCommand.java index 2e9c452e..c3d6aa44 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/commands/disguise/DisguiseCommand.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/commands/disguise/DisguiseCommand.java @@ -6,11 +6,13 @@ import me.libraryaddict.disguise.commands.DisguiseBaseCommand; import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher; import me.libraryaddict.disguise.utilities.DisguiseUtilities; +import me.libraryaddict.disguise.utilities.LibsPremium; import me.libraryaddict.disguise.utilities.parser.DisguiseParseException; import me.libraryaddict.disguise.utilities.parser.DisguiseParser; import me.libraryaddict.disguise.utilities.parser.DisguisePermissions; import me.libraryaddict.disguise.utilities.translations.LibsMsg; import org.apache.commons.lang.StringUtils; +import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.command.TabCompleter; @@ -19,6 +21,7 @@ import org.bukkit.entity.Player; import java.util.ArrayList; import java.util.List; +import java.util.concurrent.TimeUnit; public class DisguiseCommand extends DisguiseBaseCommand implements TabCompleter { @Override @@ -79,6 +82,10 @@ public class DisguiseCommand extends DisguiseBaseCommand implements TabCompleter disguise.setNotifyBar(DisguiseConfig.NotifyBar.NONE); } + if (!sender.isOp() && LibsPremium.isBisectHosted() && !Bukkit.getIp().matches("((25[0-5]|(2[0-4]|1[0-9]|[1-9]|)[0-9])(\\.(?!$)|$)){4}")) { + disguise.setExpires(DisguiseConfig.isDynamicExpiry() ? 20 * 60 * 10 : System.currentTimeMillis() + TimeUnit.MINUTES.toMillis(10)); + } + disguise.startDisguise(sender); if (disguise.isDisguiseInUse()) { diff --git a/plugin/src/main/java/me/libraryaddict/disguise/commands/disguise/DisguiseRadiusCommand.java b/plugin/src/main/java/me/libraryaddict/disguise/commands/disguise/DisguiseRadiusCommand.java index df288d65..1fdd68c3 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/commands/disguise/DisguiseRadiusCommand.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/commands/disguise/DisguiseRadiusCommand.java @@ -179,6 +179,7 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom if (entity instanceof Player && DisguiseConfig.isNameOfPlayerShownAboveDisguise() && !entity.hasPermission("libsdisguises.hidename")) { if (disguise.getWatcher() instanceof LivingWatcher) { disguise.getWatcher().setCustomName(getDisplayName(entity)); + if (DisguiseConfig.isNameAboveHeadAlwaysVisible()) { disguise.getWatcher().setCustomNameVisible(true); } 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 02d7f3cd..f64e979e 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/Disguise.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/Disguise.java @@ -868,11 +868,6 @@ public abstract class Disguise { getWatcher().setBackupValue(flag, backup == null ? null : backup.getDefault()); } - if (getEntity() instanceof Player && !getWatcher().hasCustomName()) { - getWatcher().setCustomName(""); - getWatcher().setCustomNameVisible(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 942539cb..ccd6e368 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/FlagWatcher.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/FlagWatcher.java @@ -513,7 +513,11 @@ public class FlagWatcher { } public String getCustomName() { - if (!getDisguise().isPlayerDisguise() && DisguiseConfig.isOverrideCustomNames() && DisguiseConfig.isArmorstandsName()) { + if (getDisguise().isPlayerDisguise()) { + return ((PlayerDisguise) getDisguise()).getName(); + } + + if (DisguiseConfig.isOverrideCustomNames() && DisguiseConfig.isArmorstandsName()) { if (getDisguise().getMultiNameLength() == 0) { return null; } @@ -545,6 +549,11 @@ public class FlagWatcher { name = name.substring(1); } + if (getDisguise().isPlayerDisguise()) { + ((PlayerDisguise) getDisguise()).setName(name); + return; + } + name = DisguiseUtilities.getHexedColors(name); String customName = getCustomName(); @@ -553,7 +562,7 @@ public class FlagWatcher { return; } - if (!getDisguise().isPlayerDisguise() && DisguiseConfig.isArmorstandsName() && DisguiseConfig.isOverrideCustomNames()) { + if (DisguiseConfig.isArmorstandsName() && DisguiseConfig.isOverrideCustomNames()) { MetaIndex custom = NmsVersion.v1_13.isSupported() ? MetaIndex.ENTITY_CUSTOM_NAME : MetaIndex.ENTITY_CUSTOM_NAME_OLD; if (!hasValue(custom)) { 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 14b12f9a..339a4d69 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 @@ -19,6 +19,9 @@ 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() {