fix %-n$s

This commit is contained in:
Yaode_owo 2024-10-18 16:23:37 -04:00
parent e616214c72
commit 2e1de26f34

View file

@ -235,9 +235,9 @@ function parseMinecraftMessage(component) {
return "%s";
});
translateString = translateString.replace(/%(\d+)\$s/g, (match, index, stringindex, string) => {
const argIndex = parseInt(index) - 1;
translateString = translateString.replace(/%(-?\d+)\$s/g, (match, index, stringindex, string) => {
const argIndex = index - 1;
if (argIndex < 0 || argIndex >= withArgs.length) {
DefaultMsg = true;
return match;
@ -320,13 +320,13 @@ function parseMinecraftMessageNoColor(component) {
});
translateString = translateString.replace(/%(\d+)\$s/g, (match, index, stringindex, string) => {
const argIndex = parseInt(index) - 1;
const argIndex = index - 1;
if (argIndex < 0 || argIndex >= withArgs.length) {
DefaultMsg = true;
return match;
}
if (stringindex > 0 && string[stringindex - 1] === '%') {
return match;
}