From 1b036db6e7c6a791e1a40de5b722e08fcef4506d Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Sat, 23 Jan 2021 13:33:29 -0600 Subject: [PATCH] Add null check to player display for console util --- scripts/server/utilities.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/scripts/server/utilities.js b/scripts/server/utilities.js index 5bd3a85a..35517fa7 100644 --- a/scripts/server/utilities.js +++ b/scripts/server/utilities.js @@ -1801,6 +1801,9 @@ function arrayBufferToString(arrayBuffer) { // ------------------------------------------------------------------------- function getPlayerDisplayForConsole(client) { + if(isNull(client)) { + return "(Unknown client)"; + } return `${client.name}[${client.index}]`; } @@ -1945,3 +1948,21 @@ function applyOffsetToVector3(position, position2) { } // ------------------------------------------------------------------------- + +function getPluralForm(name) { + return name; +} + +// ------------------------------------------------------------------------- + +function removeColoursFromString(str) { + let matchRegex = /#([a-f0-9]{3}|[a-f0-9]{4}(?:[a-f0-9]{2}){0,2})\b/gi; + let matchedHexes = str.match(matchRegex); + for(let i in matchHex) { + str.replace(matchedHexes, `{${i}}`); + } + + return [str, matchedHexes]; +} + +// ------------------------------------------------------------------------- \ No newline at end of file