diff --git a/src/main/java/land/chipmunk/chipmunkbot/chat/ComponentUtilities.java b/src/main/java/land/chipmunk/chipmunkbot/chat/ComponentUtilities.java index bd0042a..d746295 100644 --- a/src/main/java/land/chipmunk/chipmunkbot/chat/ComponentUtilities.java +++ b/src/main/java/land/chipmunk/chipmunkbot/chat/ComponentUtilities.java @@ -70,7 +70,7 @@ public class ComponentUtilities { public static String stringifyPartially (TranslatableComponent message) { String format = getOrReturnKey(language, message.key()); - // totallynotskidded™️ from HBot + // totallynotskidded™️ from HBot (and changed a bit) Matcher matcher = ARG_PATTERN.matcher(format); StringBuffer sb = new StringBuffer(); @@ -80,8 +80,8 @@ public class ComponentUtilities { matcher.appendReplacement(sb, "%"); } else { String idxStr = matcher.group(1); - int idx = idxStr == null ? i++ : Integer.parseInt(idxStr); - if (idx < message.args().size()) { + int idx = (idxStr == null ? i++ : Integer.parseInt(idxStr)) - 1; + if (idx >= 0 && idx < message.args().size()) { matcher.appendReplacement(sb, Matcher.quoteReplacement( stringify(message.args().get(idx)) )); } else { matcher.appendReplacement(sb, "");