diff --git a/main/chatparser.js b/main/chatparser.js index 3992008..ea5ebfe 100644 --- a/main/chatparser.js +++ b/main/chatparser.js @@ -1,7 +1,7 @@ // Don't change this or you gay. -// Version: 1.0 +// Version: 1.1 -const lang = require("./en_us.json"); // translate message +const lang = require("../util/en_us.json"); // translate message function uuidFromIntArray (arr) { const buf = Buffer.alloc(16) @@ -283,12 +283,13 @@ function parseMinecraftMessage(component) { } if (comp.translate) { - if (comp.fallback && !lang[comp.translate]) return text += formatfunction(comp, comp.fallback); let translateString = lang[comp.translate] || comp.translate; let DefaultTranslateString = lang[comp.translate] || comp.translate; let DefaultMsg = false; + let fallbackMsg = false; + if (comp.fallback && !lang[comp.translate]) fallbackMsg = true; - if (comp.with) { + if (comp.with && !fallbackMsg) { const withArgs = comp.with.map(arg => extractText(arg)); let usedReplacements = 0; translateString = translateString.replace(/thing__placeholder__/g, 'default_thing__placeholder__'); @@ -334,7 +335,9 @@ function parseMinecraftMessage(component) { if (DefaultMsg) { text += formatfunction(comp, DefaultTranslateString); - } else { + } else if (fallbackMsg) { + text += formatfunction(comp, comp.fallback); + } else { text += formatfunction(comp, translateString); } } @@ -346,11 +349,9 @@ function parseMinecraftMessage(component) { }); } - text = parseMinecraftColor(comp.color) + parseMinecraftFormat(comp) + text + ansiFormatCodes['reset']; - - return text; + return parseMinecraftColor(comp.color) + parseMinecraftFormat(comp) + text + ansiFormatCodes['reset']; } - + return extractText(component) + ansiFormatCodes['reset']; } @@ -372,12 +373,13 @@ function parseMinecraftMessageNoColor(component) { } 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) { + let fallbackMsg = false; + if (comp.fallback && !lang[comp.translate]) fallbackMsg = true; + + if (comp.with && !fallbackMsg) { const withArgs = comp.with.map(arg => extractText(arg)); let usedReplacements = 0; @@ -424,7 +426,9 @@ function parseMinecraftMessageNoColor(component) { if (DefaultMsg) { text += DefaultTranslateString; - } else { + } else if (fallbackMsg) { + text += comp.fallback; + } else { text += translateString; } }