From 28346e1185e3a8c10aedb3d375b897968ee36935 Mon Sep 17 00:00:00 2001 From: syeyoung Date: Tue, 24 Jan 2023 15:32:19 +0900 Subject: - Fixes #259 Signed-off-by: syeyoung --- .../mod/cosmetics/CustomNetworkPlayerInfo.java | 39 +++++++++------------- 1 file changed, 15 insertions(+), 24 deletions(-) (limited to 'mod/src/main/java/kr/syeyoung') diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/cosmetics/CustomNetworkPlayerInfo.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/cosmetics/CustomNetworkPlayerInfo.java index a92cd094..0aecc157 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/cosmetics/CustomNetworkPlayerInfo.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/cosmetics/CustomNetworkPlayerInfo.java @@ -42,7 +42,7 @@ public class CustomNetworkPlayerInfo extends NetworkPlayerInfo { private IChatComponent displayName; - private String unformattedDisplayText; + private String formatted; private String playerNameWithoutColor; public IChatComponent getOriginalDisplayName() { @@ -53,15 +53,15 @@ public class CustomNetworkPlayerInfo extends NetworkPlayerInfo { public void setDisplayName(IChatComponent displayNameIn) { displayName = displayNameIn; if (displayName == null) { - unformattedDisplayText = null; + formatted = null; return; } - unformattedDisplayText = displayName.getUnformattedTextForChat(); + formatted = displayName.getFormattedText(); playerNameWithoutColor = ""; - for (String s : unformattedDisplayText.split(" ")) { + for (String s : formatted.split(" ")) { String strippped = TextUtils.stripColor(s); if (strippped.startsWith("[")) { continue; @@ -75,28 +75,19 @@ public class CustomNetworkPlayerInfo extends NetworkPlayerInfo { public IChatComponent getDisplayName() { - String rawPlayerString; - String actualName; + String rawPlayerString = + formatted != null ? formatted : ScorePlayerTeam.formatPlayerName(super.getPlayerTeam(), super.getGameProfile().getName());; + String actualName = null; List activeCosmetics; - - // in case that the set player name is not called we do this - if (playerNameWithoutColor != null) { - activeCosmetics = DungeonsGuide.getDungeonsGuide().getCosmeticsManager().getActiveCosmeticByPlayerNameLowerCase().get(playerNameWithoutColor.toLowerCase()); - rawPlayerString = unformattedDisplayText; - actualName = this.playerNameWithoutColor; - } else { - rawPlayerString = ScorePlayerTeam.formatPlayerName(super.getPlayerTeam(), super.getGameProfile().getName()); - actualName = ""; - for (String s : rawPlayerString.split(" ")) { - String strippped = TextUtils.stripColor(s); - if (strippped.startsWith("[")) continue; - actualName = strippped; - break; - } - activeCosmetics = DungeonsGuide.getDungeonsGuide().getCosmeticsManager().getActiveCosmeticByPlayerNameLowerCase().get(actualName.toLowerCase()); + for (String s : rawPlayerString.split(" ")) { + String strippped = TextUtils.stripColor(s); + if (strippped.startsWith("[")) continue; + actualName = strippped; + break; } - - + // in case that the set player name is not called we do this + if (actualName == null) return displayName; + activeCosmetics = DungeonsGuide.getDungeonsGuide().getCosmeticsManager().getActiveCosmeticByPlayerNameLowerCase().get(actualName.toLowerCase()); if (activeCosmetics == null) return displayName; CosmeticData color=null; for (ActiveCosmetic activeCosmetic : activeCosmetics) { -- cgit