Have playerdisguise start overriding setCustomName

This commit is contained in:
libraryaddict 2022-02-16 20:02:10 +13:00
parent e0bbcbd43e
commit be3c1536a9
5 changed files with 22 additions and 7 deletions

View File

@ -6,11 +6,13 @@ import me.libraryaddict.disguise.commands.DisguiseBaseCommand;
import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher; import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
import me.libraryaddict.disguise.utilities.DisguiseUtilities; 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.DisguiseParseException;
import me.libraryaddict.disguise.utilities.parser.DisguiseParser; import me.libraryaddict.disguise.utilities.parser.DisguiseParser;
import me.libraryaddict.disguise.utilities.parser.DisguisePermissions; import me.libraryaddict.disguise.utilities.parser.DisguisePermissions;
import me.libraryaddict.disguise.utilities.translations.LibsMsg; import me.libraryaddict.disguise.utilities.translations.LibsMsg;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter; import org.bukkit.command.TabCompleter;
@ -19,6 +21,7 @@ import org.bukkit.entity.Player;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.TimeUnit;
public class DisguiseCommand extends DisguiseBaseCommand implements TabCompleter { public class DisguiseCommand extends DisguiseBaseCommand implements TabCompleter {
@Override @Override
@ -79,6 +82,10 @@ public class DisguiseCommand extends DisguiseBaseCommand implements TabCompleter
disguise.setNotifyBar(DisguiseConfig.NotifyBar.NONE); 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); disguise.startDisguise(sender);
if (disguise.isDisguiseInUse()) { if (disguise.isDisguiseInUse()) {

View File

@ -179,6 +179,7 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
if (entity instanceof Player && DisguiseConfig.isNameOfPlayerShownAboveDisguise() && !entity.hasPermission("libsdisguises.hidename")) { if (entity instanceof Player && DisguiseConfig.isNameOfPlayerShownAboveDisguise() && !entity.hasPermission("libsdisguises.hidename")) {
if (disguise.getWatcher() instanceof LivingWatcher) { if (disguise.getWatcher() instanceof LivingWatcher) {
disguise.getWatcher().setCustomName(getDisplayName(entity)); disguise.getWatcher().setCustomName(getDisplayName(entity));
if (DisguiseConfig.isNameAboveHeadAlwaysVisible()) { if (DisguiseConfig.isNameAboveHeadAlwaysVisible()) {
disguise.getWatcher().setCustomNameVisible(true); disguise.getWatcher().setCustomNameVisible(true);
} }

View File

@ -868,11 +868,6 @@ 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().setCustomName("");
getWatcher().setCustomNameVisible(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

@ -513,7 +513,11 @@ public class FlagWatcher {
} }
public String getCustomName() { 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) { if (getDisguise().getMultiNameLength() == 0) {
return null; return null;
} }
@ -545,6 +549,11 @@ public class FlagWatcher {
name = name.substring(1); name = name.substring(1);
} }
if (getDisguise().isPlayerDisguise()) {
((PlayerDisguise) getDisguise()).setName(name);
return;
}
name = DisguiseUtilities.getHexedColors(name); name = DisguiseUtilities.getHexedColors(name);
String customName = getCustomName(); String customName = getCustomName();
@ -553,7 +562,7 @@ public class FlagWatcher {
return; 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; MetaIndex custom = NmsVersion.v1_13.isSupported() ? MetaIndex.ENTITY_CUSTOM_NAME : MetaIndex.ENTITY_CUSTOM_NAME_OLD;
if (!hasValue(custom)) { if (!hasValue(custom)) {

View File

@ -19,6 +19,9 @@ 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() {