Skip to content

Commit

Permalink
2.1.12 Update
Browse files Browse the repository at this point in the history
  • Loading branch information
LOOHP committed May 7, 2020
1 parent abb6367 commit 7fdf086
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
14 changes: 9 additions & 5 deletions src/com/loohp/interactivechat/Modules/PlayernameDisplay.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/plugin.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 7fdf086

Please sign in to comment.