Update main/chatparser.js
This commit is contained in:
parent
9c905f83ee
commit
2b97f60c51
1 changed files with 29 additions and 19 deletions
|
@ -543,6 +543,14 @@ function parseMinecraftMessage(component) {
|
|||
let NowFormat = parseMinecraftFormat(comp);
|
||||
|
||||
if (VaildText(comp)) { // Idk, but it work atleast.
|
||||
if (NowFormat.have || prevFormat.have) {
|
||||
if (NowFormat.have) {
|
||||
text += NowFormat.format
|
||||
shouldReset = true;
|
||||
} else if (prevFormat.have) {
|
||||
text += prevFormat.format;
|
||||
}
|
||||
}
|
||||
if (NowColor.have || prevColor.have) {
|
||||
if (NowColor.have) {
|
||||
text += NowColor.color;
|
||||
|
@ -553,14 +561,6 @@ function parseMinecraftMessage(component) {
|
|||
text += ansiMap['white'];
|
||||
}
|
||||
}
|
||||
if (NowFormat.have || prevFormat.have) {
|
||||
if (NowFormat.have) {
|
||||
text += NowFormat.format
|
||||
shouldReset = true;
|
||||
} else if (prevFormat.have) {
|
||||
text += prevFormat.format;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof comp.text === 'string' || typeof comp.text === 'number') {
|
||||
|
@ -581,7 +581,7 @@ function parseMinecraftMessage(component) {
|
|||
if (comp.fallback && !lang[comp.translate]) fallbackMsg = true;
|
||||
|
||||
if (comp.with && !fallbackMsg) {
|
||||
const withArgs = comp.with.map(arg => extractText(arg, NowColor.have ? NowColor : prevColor, NowFormat.have ? NowFormat : prevFormat) + `${VaildText(comp) ? NowColor.have ? NowColor.color : prevColor.color : ""}${VaildText(comp) ? NowFormat.have ? NowFormat.format : prevFormat.format : ""}`);
|
||||
const withArgs = comp.with.map(arg => extractText(arg, NowColor.have ? NowColor : prevColor, NowFormat.have ? NowFormat : prevFormat) + `${VaildText(comp) ? NowFormat.have ? NowFormat.format : prevFormat.format : ""}${VaildText(comp) ? NowColor.have ? NowColor.color : prevColor.color : ""}`);
|
||||
let usedReplacements = 0;
|
||||
translateString = translateString.replace(/thing__placeholder__/g, 'default_thing__placeholder__');
|
||||
|
||||
|
@ -636,7 +636,7 @@ function parseMinecraftMessage(component) {
|
|||
if (comp.extra) {
|
||||
if (!Array.isArray(comp.extra)) comp.extra = [comp.extra]
|
||||
comp.extra.forEach(subComp => {
|
||||
text += extractText(subComp, NowColor.have ? NowColor : prevColor, NowFormat.have ? NowFormat : prevFormat) + `${VaildText(comp) ? NowColor.have ? NowColor.color : prevColor.color : ""}${VaildText(comp) ? NowFormat.have ? NowFormat.format : prevFormat.format : ""}`;
|
||||
text += extractText(subComp, NowColor.have ? NowColor : prevColor, NowFormat.have ? NowFormat : prevFormat) + `${VaildText(comp) ? NowFormat.have ? NowFormat.format : prevFormat.format : ""}${VaildText(comp) ? NowColor.have ? NowColor.color : prevColor.color : ""}`;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -752,12 +752,25 @@ function cboutput(component) {
|
|||
let NowColor = parseMinecraftColor(comp?.color);
|
||||
let NowFormat = parseMinecraftFormat(comp);
|
||||
|
||||
if ((comp || comp !== "") && (comp.text || comp.text !== "")) {
|
||||
text += NowColor.have ? NowColor.color : prevColor.have ? prevColor.color : ansiMap['white'];
|
||||
if (VaildText(comp)) { // Idk, but it work atleast.
|
||||
if (NowFormat.have || prevFormat.have) {
|
||||
text += NowFormat.have ? NowFormat.format : prevFormat.format;
|
||||
shouldReset = true;
|
||||
};
|
||||
if (NowFormat.have) {
|
||||
text += NowFormat.format
|
||||
shouldReset = true;
|
||||
} else if (prevFormat.have) {
|
||||
text += prevFormat.format;
|
||||
}
|
||||
}
|
||||
if (NowColor.have || prevColor.have) {
|
||||
if (NowColor.have) {
|
||||
text += NowColor.color;
|
||||
shouldReset = true;
|
||||
} else if (prevColor.have) {
|
||||
text += prevColor.color;
|
||||
} else {
|
||||
text += ansiMap['white'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof comp.text === 'string' || typeof comp.text === 'number') {
|
||||
|
@ -770,15 +783,12 @@ function cboutput(component) {
|
|||
if (comp.extra) {
|
||||
if (!Array.isArray(comp.extra)) comp.extra = [comp.extra]
|
||||
comp.extra.forEach(subComp => {
|
||||
text += extractText(subComp, NowColor.have === true ? NowColor : prevColor, NowFormat.have === true ? NowFormat : prevFormat);
|
||||
text += extractText(subComp, NowColor.have ? NowColor : prevColor, NowFormat.have ? NowFormat : prevFormat) + `${VaildText(comp) ? NowFormat.have ? NowFormat.format : prevFormat.format : ""}${VaildText(comp) ? NowColor.have ? NowColor.color : prevColor.color : ""}`;
|
||||
});
|
||||
}
|
||||
|
||||
if (shouldReset) {
|
||||
text += ansiMap['reset']
|
||||
} else {
|
||||
text += prevColor.color || ansiMap['white'];
|
||||
text += prevFormat.format || '';
|
||||
}
|
||||
|
||||
return text;
|
||||
|
|
Loading…
Reference in a new issue