Skip to content

Commit

Permalink
Pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
LOOHP committed Jul 5, 2020
1 parent d4f0c51 commit 586cba6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
12 changes: 6 additions & 6 deletions src/com/loohp/interactivechat/Utils/ChatColorUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class ChatColorUtils {

private static Set<Character> colors = new HashSet<Character>();
private static Pattern colorFormating = Pattern.compile("(?=(?<!\\\\)|(?<=\\\\\\\\))\\[[^\\]]*?color=#[0-9a-fA-F]{6}[^\\[]*?\\]");
private static Pattern colorEscape = Pattern.compile("\\\\\\[[^\\]]*?color=#[0-9a-fA-F]{6}[^\\[]*?\\]");
private static Pattern colorEscape = Pattern.compile("\\\\\\[ *?color=#[0-9a-fA-F]{6} *?\\]");

static {
colors.add('0');
Expand Down Expand Up @@ -215,11 +215,11 @@ public static String translatePluginColorFormatting(String text) {
if (sb.charAt(absPos) == ']' && sb.charAt(absPos - 1) == '[') {
sb.deleteCharAt(absPos - 1);
sb.deleteCharAt(absPos - 1);
}

if (absPos > 2 && sb.charAt(absPos - 2) == '\\' && sb.charAt(absPos - 3) == '\\') {
sb.deleteCharAt(absPos - 2);
}
if (absPos > 2 && sb.charAt(absPos - 2) == '\\' && sb.charAt(absPos - 3) == '\\') {
sb.deleteCharAt(absPos - 2);
}
}

text = sb.toString();
} else {
Expand Down
14 changes: 7 additions & 7 deletions src/com/loohp/interactivechat/Utils/ChatComponentUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class ChatComponentUtils {
private static MethodHandle hoverEventGetValueMethod;

private static Pattern fontFormating = Pattern.compile("(?=(?<!\\\\)|(?<=\\\\\\\\))\\[[^\\]]*?font=[0-9a-zA-Z:_]*[^\\[]*?\\]");
private static Pattern fontEscape = Pattern.compile("\\\\\\[[^\\]]*?font=[0-9a-zA-Z:_]*[^\\[]*?\\]");
private static Pattern fontEscape = Pattern.compile("\\\\\\[ *?font=[0-9a-zA-Z:_]* *?\\]");

public static void setupLegacy() {
try {
Expand Down Expand Up @@ -441,14 +441,14 @@ public static BaseComponent translatePluginFontFormatting(BaseComponent basecomp

if (sb.charAt(absPos) == ']' && sb.charAt(absPos - 1) == '[') {
sb.deleteCharAt(absPos - 1);
sb.deleteCharAt(absPos - 1);
sb.deleteCharAt(absPos - 1);

if (absPos > 2 && sb.charAt(absPos - 2) == '\\' && sb.charAt(absPos - 3) == '\\') {
sb.deleteCharAt(absPos - 2);
absPos--;
}
}

if (absPos > 2 && sb.charAt(absPos - 2) == '\\' && sb.charAt(absPos - 3) == '\\') {
sb.deleteCharAt(absPos - 2);
absPos--;
}

absPos--;

TextComponent before = new TextComponent(textcomponent);
Expand Down

0 comments on commit 586cba6

Please sign in to comment.