From bfe0fcfbc99acfae0dbbfbea19827f3199ed015b Mon Sep 17 00:00:00 2001 From: LOOHP Date: Sun, 16 Aug 2020 22:10:11 +0800 Subject: [PATCH] Add playername display to translatable component substitutes as well --- pom.xml | 2 +- .../interactivechat/Modules/PlayernameDisplay.java | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index e8e330de..2723b80d 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 InteractiveChat InteractiveChat - 2.6.11 + 2.6.12 src diff --git a/src/com/loohp/interactivechat/Modules/PlayernameDisplay.java b/src/com/loohp/interactivechat/Modules/PlayernameDisplay.java index d0824e8e..892b9ec8 100644 --- a/src/com/loohp/interactivechat/Modules/PlayernameDisplay.java +++ b/src/com/loohp/interactivechat/Modules/PlayernameDisplay.java @@ -24,6 +24,7 @@ import net.md_5.bungee.api.chat.ComponentBuilder; import net.md_5.bungee.api.chat.HoverEvent; import net.md_5.bungee.api.chat.TextComponent; +import net.md_5.bungee.api.chat.TranslatableComponent; public class PlayernameDisplay { @@ -58,7 +59,17 @@ public static BaseComponent processPlayer(String placeholder, Player player, Str if (matched.stream().anyMatch(each -> ChatComponentUtils.areSimilar(each, base, true))) { newlist.add(base); } else if (!(base instanceof TextComponent)) { - newlist.add(base); + if (base instanceof TranslatableComponent) { + TranslatableComponent trans = (TranslatableComponent) base; + List withs = trans.getWith(); + List withMatched = new ArrayList(); + for (int i = 0; i < withs.size(); i++) { + withs.set(i, processPlayer(placeholder, player, replaceText, withs.get(i), withMatched, messageKey, unix)); + } + newlist.add(base); + } else { + newlist.add(base); + } } else { TextComponent textcomponent = (TextComponent) base; String text = textcomponent.getText();