diff --git a/src/com/loohp/interactivechat/Modules/PlayernameDisplay.java b/src/com/loohp/interactivechat/Modules/PlayernameDisplay.java index a96c99c1..4baa5868 100644 --- a/src/com/loohp/interactivechat/Modules/PlayernameDisplay.java +++ b/src/com/loohp/interactivechat/Modules/PlayernameDisplay.java @@ -73,15 +73,17 @@ public static BaseComponent processPlayer(String placeholder, Player player, Str if (trim.get(trim.size() - 1).equals("")) { trim.remove(trim.size() - 1); } + + String lastColor = ""; + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < trim.size(); i++) { TextComponent before = (TextComponent) textcomponent.duplicate(); - before.setText(trim.get(i)); + before.setText(lastColor + trim.get(i)); newlist.add(before); + sb.append(before.getText()); if ((trim.size() - 1) > i || text.matches(".*" + regex + "$")) { - StringBuilder sb = new StringBuilder(); - newlist.forEach((each) -> sb.append(each.toLegacyText())); - - String lastColor = ChatColorUtils.getLastColors(sb.toString()); + lastColor = ChatColorUtils.getLastColors(sb.toString()); TextComponent message = new TextComponent(matches.isEmpty() ? replaceText : matches.poll()); message = (TextComponent) CustomStringUtils.copyFormatting(message, before); @@ -98,6 +100,8 @@ public static BaseComponent processPlayer(String placeholder, Player player, Str matched.add(message); newlist.add(message); + + lastColor = ChatColorUtils.getLastColors(sb.append(message.getText()).toString()); } } } diff --git a/src/com/loohp/interactivechat/Utils/ChatComponentUtils.java b/src/com/loohp/interactivechat/Utils/ChatComponentUtils.java index 6ff14087..45682249 100644 --- a/src/com/loohp/interactivechat/Utils/ChatComponentUtils.java +++ b/src/com/loohp/interactivechat/Utils/ChatComponentUtils.java @@ -77,7 +77,7 @@ public static BaseComponent cleanUpLegacyText(BaseComponent basecomponent, Playe TextComponent newTextComponent = new TextComponent(ChatColor.stripColor(before)); newTextComponent = (TextComponent) CustomStringUtils.copyFormatting(newTextComponent, textcomponent); newTextComponent = (TextComponent) ChatColorUtils.applyColor(newTextComponent, color); - if (!newlist.isEmpty() && areSimilar(newTextComponent, newlist.get(newlist.size() - 1), false)) { + if (!newlist.isEmpty() && areSimilar(newTextComponent, newlist.get(newlist.size() - 1), false) && newlist.get(newlist.size() - 1) instanceof TextComponent) { TextComponent lastTextComponent = (TextComponent) newlist.get(newlist.size() - 1); lastTextComponent.setText(lastTextComponent.getText() + newTextComponent.getText()); } else { diff --git a/src/plugin.yml b/src/plugin.yml index c99a15b7..b9e86ce6 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: InteractiveChat author: loohp -version: 2.1.11 +version: 2.1.12 main: com.loohp.interactivechat.InteractiveChat api-version: 1.13 description: Make the chat interactive