forked from chipmunkmc/chipmunkbot
Fixes relating to translation formats with %index$s
Offset the index as needed and fix OOB indexes like in `%0$s` (the notchian client does not handle oob indexes correctly but that just means my code is better 😎)
This commit is contained in:
parent
ada80cf431
commit
d0ea9a159d
1 changed files with 3 additions and 3 deletions
|
@ -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, "");
|
||||
|
|
Loading…
Reference in a new issue