From d23094ccfdf4f6070ff761e71b2a244e46f5e510 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Wed, 11 Sep 2024 01:35:15 -0400 Subject: [PATCH] Command event overhaul --- plugins/chatlog.js | 4 ++-- plugins/command.js | 8 ++++++-- util/Command.js | 1 + util/ConsoleCommand.js | 1 + 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/plugins/chatlog.js b/plugins/chatlog.js index 8f432a3..5160f24 100755 --- a/plugins/chatlog.js +++ b/plugins/chatlog.js @@ -25,8 +25,8 @@ module.exports = { b.on('plainchat', (msg, type) => { if (!settings.disableLogging && !settings.disableChatLogging) chatlog(`chat_${b.host.host}_${b.host.port}`, `[${type}] ${msg}`) }) - b.on('command', (name, uuid, text) => { - if (!settings.disableLogging && !settings.disableCommandLogging) chatlog(`cmd_${b.host.host}_${b.host.port}`, `${name} (${uuid}): ${text}`) + b.on('command', c => { + if (!settings.disableLogging && !settings.disableCommandLogging) chatlog(`cmd_${b.host.host}_${b.host.port}`, `${c.username} (${c.uuid}): ${c.command}`) }) } } diff --git a/plugins/command.js b/plugins/command.js index db8994f..52a08c5 100755 --- a/plugins/command.js +++ b/plugins/command.js @@ -42,7 +42,11 @@ module.exports = { if (verify > 0) { text = cmd.slice(0, cmd.length - 1).join(' ') } - b.emit('command', name, uuid, text, prefix) + + const commandClass = new Command(uuid, name, nickname, text, msgType, prefix, b, verify, userSettings); + b.emit("command",commandClass) + if(commandClass.cancel === true) return + if (cmds[cmd[0].toLowerCase()]) { const command = cmds[cmd[0].toLowerCase()] const permsN = getMessage(lang, 'command.help.permsNormal') @@ -61,7 +65,7 @@ module.exports = { return } try { - cmds[cmd[0].toLowerCase()].execute(new Command(uuid, name, nickname, text, msgType, prefix, b, verify, userSettings)) + if(commandClass.cancel === false) cmds[cmd[0].toLowerCase()].execute(commandClass) } catch (e) { console.log(e) b.tellraw(uuid, { diff --git a/util/Command.js b/util/Command.js index e86f28a..2af9870 100644 --- a/util/Command.js +++ b/util/Command.js @@ -18,6 +18,7 @@ class Command { this.port = bot.host.port this.serverName = bot.host.options.name this.prefs = prefs + this.cancel = false; if (prefs.lang) { this.lang = prefs.lang } else { diff --git a/util/ConsoleCommand.js b/util/ConsoleCommand.js index 6d2e631..0b7e59e 100644 --- a/util/ConsoleCommand.js +++ b/util/ConsoleCommand.js @@ -22,6 +22,7 @@ class ConsoleCommand { this.host = '' this.port = '3' this.serverName = `${version.botName} Console` + this.cancel = false; this.lang = settings.defaultLang this.colors = settings.colors }