diff options
author | syeyoung <cyong06@naver.com> | 2021-08-24 16:29:19 +0900 |
---|---|---|
committer | syeyoung <cyong06@naver.com> | 2021-08-24 16:29:19 +0900 |
commit | 6e5f013c6e27a7f806cdb0de5a4c35e20d484d5c (patch) | |
tree | c01e119137f742d39878a1dbdf34e9e74a0f8ba7 /src/main | |
parent | 0c05fa4edc4558bd33176acff66b1fa70af906b7 (diff) | |
download | Skyblock-Dungeons-Guide-6e5f013c6e27a7f806cdb0de5a4c35e20d484d5c.tar.gz Skyblock-Dungeons-Guide-6e5f013c6e27a7f806cdb0de5a4c35e20d484d5c.tar.bz2 Skyblock-Dungeons-Guide-6e5f013c6e27a7f806cdb0de5a4c35e20d484d5c.zip |
Optimzied Network Player Info
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/kr/syeyoung/dungeonsguide/cosmetics/CustomNetworkPlayerInfo.java | 55 |
1 files changed, 46 insertions, 9 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/CustomNetworkPlayerInfo.java b/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/CustomNetworkPlayerInfo.java index 4bfa775a..cfbf1fc0 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/CustomNetworkPlayerInfo.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/CustomNetworkPlayerInfo.java @@ -36,23 +36,60 @@ public class CustomNetworkPlayerInfo extends NetworkPlayerInfo { public CustomNetworkPlayerInfo(S38PacketPlayerListItem.AddPlayerData p_i46295_1_) { super(p_i46295_1_); + setDisplayName(super.getDisplayName()); } - public IChatComponent getDisplayName() - { - String semi_name = super.getDisplayName() != null ? super.getDisplayName().getFormattedText() : ScorePlayerTeam.formatPlayerName(super.getPlayerTeam(), super.getGameProfile().getName()); - String actualName = ""; - for (String s : semi_name.split(" ")) { - if (TextUtils.stripColor(s).startsWith("[")) continue; - actualName = TextUtils.stripColor(s); + private IChatComponent displayName; + private String playernameLowercase; + private String unformatted; + private String actualName; + @Override + public void setDisplayName(IChatComponent displayNameIn) { + displayName = displayNameIn; + if (displayName == null) { + playernameLowercase = null; + unformatted = null; + return; + } + + unformatted = displayName.getUnformattedText(); + + + actualName = ""; + for (String s : unformatted.split(" ")) { + String strippped = TextUtils.stripColor(s); + if (strippped.startsWith("[")) continue; + actualName = strippped; break; } - List<ActiveCosmetic> activeCosmetics = DungeonsGuide.getDungeonsGuide().getCosmeticsManager().getActiveCosmeticByPlayerNameLowerCase().get(actualName.toLowerCase()); + playernameLowercase = actualName.toLowerCase(); + } + public IChatComponent getDisplayName() + { + + String semi_name; + String actualName; + List<ActiveCosmetic> activeCosmetics; + if (playernameLowercase != null) { + activeCosmetics = DungeonsGuide.getDungeonsGuide().getCosmeticsManager().getActiveCosmeticByPlayerNameLowerCase().get(playernameLowercase); + semi_name = unformatted; + actualName = this.actualName; + } else { + semi_name = ScorePlayerTeam.formatPlayerName(super.getPlayerTeam(), super.getGameProfile().getName()); + actualName = ""; + for (String s : semi_name.split(" ")) { + String strippped = TextUtils.stripColor(s); + if (strippped.startsWith("[")) continue; + actualName = strippped; + break; + } + activeCosmetics = DungeonsGuide.getDungeonsGuide().getCosmeticsManager().getActiveCosmeticByPlayerNameLowerCase().get(actualName.toLowerCase()); + } - if (activeCosmetics == null) return super.getDisplayName(); + if (activeCosmetics == null) return displayName; CosmeticData color=null; for (ActiveCosmetic activeCosmetic : activeCosmetics) { CosmeticData cosmeticData = DungeonsGuide.getDungeonsGuide().getCosmeticsManager().getCosmeticDataMap().get(activeCosmetic.getCosmeticData()); |