From c91944e36a258a37eda105747a435e6f8ff5a491 Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Tue, 12 Apr 2022 06:31:54 -0500 Subject: [PATCH] Fix some command utils --- scripts/server/command.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/scripts/server/command.js b/scripts/server/command.js index e88b125d..8472e82d 100644 --- a/scripts/server/command.js +++ b/scripts/server/command.js @@ -534,12 +534,16 @@ function loadCommands() { // =========================================================================== function addAllCommandHandlers() { + let commandCount = 0; for(let i in serverCommands) { for(let j in serverCommands[i]) { - logToConsole(LOG_VERBOSE, `Adding command handler for ${i}/${j} - ${serverCommands[i][j].command}`); + logToConsole(LOG_DEBUG, `[VRR.Command] Adding command handler for ${i} - ${serverCommands[i][j].command}`); addCommandHandler(serverCommands[i][j].command, processPlayerCommand); + commandCount++; } } + + logToConsole(LOG_INFO, `[VRR.Command] ${commandCount} command handlers added!`); } // =========================================================================== @@ -782,7 +786,7 @@ function getAllCommandsInSingleArray() { let tempCommands = []; for(let i in serverCommands) { for(let j in serverCommands[i]) { - tempCommands.push(serverCommands[i][j]); + tempCommands.push(serverCommands[i][j].command); } } @@ -791,10 +795,12 @@ function getAllCommandsInSingleArray() { // =========================================================================== -function getAllCommandsInGroupInSingleArray(groupName) { +function getAllCommandsInGroupInSingleArray(groupName, staffFlag = "None") { let tempCommands = []; for(let i in serverCommands[groupName]) { - tempCommands.push(serverCommands[groupName][i]); + if(getCommandRequiredPermissions(serverCommands[groupName][i].command) == 0) { + tempCommands.push(serverCommands[groupName][i].command); + } } return tempCommands; @@ -806,9 +812,9 @@ function getAllCommandsForStaffFlagInSingleArray(staffFlagName) { let tempCommands = []; for(let i in serverCommands) { for(let j in serverCommands[i]) { - if(serverCommands[i][j].requiredStaffFlags != "0") { - if(hasBitFlag(serverCommands[i][j].requiredStaffFlags, getStaffFlagValue(staffFlagName))) { - tempCommands.push(serverCommands[i][j]); + if(getCommandRequiredPermissions(serverCommands[i][j].command) != 0) { + if(hasBitFlag(getCommandRequiredPermissions(serverCommands[i][j].command), getStaffFlagValue(staffFlagName))) { + tempCommands.push(serverCommands[i][j].command); } } }