diff --git a/build-number.txt b/build-number.txt index 7939e3d3..fdbec449 100644 --- a/build-number.txt +++ b/build-number.txt @@ -1 +1 @@ -1458 \ No newline at end of file +1459 \ 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 3147c80c..83949652 100644 --- a/src/main/java/me/chayapak1/chomens_bot/util/ComponentUtilities.java +++ b/src/main/java/me/chayapak1/chomens_bot/util/ComponentUtilities.java @@ -301,29 +301,31 @@ public class ComponentUtilities { } else { final String idxStr = matcher.group(1); - int idx = idxStr == null ? i++ : (Integer.parseInt(idxStr) - 1); + try { + int idx = idxStr == null ? i++ : (Integer.parseInt(idxStr) - 1); - if (idx >= 0 && idx < message.arguments().size()) { - final ComponentParser parser = new ComponentParser(); + if (idx >= 0 && idx < message.arguments().size()) { + final ComponentParser parser = new ComponentParser(); - parser.lastStyle = lastStyle + color + style; - parser.depth = depth; - parser.isSubParsing = true; + parser.lastStyle = lastStyle + color + style; + parser.depth = depth; + parser.isSubParsing = true; - matcher.appendReplacement( - sb, - Matcher.quoteReplacement( - parser.stringify( - message.arguments() - .get(idx) - .asComponent(), - type - ) + lastStyle + color + style // IMPORTANT!!!! - ) - ); - } else { - matcher.appendReplacement(sb, ""); - } + matcher.appendReplacement( + sb, + Matcher.quoteReplacement( + parser.stringify( + message.arguments() + .get(idx) + .asComponent(), + type + ) + lastStyle + color + style // IMPORTANT!!!! + ) + ); + } else { + matcher.appendReplacement(sb, ""); + } + } catch (NumberFormatException ignored) {} // is this a good idea? } }