diff --git a/src/window/components/console/console.js b/src/window/components/console/console.js index add8e53..f549b0d 100644 --- a/src/window/components/console/console.js +++ b/src/window/components/console/console.js @@ -1,6 +1,5 @@ const { getCurrentWindow } = require('electron').remote; const { ipcRenderer } = require('electron'); - const Titlebar = require('../titlebar/titlebar'); const Menu = require('../menu/menu'); const Players = require('../players/players'); diff --git a/src/window/utils/color-parser.js b/src/window/utils/color-parser.js index b01ad21..dab2b21 100644 --- a/src/window/utils/color-parser.js +++ b/src/window/utils/color-parser.js @@ -1,4 +1,13 @@ +/** + * Regular expression for checking colored strings. + * @type {RegExp} + */ const colorRegex = /\[(\w)+]/g; + +/** + * Regular expression for checking HEX colors. + * @type {RegExp} + */ const hexRegex = /[0-9A-Fa-f]{6}/; /** @@ -67,8 +76,11 @@ function parseName(rawName) { } const coloredStrings = []; + let coloring = false; + for (let i = 0; i < name.length; i++) { if (name.charAt(i) === '[' && i !== name.length - 1 && name.charAt(i + 1) !== '[' && (i === 0 || name.charAt(i - 1) !== '[')) { + coloring = true; const next = name.substring(i); const result = checkColor(next); for (let j = 0; j < result.str.length; j++) { @@ -82,6 +94,9 @@ function parseName(rawName) { ? getHexColoredString(result.str, result.color) : getColoredString(result.str, result.color); coloredStrings.push(coloredString); + } else if (!coloring) { + const whiteString = getColoredString(name.charAt(i), 'white'); + coloredStrings.push(whiteString); } } return `
${coloredStrings.join('')}
`; diff --git a/src/window/window.html b/src/window/window.html index 8ba1cb6..7da7aea 100644 --- a/src/window/window.html +++ b/src/window/window.html @@ -85,8 +85,15 @@
- - + +