From 9593225f8efd354d8b097008f5acb9becd444de1 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Mon, 7 Jun 2021 20:01:27 +1200 Subject: [PATCH] Let setDynamicName work on player disguises and player entities --- .../disguise/disguisetypes/Disguise.java | 18 +++++++++++++++--- .../disguise/disguisetypes/PlayerDisguise.java | 8 +++++++- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/Disguise.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/Disguise.java index a0b78447..b4e49c6f 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/Disguise.java +++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/Disguise.java @@ -380,7 +380,13 @@ public abstract class Disguise { } if (isDynamicName()) { - String name = getEntity().getCustomName(); + String name; + + if (getEntity() instanceof Player) { + name = DisguiseUtilities.translateAlternateColorCodes(DisguiseUtilities.getDisplayName(getEntity())); + } else { + name = getEntity().getCustomName(); + } if (name == null) { name = ""; @@ -1014,8 +1020,14 @@ public abstract class Disguise { setExpires(DisguiseConfig.isDynamicExpiry() ? 240 * 20 : System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(330)); } - if (isDynamicName() && !isPlayerDisguise()) { - String name = getEntity().getCustomName(); + if (isDynamicName()) { + String name; + + if (getEntity() instanceof Player) { + name = DisguiseUtilities.translateAlternateColorCodes(DisguiseUtilities.getDisplayName(getEntity())); + } else { + name = getEntity().getCustomName(); + } if (name == null) { name = ""; diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/PlayerDisguise.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/PlayerDisguise.java index d7ce862f..ab2b2a99 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/PlayerDisguise.java +++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/PlayerDisguise.java @@ -648,7 +648,13 @@ public class PlayerDisguise extends TargetedDisguise { } if (isDynamicName()) { - String name = getEntity().getCustomName(); + String name; + + if (getEntity() instanceof Player) { + name = DisguiseUtilities.translateAlternateColorCodes(DisguiseUtilities.getDisplayName(getEntity())); + } else { + name = getEntity().getCustomName(); + } if (name == null) { name = "";