again
This commit is contained in:
parent
3fad481e1c
commit
17d9868ec7
1 changed files with 19 additions and 9 deletions
|
@ -165,20 +165,25 @@ function parseMinecraftMessage(component) {
|
|||
|
||||
if (comp.translate) {
|
||||
let translateString = lang[comp.translate] || comp.translate;
|
||||
|
||||
if (comp.with) {
|
||||
const withArgs = comp.with.map(arg => extractText(arg));
|
||||
|
||||
withArgs.forEach((arg, index) => {
|
||||
const regex = new RegExp(`%${index + 1}\\$s`, 'g');
|
||||
if (translateString.length + formatfunction(comp, arg).length > 2048) return 'Translate Crash'; // Anti translate Crash
|
||||
translateString = translateString.replace(regex, formatfunction(comp, arg));
|
||||
const formattedArg = formatfunction(comp, arg);
|
||||
if (translateString.length + formattedArg.length > 2048) return text += 'Translate Crash';
|
||||
translateString = translateString.replace(regex, formattedArg);
|
||||
});
|
||||
|
||||
let usedReplacements = 0;
|
||||
|
||||
translateString = translateString.replace(/%s/g, () => {
|
||||
if (usedReplacements < withArgs.length) {
|
||||
if (translateString.length + formatfunction(comp, withArgs[usedReplacements++]).length > 2048) return 'Translate Crash'; // Anti translate Crash
|
||||
return formatfunction(comp, withArgs[usedReplacements++]);
|
||||
const formattedArg = formatfunction(comp, withArgs[usedReplacements]);
|
||||
if (translateString.length + formattedArg.length > 2048) return 'Translate Crash';
|
||||
usedReplacements++;
|
||||
return formattedArg;
|
||||
}
|
||||
return "%s";
|
||||
});
|
||||
|
@ -186,7 +191,7 @@ function parseMinecraftMessage(component) {
|
|||
|
||||
text += translateString;
|
||||
}
|
||||
|
||||
|
||||
text = parseMinecraftColor(comp.color) + parseMinecraftFormat(comp) + text + ansiFormatCodes['reset'];
|
||||
return text;
|
||||
}
|
||||
|
@ -224,20 +229,25 @@ function parseMinecraftMessageNoColor(component) {
|
|||
|
||||
if (comp.translate) {
|
||||
let translateString = lang[comp.translate] || comp.translate;
|
||||
|
||||
if (comp.with) {
|
||||
const withArgs = comp.with.map(arg => extractText(arg));
|
||||
|
||||
withArgs.forEach((arg, index) => {
|
||||
const regex = new RegExp(`%${index + 1}\\$s`, 'g');
|
||||
if (translateString.length + arg.length > 2048) return 'Translate Crash'; // Anti translate Crash
|
||||
translateString = translateString.replace(regex, arg);
|
||||
const formattedArg = arg;
|
||||
if (translateString.length + formattedArg.length > 2048) return 'Translate Crash';
|
||||
translateString = translateString.replace(regex, formattedArg);
|
||||
});
|
||||
|
||||
let usedReplacements = 0;
|
||||
|
||||
translateString = translateString.replace(/%s/g, () => {
|
||||
if (usedReplacements < withArgs.length) {
|
||||
if (translateString.length + withArgs[usedReplacements++].length > 2048) return 'Translate Crash'; // Anti translate Crash
|
||||
return withArgs[usedReplacements++];
|
||||
const formattedArg = withArgs[usedReplacements];
|
||||
if (translateString.length + formattedArg.length > 2048) return 'Translate Crash';
|
||||
usedReplacements++;
|
||||
return formattedArg;
|
||||
}
|
||||
return "%s";
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue