Don't allow vanilla nametag setting to ruin player disguise names

This commit is contained in:
libraryaddict 2024-09-23 22:26:28 +12:00
parent 0034aa07db
commit e0eba67f74
4 changed files with 11 additions and 4 deletions

View File

@ -12,6 +12,7 @@ import me.libraryaddict.disguise.commands.modify.DisguiseModifyCommand;
import me.libraryaddict.disguise.commands.modify.DisguiseModifyEntityCommand;
import me.libraryaddict.disguise.commands.modify.DisguiseModifyPlayerCommand;
import me.libraryaddict.disguise.commands.modify.DisguiseModifyRadiusCommand;
import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
import me.libraryaddict.disguise.disguisetypes.watchers.MinecartWatcher;
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
@ -293,7 +294,13 @@ public abstract class DisguiseBaseCommand implements CommandExecutor {
return new ArrayList<>(new HashSet<>(list));
}
protected String getDisplayName(CommandSender player) {
protected String getDisplayName(Disguise disguise, CommandSender player) {
// If we can't do fancy names, and this nametag can't go beyond the 16 char name limit
// Then we shouldn't say anything but the actual name
if (disguise.isPlayerDisguise() && !DisguiseConfig.isScoreboardNames()) {
return player.getName();
}
String name = DisguiseConfig.getNameAboveDisguise().replace("%simple%", player.getName());
if (name.contains("%complex%")) {

View File

@ -61,7 +61,7 @@ public class DisguiseCommand extends DisguiseBaseCommand implements TabCompleter
if (DisguiseConfig.isNameOfPlayerShownAboveDisguise() && !sender.hasPermission("libsdisguises.hidename")) {
if (disguise.getWatcher() instanceof LivingWatcher) {
disguise.getWatcher().setCustomName(getDisplayName(sender));
disguise.getWatcher().setCustomName(getDisplayName(disguise, sender));
if (DisguiseConfig.isNameAboveHeadAlwaysVisible()) {
disguise.getWatcher().setCustomNameVisible(true);

View File

@ -97,7 +97,7 @@ public class DisguisePlayerCommand extends DisguiseBaseCommand implements TabCom
if (DisguiseConfig.isNameOfPlayerShownAboveDisguise() && !entityTarget.hasPermission("libsdisguises.hidename")) {
if (disguise.getWatcher() instanceof LivingWatcher) {
disguise.getWatcher().setCustomName(getDisplayName(entityTarget));
disguise.getWatcher().setCustomName(getDisplayName(disguise, entityTarget));
if (DisguiseConfig.isNameAboveHeadAlwaysVisible()) {
disguise.getWatcher().setCustomNameVisible(true);

View File

@ -179,7 +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));
disguise.getWatcher().setCustomName(getDisplayName(disguise, entity));
if (DisguiseConfig.isNameAboveHeadAlwaysVisible()) {
disguise.getWatcher().setCustomNameVisible(true);