From 8bcd8b0db9ed14610b5a7ad65665163aa5d8bef9 Mon Sep 17 00:00:00 2001 From: ChomeNS Date: Wed, 17 Aug 2022 18:47:22 +0700 Subject: [PATCH] config.core.useChat to config.useChat --- config.json | 2 +- plugins/core.js | 62 ++++++++++++++++++++++++++----------------------- 2 files changed, 34 insertions(+), 30 deletions(-) diff --git a/config.json b/config.json index fa806ec..e71554e 100644 --- a/config.json +++ b/config.json @@ -4,8 +4,8 @@ "cbot ", "/cbot " ], + "useChat": true, "core": { - "useChat": true, "layers": 1 }, "discord": { diff --git a/plugins/core.js b/plugins/core.js index 5b906d9..d3d68c1 100644 --- a/plugins/core.js +++ b/plugins/core.js @@ -13,37 +13,41 @@ function inject(bot) { return position.x >= core.start.x && position.x <= core.end.x && position.y >= core.start.y && position.y <= core.end.y && position.z >= core.start.z && position.z <= core.end.z; }, run(command) { - if (config.core.useChat && command.startsWith('minecraft:tellraw @a ')) { - bot.chat(chatMessage.fromNotch(command.replace('minecraft:tellraw @a ', '')).toMotd().replaceAll('§', '&')); + try { + if (config.useChat && command.startsWith('minecraft:tellraw @a ') && !command.includes('Console') && !command.includes('Discord')) { + bot.chat(chatMessage.fromNotch(command.replace('minecraft:tellraw @a ', '')).toMotd().replaceAll('§', '&')); + return; + } + + relativePosition.x++; + + if (relativePosition.x >= 16) { + relativePosition.x = 0; + relativePosition.y++; + } + + if (relativePosition.y >= layers) { + relativePosition.y = 0; + relativePosition.z++; + } + + if (relativePosition.z >= 16) { + relativePosition.z = 0; + } + + bot.write('update_command_block', { + location: { + x: core.start.x + relativePosition.x, + y: core.start.y + relativePosition.y, + z: core.start.z + relativePosition.z, + }, + command: command.substring(0, 32767), + mode: 1, + flags: 0b100, + }); + } catch (e) { return; } - - relativePosition.x++; - - if (relativePosition.x >= 16) { - relativePosition.x = 0; - relativePosition.y++; - } - - if (relativePosition.y >= layers) { - relativePosition.y = 0; - relativePosition.z++; - } - - if (relativePosition.z >= 16) { - relativePosition.z = 0; - } - - bot.write('update_command_block', { - location: { - x: core.start.x + relativePosition.x, - y: core.start.y + relativePosition.y, - z: core.start.z + relativePosition.z, - }, - command: command.substring(0, 32767), - mode: 1, - flags: 0b100, - }); }, fillCore(useCore) { const fillCommand = `/minecraft:fill ${core.start.x} ${core.start.y} ${core.start.z} ${core.end.x} ${core.end.y} ${core.end.z} command_block{CustomName:'{"text":"ChomeNS Bot Core","color":"yellow"}'}`;