Skip to content

Commit 3dadece

Browse files
committed
Added escape "\" for command click actions
1 parent e731607 commit 3dadece

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

src/com/loohp/interactivechat/Modules/CommandsDisplay.java

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,20 @@ public static BaseComponent process(BaseComponent basecomponent) {
5757
if (!parsingCommand) {
5858
int begin = textComp.getText().indexOf(InteractiveChat.clickableCommandsPrefix);
5959
if (begin >= 0) {
60-
String remaining = ChatColorUtils.stripColor(textComp.getText().substring(begin));
61-
if (remaining.length() > InteractiveChat.clickableCommandsPrefix.length() && remaining.charAt(InteractiveChat.clickableCommandsPrefix.length()) == '/') {
62-
parsingCommand = true;
63-
TextComponent before = new TextComponent(textComp);
64-
before.setText(before.getText().substring(0, begin));
65-
newlist.add(before);
66-
textComp.setText(ChatColorUtils.getLastColors(before.getText()) + textComp.getText().substring(begin + InteractiveChat.clickableCommandsPrefix.length()));
67-
basecomponentlist.add(i + 1, textComp);
68-
indexOfParsingStart = i + 1;
60+
if (begin == 0 || textComp.getText().charAt(begin - 1) != '\\' || (begin > 1 && textComp.getText().charAt(begin - 1) == '\\' && textComp.getText().charAt(begin - 2) == '\\')) {
61+
String remaining = ChatColorUtils.stripColor(textComp.getText().substring(begin));
62+
if (remaining.length() > InteractiveChat.clickableCommandsPrefix.length() && remaining.charAt(InteractiveChat.clickableCommandsPrefix.length()) == '/') {
63+
parsingCommand = true;
64+
TextComponent before = new TextComponent(textComp);
65+
before.setText(before.getText().substring(0, begin));
66+
if (before.getText().endsWith("\\")) {
67+
before.setText(before.getText().substring(0, before.getText().length() - 1));
68+
}
69+
newlist.add(before);
70+
textComp.setText(ChatColorUtils.getLastColors(before.getText()) + textComp.getText().substring(begin + InteractiveChat.clickableCommandsPrefix.length()));
71+
basecomponentlist.add(i + 1, textComp);
72+
indexOfParsingStart = i + 1;
73+
}
6974
}
7075
}
7176
}

0 commit comments

Comments
 (0)