diff --git a/build-number.txt b/build-number.txt index 80c63200..c15dd12d 100644 --- a/build-number.txt +++ b/build-number.txt @@ -1 +1 @@ -1583 \ No newline at end of file +1588 \ No newline at end of file diff --git a/src/main/java/me/chayapak1/chomens_bot/util/ComponentUtilities.java b/src/main/java/me/chayapak1/chomens_bot/util/ComponentUtilities.java index 70da1d73..276a9ba8 100644 --- a/src/main/java/me/chayapak1/chomens_bot/util/ComponentUtilities.java +++ b/src/main/java/me/chayapak1/chomens_bot/util/ComponentUtilities.java @@ -57,7 +57,7 @@ public class ComponentUtilities { private static class ComponentParser { public static final Pattern ARG_PATTERN = Pattern.compile("%(?:(\\d+)\\$)?([s%])"); - public static final int MAX_DEPTH = 12; + public static final long MAX_TIME = 100; // this is actually more than we need public static final Map ansiMap = new HashMap<>(); static { @@ -87,7 +87,8 @@ public class ComponentUtilities { } private ParseType type; - private int depth = 0; + + private long parseStartTime = System.currentTimeMillis(); private String lastStyle = ""; @@ -96,7 +97,7 @@ public class ComponentUtilities { private String stringify (Component message, ParseType type) { this.type = type; - if (depth > MAX_DEPTH) return ""; + if (System.currentTimeMillis() > parseStartTime + MAX_TIME) return ""; try { final StringBuilder builder = new StringBuilder(); @@ -111,7 +112,7 @@ public class ComponentUtilities { for (Component child : message.children()) { final ComponentParser parser = new ComponentParser(); parser.lastStyle = lastStyle + color + style; - parser.depth = depth; + parser.parseStartTime = parseStartTime; parser.isSubParsing = true; builder.append(parser.stringify(child, type)); } @@ -294,7 +295,7 @@ public class ComponentUtilities { // is INTENTIONAL and is a FEATURE int i = 0; while (matcher.find()) { - depth++; + parseStartTime++; if (matcher.group().equals("%%")) { matcher.appendReplacement(sb, "%"); } else { @@ -307,7 +308,7 @@ public class ComponentUtilities { final ComponentParser parser = new ComponentParser(); parser.lastStyle = lastStyle + color + style; - parser.depth = depth; + parser.parseStartTime = parseStartTime; parser.isSubParsing = true; matcher.appendReplacement(