From a140a2d12eff117581e2677a3aed82f97ea212dc Mon Sep 17 00:00:00 2001 From: Parker2991 Date: Thu, 14 Nov 2024 09:25:22 -0500 Subject: [PATCH] v6.1.1-1 build: 1150 added a new core refill method to where the bot refills its core via a command block but made the method configurable, this was supposed to be in v6.1.1 originally --- package-lock.json | 4 +-- src/commands/public/wiki.js | 4 +-- src/commands/trusted/rtp.js | 2 +- src/data/default_config.yml | 6 +++- src/data/filter.json | 1 - src/index.js | 4 +++ src/modules/command_core.js | 60 ++++++++++++++++++++++++++++++++-- src/modules/command_manager.js | 4 +-- src/util/checks.js | 4 +-- 9 files changed, 75 insertions(+), 14 deletions(-) delete mode 100644 src/data/filter.json diff --git a/package-lock.json b/package-lock.json index e354e05..08d28b6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,9 +1,9 @@ { "name": "FridayNightFunkinBoyfriendBot", - "version": "v6.1.1", + "version": "v6.1.1-1", "lockfileVersion": 3, "requires": true, - "build": "1145", + "build": "1150", "codename": "", "url": "https://code.chipmunk.land/Parker2991/FridayNightFunkinBoyfriendBot", "packages": { diff --git a/src/commands/public/wiki.js b/src/commands/public/wiki.js index 59ea791..db3b688 100644 --- a/src/commands/public/wiki.js +++ b/src/commands/public/wiki.js @@ -10,7 +10,7 @@ module.exports = { 'wikipedia' ], usages:[ - "" + "
" ], }, async execute (context) { @@ -23,7 +23,7 @@ module.exports = { bot.tellraw(`@a`, { text: `${summary}`, color: 'gray' }); } catch (error) { if (error.toString() === "pageError: TypeError: Cannot read properties of undefined (reading 'pages')") { - bot.tellraw(`@a`, { text: 'Definition not found!', color: 'dark_red' }) + bot.tellraw(`@a`, { text: 'Article not found!', color: 'dark_red' }) } else { bot.tellraw(`@a`, `${error.toString()}`) } diff --git a/src/commands/trusted/rtp.js b/src/commands/trusted/rtp.js index 7704d14..48ec757 100644 --- a/src/commands/trusted/rtp.js +++ b/src/commands/trusted/rtp.js @@ -3,7 +3,7 @@ const CommandError = require('../../util/command_error') module.exports = { data: { name: 'tpr', - description: 'teleport to a random place', + description: 'teleport to very fucked up coords', trustLevel: 1, aliases: [ 'rtp', diff --git a/src/data/default_config.yml b/src/data/default_config.yml index 66f7eef..e4f1c21 100644 --- a/src/data/default_config.yml +++ b/src/data/default_config.yml @@ -1,17 +1,21 @@ prefixes: - "!" - discord: token: "discord token here" prefix: "!" invite: "discord invite here" + enabled: true roles: trusted: "trusted" admin: "admin" owner: "FNFBoyfriendBot Owner" core: + # core refill methods: + # chat: refill core in chat + # item refill core in a command block placed by the bot name: {"translate":"outOfMemory.message"} + method: 'item' area: start: x: 0 diff --git a/src/data/filter.json b/src/data/filter.json deleted file mode 100644 index fe9d940..0000000 --- a/src/data/filter.json +++ /dev/null @@ -1 +0,0 @@ -[{"ignoreCase":false,"regexed":false,"name":"04928"},{"ignoreCase":false,"regexed":false,"name":"04928"},{"ignoreCase":false,"regexed":false,"name":"04928"},{"ignoreCase":false,"regexed":false,"name":"04928"},{"ignoreCase":false,"regexed":false,"name":"Parker2991"}] \ No newline at end of file diff --git a/src/index.js b/src/index.js index 43259ec..482c5a2 100644 --- a/src/index.js +++ b/src/index.js @@ -16,6 +16,10 @@ try { } catch (e) { console.log(e.stack); } +if (config.core.method !== 'item' && config.core.method !== 'chat') { + config.core.method = 'item'; + console.warn('invalid core method type defaulting to item'); +} const rl = readline.createInterface({ input: process.stdin, output: process.stdout, diff --git a/src/modules/command_core.js b/src/modules/command_core.js index e24f341..0794b70 100644 --- a/src/modules/command_core.js +++ b/src/modules/command_core.js @@ -1,3 +1,4 @@ +const mcData = require('minecraft-data')('1.20.2'); function core (bot, options, config) { let number = 0; bot.core = { @@ -25,7 +26,51 @@ function core (bot, options, config) { it will not refill core until the pos is not NaN instead of tping to a set cords cuz fuck you im not doing that */ - bot.chat.command(`minecraft:fill ${pos.x + start.x} ${pos.y + start.y} ${pos.z + start.z} ${pos.x + end.x} ${pos.y + end.y} ${pos.z + end.z} repeating_command_block{CustomName:'${JSON.stringify(config.core.name)}'}`) + if (config.core.method === 'chat') { + bot.chat.command(`minecraft:fill ${pos.x + start.x} ${pos.y + start.y} ${pos.z + start.z} ${pos.x + end.x} ${pos.y + end.y} ${pos.z + end.z} repeating_command_block{CustomName:'${JSON.stringify(config.core.name)}'}`) + } else if (config.core.method === 'item') { + bot._client.write('set_creative_slot', { + slot: 36, + item: { + present: true, + itemId: mcData.itemsByName.command_block.id, + itemCount: 1, + nbtData: { + } + } + }); + + bot._client.write('block_dig', { + status: 0, + location: { + x: bot.position.x, + y: bot.position.y, + z: bot.position.z + }, + face: 0 + }); + + bot._client.write('block_place', { + hand: 0, + location: { + x: bot.position.x, + y: bot.position.y, + z: bot.position.z + }, + direction: 0, + cursorX: 0.1, + cursorY: 0, + cursorZ: 0.1, + insideBlock: false + }); + + bot._client.write('update_command_block', { + location: bot.position, + command: `minecraft:fill ${pos.x + start.x} ${pos.y + start.y} ${pos.z + start.z} ${pos.x + end.x} ${pos.y + end.y} ${pos.z + end.z} repeating_command_block{CustomName:'${JSON.stringify(config.core.name)}'}`, + flags: 5, + mode: 1 + }) + } }, move (pos = bot.position) { @@ -76,7 +121,7 @@ function core (bot, options, config) { } else { bot._client.write('update_command_block', { command: command.substring(0, 32767), location, mode: 1, flags: 0b100 }); bot._client.write('query_block_nbt', ({ location: location, transactionId: eee})); - bot.core.incrementCurrentBlock() + bot.core.incrementCurrentBlock(); } }, } @@ -85,6 +130,15 @@ function core (bot, options, config) { bot.on('move', () => { bot.core.move(bot.position) }) -} + bot.on('packet.block_change', (data) => { +// console.log('data pos ' + JSON.stringify(data.location)) +// console.log('core pos ' +JSON.stringify(bot.core.position)); + if (data.type === 0) { +// console.log('data pos ' + JSON.stringify(data.location)); +// console.log('core position ' + JSON.stringify(bot.core.position)); +// bot.core.refill(); + } + }) +} module.exports = core; diff --git a/src/modules/command_manager.js b/src/modules/command_manager.js index 6df51a6..aafc7cf 100644 --- a/src/modules/command_manager.js +++ b/src/modules/command_manager.js @@ -47,8 +47,8 @@ async function command_manager (bot, options, config, discordClient) { const event = bot.discord.message; const roles = event?.member?.roles?.cache; if (command?.data?.trustLevel === 1 && !source?.sources?.discord) { - if (args.length === 0 && bot.validation.trusted && bot.validation.admin && bot.validation.owner && !source?.sources?.console) throw new CommandError({ text: "Please provide an trusted or an admin or an owner hash", color: "dark_red" }) - if (args[0] !== bot.validation.trusted && args[0] !== bot.validation.admin && args[0] !== bot.validation.owner && !source.sources.console) throw new CommandError({ translate: 'Invalid trusted or admin or owner hash', color: 'dark_red' }); + if (args.length === 0 && bot.validation.trusted && bot.validation.admin && bot.validation.owner && !source?.sources?.console) throw new CommandError({ text: "Please provide a trusted, admin or owner hash", color: "dark_red" }) + if (args[0] !== bot.validation.trusted && args[0] !== bot.validation.admin && args[0] !== bot.validation.owner && !source.sources.console) throw new CommandError({ translate: 'Invalid trusted, admin or owner hash', color: 'dark_red' }); } else if (command?.data?.trustLevel === 1 && source?.sources.discord) { const hasRole = roles?.some(role => role.name === `${config.discord.roles.trusted}` || role.name === `${config.discord.roles.owner}`) if (!hasRole) throw new CommandError({ translate: 'You are not trusted or the owner!', color: "dark_red" }) diff --git a/src/util/checks.js b/src/util/checks.js index e215478..1302134 100644 --- a/src/util/checks.js +++ b/src/util/checks.js @@ -9,11 +9,11 @@ module.exports = () => { ) } - if (!fs.existsSync(path.join(__dirname, "../data/filter.json"))) { +/* if (!fs.existsSync(path.join(__dirname, "../data/filter.json"))) { console.warn("filter json not found creating the file,......"); let data = [{ ignoreCase: false, regexed: false, name: 'whatever player username idfk' }] fs.writeFileSync(path.join(__dirname, "../data/filter.json"), JSON.stringify(data)) - } + }*/ /* if (!fs.existsSync(path.join(__dirname, "../data/trustedPlayers.json"))) {