Skip to content

Commit

Permalink
Add playername display to translatable component substitutes as well
Browse files Browse the repository at this point in the history
  • Loading branch information
LOOHP committed Aug 16, 2020
1 parent b7cfea7 commit bfe0fcf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>InteractiveChat</groupId>
<artifactId>InteractiveChat</artifactId>
<version>2.6.11</version>
<version>2.6.12</version>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
Expand Down
13 changes: 12 additions & 1 deletion src/com/loohp/interactivechat/Modules/PlayernameDisplay.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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<BaseComponent> withs = trans.getWith();
List<BaseComponent> withMatched = new ArrayList<BaseComponent>();
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();
Expand Down

0 comments on commit bfe0fcf

Please sign in to comment.