removed something

This commit is contained in:
Yaode_owo 2024-10-30 11:52:33 -04:00
parent 66cd34974f
commit 8d091e9127

View file

@ -442,124 +442,4 @@ function parseMinecraftMessageNoColor(component) {
return extractText(component);
}
function kickparser(component) {
if (component === undefined) return;
if (typeof component === "string") return component;
function kickparserText(comp) {
let text = '';
if (comp.text && typeof comp.text === 'string' || typeof comp.text === 'number') {
text += comp.text;
}
if (comp[""] && typeof comp[""] === 'string' || typeof comp[""] === 'number') {
text += comp[""];
}
if (comp && typeof comp === 'string' || typeof comp === 'number') {
return comp;
}
if (comp.translate) {
if (comp.fallback && !lang[comp.translate]) return text += comp.fallback;
let translateString = lang[comp.translate] || comp.translate;
let DefaultTranslateString = lang[comp.translate] || comp.translate;
let DefaultMsg = false;
if (comp.with) {
const withArgs = comp.with.map(arg => kickparserText(arg));
let usedReplacements = 0;
translateString = translateString.replace(/thing__placeholder__/g, 'default_thing__placeholder__');
translateString = translateString.replace(/%s/g, (match, offset, string) => {
if (offset > 0 && string[offset - 1] === '%') {
return 's';
}
if (usedReplacements < withArgs.length) {
if (translateString.length + withArgs[usedReplacements].length > 2048) return 'Translate Crash'; // Prevent translate crash
return `thing__placeholder__${usedReplacements++}`;
}
DefaultMsg = true;
return "%s";
});
translateString = translateString.replace(/%(-?\d+)\$s/g, (match, index, stringindex, string) => {
const argIndex = parseInt(index, 10) - 1;
if (argIndex < 0 || argIndex >= withArgs.length) {
DefaultMsg = true;
return match;
}
if (stringindex > 0 && string[stringindex - 1] === '%') {
return match;
}
if (translateString.length + withArgs[argIndex].length > 2048) return 'Translate Crash'; // Prevent translate crash
return `thing__placeholder__${argIndex}`;
});
for (let i = 0; i < withArgs.length; i++) {
if (translateString.length + withArgs[i].length > 2048) return 'Translate Crash'; // Prevent translate crash
translateString = translateString.replace(new RegExp(`thing__placeholder__${i}`, 'g'), (match) => {
const formattedArg = withArgs[i];
return formattedArg;
});
}
translateString = translateString.replace(/default_thing__placeholder__/g, 'thing__placeholder__');
}
if (DefaultMsg) {
text += DefaultTranslateString;
} else {
text += translateString;
}
}
if (comp.extra) {
if (!Array.isArray(comp.extra)) comp.extra = [comp.extra]
comp.extra.forEach(subComp => {
text += kickparserText(subComp);
});
}
return text;
}
return kickparserText(simplify(component));
}
function cboutput(component) {
if (component === undefined) return;
function extractText(comp) {
let text = '';
if (comp.text && typeof comp.text === 'string' || typeof comp.text === 'number') {
text += comp.text;
}
if (comp && typeof comp === 'string' || typeof comp === 'number') {
return comp;
}
if (comp.extra) {
if (!Array.isArray(comp.extra)) comp.extra = [comp.extra]
comp.extra.forEach(subComp => {
text += formatfunction(comp, extractText(subComp));
});
}
text = parseMinecraftColor(comp.color) + parseMinecraftFormat(comp) + text + ansiFormatCodes['reset'];
return text;
}
return extractText(component) + ansiFormatCodes['reset'];
}
module.exports = { inject, kickparser, cboutput };
module.exports = { inject };