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) {
|
if (comp.translate) {
|
||||||
let translateString = lang[comp.translate] || comp.translate;
|
let translateString = lang[comp.translate] || comp.translate;
|
||||||
|
|
||||||
if (comp.with) {
|
if (comp.with) {
|
||||||
const withArgs = comp.with.map(arg => extractText(arg));
|
const withArgs = comp.with.map(arg => extractText(arg));
|
||||||
|
|
||||||
withArgs.forEach((arg, index) => {
|
withArgs.forEach((arg, index) => {
|
||||||
const regex = new RegExp(`%${index + 1}\\$s`, 'g');
|
const regex = new RegExp(`%${index + 1}\\$s`, 'g');
|
||||||
if (translateString.length + formatfunction(comp, arg).length > 2048) return 'Translate Crash'; // Anti translate Crash
|
const formattedArg = formatfunction(comp, arg);
|
||||||
translateString = translateString.replace(regex, formatfunction(comp, arg));
|
if (translateString.length + formattedArg.length > 2048) return text += 'Translate Crash';
|
||||||
|
translateString = translateString.replace(regex, formattedArg);
|
||||||
});
|
});
|
||||||
|
|
||||||
let usedReplacements = 0;
|
let usedReplacements = 0;
|
||||||
|
|
||||||
translateString = translateString.replace(/%s/g, () => {
|
translateString = translateString.replace(/%s/g, () => {
|
||||||
if (usedReplacements < withArgs.length) {
|
if (usedReplacements < withArgs.length) {
|
||||||
if (translateString.length + formatfunction(comp, withArgs[usedReplacements++]).length > 2048) return 'Translate Crash'; // Anti translate Crash
|
const formattedArg = formatfunction(comp, withArgs[usedReplacements]);
|
||||||
return formatfunction(comp, withArgs[usedReplacements++]);
|
if (translateString.length + formattedArg.length > 2048) return 'Translate Crash';
|
||||||
|
usedReplacements++;
|
||||||
|
return formattedArg;
|
||||||
}
|
}
|
||||||
return "%s";
|
return "%s";
|
||||||
});
|
});
|
||||||
|
@ -224,20 +229,25 @@ function parseMinecraftMessageNoColor(component) {
|
||||||
|
|
||||||
if (comp.translate) {
|
if (comp.translate) {
|
||||||
let translateString = lang[comp.translate] || comp.translate;
|
let translateString = lang[comp.translate] || comp.translate;
|
||||||
|
|
||||||
if (comp.with) {
|
if (comp.with) {
|
||||||
const withArgs = comp.with.map(arg => extractText(arg));
|
const withArgs = comp.with.map(arg => extractText(arg));
|
||||||
|
|
||||||
withArgs.forEach((arg, index) => {
|
withArgs.forEach((arg, index) => {
|
||||||
const regex = new RegExp(`%${index + 1}\\$s`, 'g');
|
const regex = new RegExp(`%${index + 1}\\$s`, 'g');
|
||||||
if (translateString.length + arg.length > 2048) return 'Translate Crash'; // Anti translate Crash
|
const formattedArg = arg;
|
||||||
translateString = translateString.replace(regex, arg);
|
if (translateString.length + formattedArg.length > 2048) return 'Translate Crash';
|
||||||
|
translateString = translateString.replace(regex, formattedArg);
|
||||||
});
|
});
|
||||||
|
|
||||||
let usedReplacements = 0;
|
let usedReplacements = 0;
|
||||||
|
|
||||||
translateString = translateString.replace(/%s/g, () => {
|
translateString = translateString.replace(/%s/g, () => {
|
||||||
if (usedReplacements < withArgs.length) {
|
if (usedReplacements < withArgs.length) {
|
||||||
if (translateString.length + withArgs[usedReplacements++].length > 2048) return 'Translate Crash'; // Anti translate Crash
|
const formattedArg = withArgs[usedReplacements];
|
||||||
return withArgs[usedReplacements++];
|
if (translateString.length + formattedArg.length > 2048) return 'Translate Crash';
|
||||||
|
usedReplacements++;
|
||||||
|
return formattedArg;
|
||||||
}
|
}
|
||||||
return "%s";
|
return "%s";
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue