diff --git a/.gitignore b/.gitignore index ec2115e..23af4d3 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,7 @@ node_modules build # ignore config -config.toml +config.js # ignore .git folder .git @@ -15,3 +15,5 @@ debug-bridge/.gradle # ignore the build folder in the debug bridge debug-bridge/build + +bot.old diff --git a/bot/Bot.ts b/bot/Bot.ts deleted file mode 100644 index 80f8db2..0000000 --- a/bot/Bot.ts +++ /dev/null @@ -1,34 +0,0 @@ -import mc from "minecraft-protocol"; -import FNFBoyfriendBot from "./FNFBoyfriendBot"; - -export class Bot extends FNFBoyfriendBot { - constructor (options: any, config: any, rl: any) { - super(options, config); - const bot = this; - - bot?.console?.interface(rl) - bot.on("init_client", (client: any) => { - client?.on('packet', (data: any, meta: any) => { - bot.emit("packet", data, meta); - bot.emit("packet." + meta.name, data) - }); - - client.on('login', (packet: any) => { - bot.entityId = packet.entityId; - }); - - client?.on("end", (reason: any) => { - bot.emit("end", reason); - }); - - // client.on("error", (error: any) => console.error(error)) - }) - - const client = mc.createClient(options) - - bot._client = client; - bot.emit('init_client', client); - bot.bots = options.bots ?? [bot] - return bot; - } -} diff --git a/bot/FNFBoyfriendBot.ts b/bot/FNFBoyfriendBot.ts deleted file mode 100644 index a4e4728..0000000 --- a/bot/FNFBoyfriendBot.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { EventEmitter } from 'events'; -import optionss from './Options'; -import { LoadModules } from './util/LoadModules'; - -export default class FNFBoyfriendBot extends EventEmitter { - public _client: any; - public bots: any; - public chat: any; - public commandManager: any; - public core: any; - public console: any; - public entityId: number; - public modules: []; - public options: any; - public players: any; - public position: any; - public reconnectDelay: any; - public registry: any; - public selfcare: any; - public tabcomplete: any; - public world: any; - - constructor (options: any, config: any) { - super(); - const defaultOptions = new optionss() - this.options = { - host: options.host ??= defaultOptions.host, - port: options.port ??= defaultOptions.port, - username: options.username ??= defaultOptions.username, - version: options.version ??= defaultOptions.version, - hideErrors: options.hideErrors ??= defaultOptions.hideErrors, - scInterval: options.scInterval ??= defaultOptions.scInterval, - reconnectDelay: options.reconnectDelay ?? defaultOptions.reconnectDelay - } - - this.options = options; - - LoadModules({ bot: this, config: config }) - } -} diff --git a/bot/Index.ts b/bot/Index.ts deleted file mode 100644 index db2c121..0000000 --- a/bot/Index.ts +++ /dev/null @@ -1,29 +0,0 @@ -import fs from "fs"; -import path from "path" -import readline from 'readline'; -import { Bot } from "./Bot"; -import { ParseToml } from './util/ParseToml'; -import version from './resources/Version.json'; -const rl = readline.createInterface({ - input: process.stdin, - output: process.stdout, -}) - -let debugEnabled = false; - -if (process.argv[2] === "--debug"?.toLowerCase()) { - debugEnabled = true -} - -if (debugEnabled) console.log(`Starting FNFBoyfriendBot ${version.codename} ${version.version} Build: ${version.build}`) -else console.log('Starting FNFBoyfriendBot....'); - -const config = ParseToml('./config.toml'); -const bots = []; - -for (const options of config.bots) { - let bot = new Bot(options, config, rl); - bots.push(bot); - bot.bots = bots; -// bot?.console?.interface(rl) -} diff --git a/bot/Options.ts b/bot/Options.ts deleted file mode 100644 index c597b94..0000000 --- a/bot/Options.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { UsernameGen } from './util/UsernameGen'; - -export default class options { - public host: string = "localhost" - public port: number = 25565; - public username = UsernameGen(); - public serverName: string = "localhost"; - public hideErrors: boolean = true; - public scInterval: number = 1000; - public version: '1.21.8'; - public reconnectDelay: number = 3000 -} diff --git a/bot/chatParsers/ChipmunkMod.ts b/bot/chatParsers/ChipmunkMod.ts deleted file mode 100644 index b7519d5..0000000 --- a/bot/chatParsers/ChipmunkMod.ts +++ /dev/null @@ -1,42 +0,0 @@ -export default function chipmunkmod(message: any, data: any) { - try { - if (message === null || typeof message !== "object") return; - if ( - message.with?.length < 3 || - (message.translate !== "[%s] %s › %s" && - message.translate !== "%s %s › %s") - ) - return; - - const senderComponent = message.with[1]; - const contents = message.with[2]; - let sender; - const hoverEvent = senderComponent.hover_event; - // console.log(hoverEvent) - if (hoverEvent?.action === "show_entity") { - const id = hoverEvent.uuid; - - sender = data.players.find((player: any) => player.entityUuid[0] === id[0])//.entityUuid //=== hoverEvent.uuid)//.entityUuid; - } else { - const stringUsername = data - .getMessageAsPrismarine(senderComponent) - ?.toString(); - - sender = data.players.find( - (player: any) => player.profile.name === stringUsername, - ); - } - - if (!sender) return null; - - return { - sender, - contents, - type: "minecraft:chat", - senderComponent, - chatType: data.chatType - }; - } catch (e) { - console.error(e); - } -} diff --git a/bot/chatParsers/Kaboom.ts b/bot/chatParsers/Kaboom.ts deleted file mode 100644 index 55f35aa..0000000 --- a/bot/chatParsers/Kaboom.ts +++ /dev/null @@ -1,40 +0,0 @@ -import util from 'util'; - -export default function kaboom (message: any, data: any) { - if (message === null || typeof message !== 'object') return - if (message.text !== '' || !Array.isArray(message.extra) || message.extra.length < 3) return - - const children = message.extra - - const prefix = children[0] - let displayName = data.senderName ?? { text: '' } - let contents = { text: '' } - - if (isSeparatorAt(children, 1)) { // Missing/blank display name - if (children.length > 3) contents = children[3] - } else if (isSeparatorAt(children, 2)) { - displayName = children[1] - if (children.length > 4) contents = children[4] - } else { - return undefined - } - - const playerListDisplayName = { extra: [prefix, displayName], text: '' } - - let sender - - if (data.senderUuid) { - sender = data.players.find((player: any) => player.uuid === data.senderUuid) - } else { - const playerListDisplayName = { extra: [prefix, displayName], text: '' } - sender = data.players.find((player: any) => util.isDeepStrictEqual(player.displayName, playerListDisplayName)) - } - - if (!sender) return undefined - - return { sender, contents, type: "minecraft:chat", displayName, chatType: data.chatType } -} - -function isSeparatorAt (children: any, start: any) { - return (children[start]?.text === ':' || children[start]?.text === '\xa7f:') && children[start + 1]?.text === ' ' -} diff --git a/bot/command/CommandContext.ts b/bot/command/CommandContext.ts deleted file mode 100644 index 5e56f2a..0000000 --- a/bot/command/CommandContext.ts +++ /dev/null @@ -1,12 +0,0 @@ -export class CommandContext { - public data: any - constructor (aliases: any, description: any, usages: any) { - this.data = {}; - - this.data.aliases = aliases; - - this.data.description = description; - - this.data.usages = usages; - } -} \ No newline at end of file diff --git a/bot/command/CommandError.ts b/bot/command/CommandError.ts deleted file mode 100644 index f689373..0000000 --- a/bot/command/CommandError.ts +++ /dev/null @@ -1,18 +0,0 @@ -// ported from FNFBoyfriendBot v8.0.0 - -const ChatMessage = require("prismarine-chat")("1.21.8"); -const stringify = (message: any) => new ChatMessage(message)?.toString(); - -export class CommandError extends Error { - public _message: any; - - constructor(message: any) { - super(stringify(message)) - this.name = "CommandError"; - this._message = message; - } - - get message() { - return stringify(this._message); - } -} diff --git a/bot/command/CommandSource.ts b/bot/command/CommandSource.ts deleted file mode 100644 index 7d797fb..0000000 --- a/bot/command/CommandSource.ts +++ /dev/null @@ -1,10 +0,0 @@ -export class CommandSource { - public player: any; - - public prefix: any; - - constructor (player: any, prefix: any) { - this.player = player; - this.prefix = prefix; - } -} \ No newline at end of file diff --git a/bot/commands/public/test.ts b/bot/commands/public/test.ts deleted file mode 100644 index 0c302cd..0000000 --- a/bot/commands/public/test.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { CommandContext } from '../../command/CommandContext'; - -export default class test extends CommandContext { - constructor() { - super( - ['te'], - "testing stuff", - [] - ) - } - - execute (context: any) { - const bot = context.bot; - const config = context.config; - const args = context.arguments; - - bot.chat.send('meow :3') - } -} diff --git a/bot/commands/trusted/.gitkeep b/bot/commands/trusted/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/bot/data/console/format.ts b/bot/data/console/format.ts deleted file mode 100644 index 54cf9fa..0000000 --- a/bot/data/console/format.ts +++ /dev/null @@ -1,38 +0,0 @@ -import translations from '../../resources/Translations.json'; - -export default function format ( - bot: any, - time: any, - dayName: any, - month: any, - dayNumber: any, - year: any, - type: any, - server: any, - message: any, -) { - let component = [ - { - translate: translations["console.format.text"], - color: "light_purple", - with: [ - { text: `${time}`, color: "blue" }, - { - translate: translations["console.format.date"], - color: "aqua", - with: [ - dayName, - month, - dayNumber, - year - ] - }, - type, - { text: `${server}`, color: "aqua" }, - ] - - }, - bot.getMessageAsPrismarine(message)?.toAnsi() - ] - return component; -} diff --git a/bot/data/playerlist/info.ts b/bot/data/playerlist/info.ts deleted file mode 100644 index e69de29..0000000 diff --git a/bot/commands/admin/.gitkeep b/bot/index.ts similarity index 100% rename from bot/commands/admin/.gitkeep rename to bot/index.ts diff --git a/bot/modules/Chat.ts b/bot/modules/Chat.ts deleted file mode 100644 index fbaaee5..0000000 --- a/bot/modules/Chat.ts +++ /dev/null @@ -1,185 +0,0 @@ -import convertNbtComponentToJson from "../util/ConvertNbtComponentToJson"; -import loadPrismarineChat from 'prismarine-chat'; -import kaboom from '../chatParsers/Kaboom'; -import chipmunkmod from '../chatParsers/ChipmunkMod'; - -// taken from FNFBoyfriendBot v8.0.0 - -function parseChatType (chatTypes: any, type: any, sender: any, target: any, message: any) { - const chatType = chatTypes[type] - const parsed = convertNbtComponentToJson(null, chatType.value.value.chat) - const array: any[] = [] - for (const parameter of parsed.parameters) { - - switch (parameter) { - case "sender": array.push(sender) - break; - case "target": array.push(target) - case "content": array.push(message) - break; - } - } - let json = { translate: parsed.translation_key, with: array } - - if (type === 4) json = message - - return json -} - -export default class Chat { - constructor (context: any) { - const bot = context.bot; - const config = context.config; - const options = bot.options; - let ChatMessage: any; - let chatTypes: any; - bot.on("registry_ready", (registry: any) => { - ChatMessage = loadPrismarineChat(registry); - }); - - bot.on('packet.registry_data', (packet: any) => { - if (packet.id !== 'minecraft:chat_type') return // taken from the 1.21.1 build of my bot that chayapak made - chatTypes = packet.entries - }) - - bot.chatParsers = [kaboom, chipmunkmod]; - - /* if (options.mode === "savageFriends") { - bot.chatParsers = [creayun]; - } else { - bot.chatParsers = [ - kaboom, - creayun, - chipmunkmod, - vanilla, - me - ]; - }*/ - - bot.on("packet.profileless_chat", (packet: any) => { - const sender = convertNbtComponentToJson(null, packet.name); - const message = convertNbtComponentToJson(null, packet.message); - const target = convertNbtComponentToJson(null, packet.target) - const type = packet.type.chatType; - const parsed = parseChatType(chatTypes, type, sender, target, message) - bot.emit('message', { - type: "minecraft:disguised_chat", - message: parsed - }) - - parseMessage(parsed, { senderName: sender, players: bot.players, getMessageAsPrismarine: bot.getMessageAsPrismarine, chatType: "minecraft:diguised_chat" }) - }); - - bot.on("packet.player_chat", (packet: any) => { - const unsigned = convertNbtComponentToJson(null, packet.unsignedChatContent); - const networkName = convertNbtComponentToJson(null, packet.networkName) - bot.emit('message', { - type: "minecraft:player_chat", - message: unsigned - }) - - parseMessage(unsigned, { - senderUuid: packet.senderUuid, - players: bot.players, - getMessageAsPrismarine: bot.getMessageAsPrismarine, - chatType: "minecraft:player_chat" - }); - - }); - - bot.on("packet.system_chat", (packet: any) => { - const message = convertNbtComponentToJson(null, packet.content); - bot.emit("system", message); - if ( - // message.translate === "advMode.setCommand.success" - //|| - message.translate === "multiplayer.message_not_delivered" - || - packet.isActionBar - || - message.translate === "advMode.notAllowed" - ) - return; - - bot.emit("message", { - type: "minecraft:system_chat", - message: message - }); - - parseMessage(message, { - players: bot.players, - getMessageAsPrismarine: bot.getMessageAsPrismarine, - chatType: "minecraft:system_chat", - }); - }); - - function parseMessage(message: any, data: any) { - try { - let parsed; - - for (const parser of bot.chatParsers) { - parsed = parser(message, data); - if (parsed) break; - } - - if (!parsed) return; - - bot.emit("parsed_message", parsed); - } catch (e: unknown) { - console.log(e); - } - } - - bot.getMessageAsPrismarine = (message: string) => { - try { - if (ChatMessage !== undefined) { - return new ChatMessage(message); - } - } catch {} - - return undefined; - }; - - bot.chat = { - message(message: any) { - const acc = 0; - const bitset = Buffer.allocUnsafe(3); - bitset[0] = acc & 0xff; - bitset[1] = (acc >> 8) & 0xff; - bitset[2] = (acc >> 16) & 0xff; - bot._client.write("chat_message", { - message: message?.substring(0, 256)?.replaceAll("§", "&"), - timestamp: BigInt(Date.now()), - salt: 0n, - offset: 0, - acknowledged: bitset, - }); - }, - - command(command: any) { - bot._client.write("chat_command", { - command: command?.substring(0, 256)?.replaceAll("§", "&"), - timestamp: BigInt(Date.now()), - salt: 0n, - argumentSignatures: [], - signedPreview: false, - messageCount: 0, - acknowledged: Buffer.alloc(3), - previousMessages: [], - }); - }, - - send(message: any) { - if (message.startsWith("/")) { - bot.chat.command(message.substring(1)); - return; - } - bot.chat.message(message); - } - } - - bot.tellraw = (selector: any, message: any) => { - bot.core.run(`minecraft:tellraw ${selector} ` + JSON.stringify(message)) - } - } -} diff --git a/bot/modules/CommandHandler.ts b/bot/modules/CommandHandler.ts deleted file mode 100644 index a91dfbe..0000000 --- a/bot/modules/CommandHandler.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { CommandSource } from '../command/CommandSource'; - -export default class CommandHandler { - constructor (context: any) { - const bot = context.bot; - const config = context.config; - const options = bot.options; - - bot.on('parsed_message', (packet: any) => { - try { - const prefixes = config.prefixes; - const message = packet.contents; - const plainMessage = bot.getMessageAsPrismarine(message)?.toString(); - const player = packet.player - - for (const prefix of prefixes) { - if (!plainMessage.startsWith(prefix)) return; - const command = plainMessage.substring(prefix.length); - if (command.length == 0) return; - const getPrefix = plainMessage.split(command)[0] - const source = new CommandSource(player, prefix) - bot.commandManager.executeString(source, command) - } - } catch (e) { - if (e instanceof Error) bot.console.info(e.stack) - } - }) - } -} diff --git a/bot/modules/CommandsManager.ts b/bot/modules/CommandsManager.ts deleted file mode 100644 index a4107a5..0000000 --- a/bot/modules/CommandsManager.ts +++ /dev/null @@ -1,83 +0,0 @@ -import { LoadCommands } from '../util/LoadCommands'; -import { CommandError } from '../command/CommandError'; - -export default class CommandManager { - constructor (context: any) { - const bot = context.bot; - const config = context.config; - const options = bot.options; - - bot.commandManager = { - commands: {}, - - list: [], - - execute (source: any, commandName: any, args: any) { - const command = this.getCommand(commandName.toLowerCase()); - - try { - if (!command) throw new CommandError({ - translate: "%s%s%s %s", - color: "red", - with: [ - { translate: "command.unknown.command", color: "red" }, - { text: "\n" }, - { text: `${commandName}`, color: "gray" }, - { translate: "command.context.here", color: "red" } - ] - }) - - return command?.execute({ bot, config, arguments: args }) - } catch (e) { - if (e instanceof CommandError) bot.tellraw("@a", e._message); - else { - bot.console.info(e); - bot.tellraw("@a", - { - translate: "command.failed", - color: "red", - hoverEvent: { - action: "show_text", - contents: String(e), - }, - } - ) - } - } - }, - - executeString (source: any, command: any) { - const [commandName, ...args] = command.split(" "); - - return this.execute(source, commandName, args); - }, - - register (command: any, filename: any, folderName: any) { - const commandName = filename.split('.js')[0]; - command.data.name = commandName; - - if (folderName === "public") command.data.trustLevel = [0, "public"]; - if (folderName === "trusted") command.data.trustLevel = [0, "trusted"]; - if (folderName === "admin") command.data.trustLevel = [0, "admin"]; - if (folderName === "owner") command.data.trustLevel = [0, "owner"]; - if (folderName === "console") command.data.trustLevel = [0, "console"]; - else command.data.trustLevel = [5, "unknown"]; - this.commands[command.data.name] = command; - - if (command.data.aliases) { - command.data.aliases.map((aliases: any) => this.commands[aliases] = command) - } - }, - - getCommand(name: any) { - return this.commands[name]; - }, - - getCommands() { - return Object.values(this.commands); - }, - } - - LoadCommands(bot, config); - } -} diff --git a/bot/modules/Console.ts b/bot/modules/Console.ts deleted file mode 100644 index 4063e79..0000000 --- a/bot/modules/Console.ts +++ /dev/null @@ -1,72 +0,0 @@ -import translations from '../resources/Translations.json'; -import format from '../data/console/format'; -export default class Console { - constructor (context: any) { - const bot = context.bot; - const config = context.config; - const options = bot.options; - let host = `${options.host}:${options.port}`; - - bot.console = { - readline: null, - - currentServer: "all", - - interface(rl: any) { - this.readline = rl; - - rl.on("line", (args: any) => { - console.log(args) - //if (options.serverName !== this.server && this.server !== "all") return; - - if (args.startsWith(config.console.prefix)) { - - } else { - bot.chat.send(args) - } - }); - - rl.on("close", () => { - this.readline = null; - }); - }, - - refreshLine(...args: any) { - this?.readline?.output.write("\x1b[2K\r"); - console.log.apply(console, args); - this?.readline?._refreshLine(); - }, - - prefix(type: any, server: any, message: any) { - // i read the firefox docs to see how to get elements of date seperately if that makes any sense - const timeZone = config.console.timeZone - const dayName = new Date().toLocaleDateString('en-US', { weekday: 'long', timeZone }); - const dayNumber = new Date().toLocaleDateString('en-US', { day: 'numeric', timeZone }); - const month = new Date().toLocaleDateString('en-US', { month: 'long', timeZone }); - const year = new Date().toLocaleDateString('en-US', { year: 'numeric', timeZone }); - //const date = format(translations['console.format.date'], `${dayName}`, `${month}`, `${dayNumber}`, `${year}`); - const time = new Date().toLocaleTimeString("en-US", { timeZone }); - const consoleFormat = format(bot, time, dayName, month, dayNumber, year, type, server, message); - - return bot.getMessageAsPrismarine(consoleFormat)?.toAnsi() - }, - - log(message: any) { - this.refreshLine( - this.prefix('§6log', host, message) - ) - }, - - info(info: any) { - this.refreshLine( - this.prefix('§6info', host, info) - ) - } - } - - bot.on('message', (data: any) => { - const message = data.message; - bot.console.log(message) - }); - } -} diff --git a/bot/modules/Core.ts b/bot/modules/Core.ts deleted file mode 100644 index 16169b1..0000000 --- a/bot/modules/Core.ts +++ /dev/null @@ -1,170 +0,0 @@ -// i may or may not have used v4's command core for a base here -import { format } from 'util'; -//const Chunk = require('prismarine-chunk') -export default class Core { - constructor (context: any) { - const bot = context.bot; - const config = context.config; - const options = bot.options; - const Item = require("prismarine-item")(bot.options.version); - - bot.core = { - area: { - start: options.core?.area.start ?? { x: 0, y: 0, z: 0 }, - end: options.core?.area.end ?? { x: 15, y: 0, z: 15 } - }, - - position: null, - - itemPosition: null, - - currentBlockRelative: { x: 0, y: 0, z: 0 }, - - refill () { - const pos = bot.core.position - const { start, end } = bot.core.area - - if (!pos) return -// {CustomName:${JSON.stringify(config.core.name)} - bot.chat.command(`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`) - }, - - itemRefill () { - const pos = bot.core.itemPosition; - //console.log(Item.toNotch(new Item(bot.registry.itemsByName.repeating_command_block.id, 1, 0, 0, 0,))) - // console.log(Item.toNotch(new Item(bot.registry.itemsByName.repeating_command_block.id))) - console.log(Item.toNotch(new Item(bot.registry.itemsByName.repeating_command_block.id), 1)) - bot._client.write("set_creative_slot", { - slot: 36, - //item: {} - item: Item.toNotch( - new Item( - bot.registry.itemsByName.repeating_command_block.id, - 1, - 0, - ), - ), - }); - - bot._client.write("block_dig", { - status: 0, - location: pos, - face: 0, - }); - - bot._client.write("block_place", { - hand: 0, - location: pos, - direction: 0, - cursorX: 0, - cursorY: 0, - cursorZ: 0, - insideBlock: false, - }); - }, - - useCommandBlock (command: any, location: any, mode: any, flags: any) { - bot._client.write("update_command_block", { - command: command?.substring(0, 32767), - location: location, - mode: mode, - flags: flags, - }); - }, - - move (pos = bot.position) { - bot.core.position = { - x: Math.floor(pos.x / 16) * 16, - y: 0, - z: Math.floor(pos.z / 16) * 16 - } - - bot.core.itemPosition = { - x: Math.floor(pos.x), - y: Math.floor(pos.y - 1), - z: Math.floor(pos.z), - }; - - bot.core.itemRefill(); - //bot.core.refill() - }, - - commandBlockCoords: [], - - needsFilling: false, - - cantFill: false, - - currentBlock () { - const relativePosition = bot.core.currentBlockRelative - const corePosition = bot.core.position - if (!corePosition) return null - return { x: relativePosition.x + corePosition.x, y: relativePosition.y + corePosition.y, z: relativePosition.z + corePosition.z } - }, - - incrementCurrentBlock () { - const relativePosition = bot.core.currentBlockRelative - const { start, end } = bot.core.area - - relativePosition.x++ - - if (relativePosition.x > end.x) { - relativePosition.x = start.x - relativePosition.z++ - } - - if (relativePosition.z > end.z) { - relativePosition.z = start.z - relativePosition.y++ - } - - if (relativePosition.y > end.y) { - relativePosition.x = start.x - relativePosition.y = start.y - relativePosition.z = start.z - } - }, - - run (command: any) { - const location = bot.core.currentBlock() - if (!location) return - - bot._client.write('update_command_block', { command, location, mode: 1, flags: 0b100 }) - - bot.core.incrementCurrentBlock() - } - } - - bot.on('move', () => { - bot.core.move(bot.position) - }); - - bot.on('packet.multi_block_change', (packet: any) => { - // used some code here from https://code.chipmunk.land/Yaode_owo/js-nmp-1.21.8-chunkparser/src/branch/main/chunkparser.js - - const chunkCoord = packet.chunkCoordinates; - - const findChunkColumn = bot.world.chunkColumns.find((column: any) => column.x === chunkCoord.x && column.z === chunkCoord.z); - const baseX = chunkCoord.x << 4; - const baseY = chunkCoord.y << 4; - const baseZ = chunkCoord.z << 4; - - for (const num of packet.records) { - const x = baseX | ((num >> 8) & 15); - const y = baseY | (num & 15); - const z = baseZ | ((num >> 4) & 15); - const getBlock = bot.world.getBlock(num >> 12); - if (getBlock.name === "command_block") { - bot.core.commandBlockCoords.push({ x: x, y: y, z: z }); - } - const coreX = bot.core.commandBlockCoords.find((coord: any) => coord.x === x); - const coreY = bot.core.commandBlockCoords.find((coord: any) => coord.y === y); - const coreZ = bot.core.commandBlockCoords.find((coord: any) => coord.z === z) - if (coreX && coreY && coreZ) { - if (getBlock.name === "command_block" || getBlock.name === "repeating_command_block") return; - else bot.core.refill() - } - } - }); - } -} diff --git a/bot/modules/MemUsage.ts b/bot/modules/MemUsage.ts deleted file mode 100644 index 40f35ef..0000000 --- a/bot/modules/MemUsage.ts +++ /dev/null @@ -1,25 +0,0 @@ -import v8 from 'v8'; -const { heap_size_limit } = v8.getHeapStatistics(); - -export default class MemUsage { - constructor (context: any) { - const bot = context.bot; - const config = context.config; - if (!config.debug.memoryUsage) return; - - setInterval(() => { - let mbDivide = 1048576; - bot.console.info(`[Heap Memory] ${Math.floor(process.memoryUsage().heapUsed / mbDivide)} MB / ${Math.floor(process.memoryUsage().heapTotal / mbDivide)} MB`); - bot.console.info(`[Process Memory] ${Math.floor(process.memoryUsage.rss() / mbDivide)} MB / ${Math.floor(heap_size_limit / mbDivide - 192)} MB`); - }, 1000); - } -} - -/* -setInterval(() => { - let osMemUsed = Math.floor((totalmem() / mbDivide) - freemem() / mbDivide) - console.log(`Heap mem: ${Math.floor(heapUsed / mbDivide)} MB / ${Math.floor(heapTotal / mbDivide)} MB`); - console.log(`Process mem: ${Math.floor(rss / mbDivide)} MB / ${Math.floor(heap_size_limit) / mbDivide} MB`); - console.log(`OS mem: ${osMemUsed} MB / ${Math.floor(totalmem() / mbDivide)} MB`) -}, 1000) -*/ diff --git a/bot/modules/Players.ts b/bot/modules/Players.ts deleted file mode 100644 index 29d2c2d..0000000 --- a/bot/modules/Players.ts +++ /dev/null @@ -1,101 +0,0 @@ -const convertNbtComponentToJson = require("../util/ConvertNbtComponentToJson"); -const entityUUID = require('../util/EntityUUID'); - -// taken from FNFBoyfriendBot v8.0.0 -export default class Players { - constructor(context: any) { - const bot = context.bot; - bot.players = []; - - bot.on("packet.player_info", (packet: any) => { - const actions = []; - if (packet.action._value & 0b000001) actions.push(addPlayer); - if (packet.action._value & 0b000010) actions.push(initializeChat); - if (packet.action._value & 0b000100) actions.push(updateGamemode); - if (packet.action._value & 0b001000) actions.push(updateListed); - if (packet.action._value & 0b010000) actions.push(updateLatency); - if (packet.action._value & 0b100000) actions.push(updateDisplayName); - for (const entry of packet.data) { - for (const action of actions) { - action(entry); - } - } - }); - - bot.on("packet.player_remove", async ({ players }: { players: any }) => { - // players has uuids of the players - let player_completion = ( - await bot.tabcomplete("scoreboard players add ") - ).filter((_: any) => _.tooltip == undefined); // exclude @a, @r, @s, @e, @p -aaa - bot.players.forEach(async (player: any) => { - if (!players.includes(player.uuid)) return; - - const a = player_completion.filter( - (_: any) => _.match == player.profile.name, - ); - if (a.length >= 1) { - player.vanished = true; - } else { - bot.players = bot.players.filter((_: any) => _.uuid != player.uuid); - } - }); - }); - - function addPlayer(entry: any) { - bot.players = bot.players.filter((_entry: any) => _entry.uuid !== entry.uuid); - bot.players.push({ - uuid: entry.uuid, - entityUuid: entityUUID(entry.uuid), - profile: { - name: entry.player.name, - properties: entry.player.properties, - }, - chatSession: undefined, - gamemode: undefined, - listed: undefined, - latency: undefined, - displayName: undefined, - prefix: undefined, - vanished: false, - }); - - //bot.emit('player_info', entry) - } - - function initializeChat(entry: any) {} - - function updateGamemode(entry: any) { - const target = bot.players.find((_entry: any) => _entry.uuid === entry.uuid); - if (!target) return; - - target.gamemode = entry.gamemode; - } - - function updateListed(entry: any) { - const target = bot.players.find((_entry: any) => _entry.uuid === entry.uuid); - if (!target) return; - target.listed = entry.listed; - } - - function updateLatency(entry: any) { - const target = bot.players.find((_entry: any) => _entry.uuid === entry.uuid); - if (!target) return; - - target.latency = entry.latency; - } - - function updateDisplayName(entry: any) { - const target = bot.players.find((_entry: any) => _entry.uuid === entry.uuid); - if (!target) return; - - try { - target.displayName = convertNbtComponentToJson(null, entry.displayName); - // if (bot.options.mode === "kaboom") target.prefix = convertNbtComponentToJson(null, entry.displayName).extra[0] - } catch { - // do nothing - } - } - - bot.on("end", () => (bot.players = [])); - } -} diff --git a/bot/modules/Position.ts b/bot/modules/Position.ts deleted file mode 100644 index 898daa2..0000000 --- a/bot/modules/Position.ts +++ /dev/null @@ -1,20 +0,0 @@ -export default class Position { - constructor (context: any) { - const bot = context.bot; - - bot.position = null; - - bot.on('packet.position', (packet: any) => { - bot.position = { - x: packet.x, - y: packet.y, - z: packet.z - } - bot._client.write("teleport_confirm", { teleportId: packet.teleportId }); - - bot.emit("move"); - }); - - bot.on('end', () => bot.position = null); - } -} diff --git a/bot/modules/Reconnect.ts b/bot/modules/Reconnect.ts deleted file mode 100644 index cb9030f..0000000 --- a/bot/modules/Reconnect.ts +++ /dev/null @@ -1,22 +0,0 @@ -import mc from 'minecraft-protocol'; - -export default class Reconnect { - constructor (context: any) { - const bot = context.bot; - const config = context.config; - const options = bot.options; - bot.reconnectDelay = options.reconnectDelay; - let client; - - bot.on('end', () => { - bot.world.dimensions = []; - bot.world.chunks = []; - bot.world.currentDimension = undefined; - setTimeout(() => { - client = options.client ?? mc.createClient(options); - bot._client = client; - bot.emit("init_client", bot._client); - }, bot.reconnectDelay); - }) - } -} diff --git a/bot/modules/Registry.ts b/bot/modules/Registry.ts deleted file mode 100644 index 46473a3..0000000 --- a/bot/modules/Registry.ts +++ /dev/null @@ -1,16 +0,0 @@ -import createRegistry from 'prismarine-registry'; -import language from '../resources/Language.json'; - -export default class Registry { - constructor(context: any) { - const bot = context.bot; - - bot.registry = createRegistry(bot.options.version); - bot.registry.language = language; - bot.emit("registry_ready", bot.registry); - - bot.on('packet.registry_data', (packet: any) => { - bot.registry.loadDimensionCodec(packet) - }) - } -} diff --git a/bot/modules/Selfcare.ts b/bot/modules/Selfcare.ts deleted file mode 100644 index ff532d6..0000000 --- a/bot/modules/Selfcare.ts +++ /dev/null @@ -1,32 +0,0 @@ -export default class Selfcare { - constructor (context: any) { - const bot = context.bot; - const config = context.config; - const options = bot.options; - - bot.selfcare = { - permission: 2, - gamemode: 0, - }; - - const entity = [ - require('../selfcare/entity/Permission'), - require('../selfcare/entity/GameMode') - ]; - - for (const file of entity) file.default(bot, config); - - let timer: any; - - bot.on('packet.login', (packet: any) => { - timer = setInterval(() => { - if (bot.selfcare.permission < 2) bot.chat.command("minecraft:op @s[type=player]"); - else if (bot.selfcare.gamemode !== 1) bot._client.write("change_gamemode", { mode: 1 }) - }, options.scInterval) - }); - - bot.on('end', () => { - if (timer) clearInterval(timer); - }) - } -} diff --git a/bot/modules/Sign.ts b/bot/modules/Sign.ts deleted file mode 100644 index c51e296..0000000 --- a/bot/modules/Sign.ts +++ /dev/null @@ -1,17 +0,0 @@ -const convertNbtToComponent = require('../util/ConvertNbtComponentToJson'); - -export default class Sign { - constructor (context: any) { - const bot = context.bot; - const options = bot.options; - - bot.on('packet.tile_entity_data', (packet: any) => { - const front = convertNbtToComponent(null, packet.nbtData.value.front_text); - const back = convertNbtToComponent(null, packet.nbtData.value.back_text); - //console.log(front); - //console.log(back); - }); - - bot.on("packet.error", (error: any) => console.error(error)) - } -}; diff --git a/bot/modules/TabComplete.ts b/bot/modules/TabComplete.ts deleted file mode 100644 index bb2a612..0000000 --- a/bot/modules/TabComplete.ts +++ /dev/null @@ -1,22 +0,0 @@ -// taken from FNFBoyfriendBot v8.0.0 - -export default class TabComplete { - constructor(context: any) { - const bot = context.bot; - // let aaa cook - bot.tabcomplete = (str: any) => { - return new Promise((resolve) => { - bot._client.write("tab_complete", { - text: str, - assumeCommand: false, - sendBlockInSight: false, - }); - const tab_completeH = (packet: any) => { - bot._client.removeListener("tab_complete", tab_completeH); - resolve(packet.matches); - }; - bot._client.once("tab_complete", tab_completeH); - }); - }; - } -} diff --git a/bot/modules/World.ts b/bot/modules/World.ts deleted file mode 100644 index d2d16b8..0000000 --- a/bot/modules/World.ts +++ /dev/null @@ -1,70 +0,0 @@ -const convertNbtComponentToJson = require('../util/ConvertNbtComponentToJson'); - -export default class world { - constructor (context: any) { - const bot = context.bot; - const config = context.config; - const options = bot.options; - bot.world = { - dimensions: [], - chunkColumns: [], - currentDimension: undefined, - getBlock (blockStateID: any) { - const getBlocks = bot.registry.blocksByStateId; - - return getBlocks[blockStateID]; - }, - chunk: undefined, - - getBlockNBT (location: any) { - const transactionId = Math.floor(Math.random() * 10000); - - bot._client.write('query_block_nbt', { transactionId, location }); - - bot.on('packet.nbt_query_response', (packet: any) => { - try { - if (packet.transactionId == transactionId) { - const parsed = convertNbtComponentToJson(null, packet.nbt); - } - } catch (e) { - console.log(e) - } - }) - } - } - - bot.on('packet.login', (packet: any) => { - - }); - - bot.on('packet.registry_data', (packet: any) => { - let dimension; - if (packet.id === "minecraft:dimension_type") { - for (const dimensions of packet.entries) { - const parseToJson = convertNbtComponentToJson(null, dimensions.value); - const maxY = parseToJson.height; - const minY = parseToJson.min_y; - - if (dimensions.key === "minecraft:overworld_caves") dimension = "minecraft:world_flatlands"; - else dimension = dimensions.key - bot.world.dimensions.push({ name: dimension, minY: minY, maxY: maxY }); - } - } - }); - - bot.on('packet.map_chunk', (packet: any) => { - const x = packet.x; - const z = packet.z; - - bot.world.chunkColumns.push({ x, z }); - }); - - bot.on('packet.unload_chunk', (packet: any) => { - bot.world.chunkColumns = []; - }); - - bot.on('packet.respawn', (packet: any) => { - bot.world.currentDimension = packet.worldState.name; - }) - } -} \ No newline at end of file diff --git a/bot/resources/DefaultConfig.toml b/bot/resources/DefaultConfig.toml deleted file mode 100644 index 2fabb6d..0000000 --- a/bot/resources/DefaultConfig.toml +++ /dev/null @@ -1,17 +0,0 @@ -prefixes = ["!"] - -[debug] -host = "http://localhost:8080" - -[console] -prefix = "c." -timezone = "America/CHICAGO" - - -[[bots]] -host = "localhost" -version = "1.21.8" -username = "meow" -serverName = "localhost" -hideErrors = true -scInterval = 1000 diff --git a/bot/resources/Translations.json b/bot/resources/Translations.json deleted file mode 100644 index eb4d0c9..0000000 --- a/bot/resources/Translations.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "console.format.date": "%s, %s %s, %s", - "console.format.text": "[%s %s %s] [%s] " -} \ No newline at end of file diff --git a/bot/resources/Version.json b/bot/resources/Version.json deleted file mode 100644 index 81ac732..0000000 --- a/bot/resources/Version.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "build": "5010", - "codename": "§5Madoka", - "version": "v9.0.0-alpha" -} \ No newline at end of file diff --git a/bot/resources/Language.json b/bot/resources/language.json similarity index 100% rename from bot/resources/Language.json rename to bot/resources/language.json diff --git a/bot/resources/version.json b/bot/resources/version.json new file mode 100644 index 0000000..153d498 --- /dev/null +++ b/bot/resources/version.json @@ -0,0 +1,13 @@ +{ + "build": "5010", + "codename": { + "translate": "%s-%s-%s", + "color": "dark_aqua", + "with": [ + { "text": "Night", "color": "blue" }, + { "text": "of", "color": "dark_blue" }, + { "text": "Nights", "color": "blue" } + ] + }, + "version": "v9.0.0-alpha" +} \ No newline at end of file diff --git a/bot/selfcare/entity/GameMode.ts b/bot/selfcare/entity/GameMode.ts deleted file mode 100644 index 974ec61..0000000 --- a/bot/selfcare/entity/GameMode.ts +++ /dev/null @@ -1,9 +0,0 @@ -export default function GameMode (bot: any, config: any) { - bot.on('packet.game_state_change', (packet: any) => { - if (packet.reason === "change_game_mode") { - bot.selfcare.gamemode = packet.gameMode - } if (packet.reason === "win_game") { - bot._client.write('client_command', { action: 0 }) - } - }) -} diff --git a/bot/selfcare/entity/Permission.ts b/bot/selfcare/entity/Permission.ts deleted file mode 100644 index d6324b8..0000000 --- a/bot/selfcare/entity/Permission.ts +++ /dev/null @@ -1,12 +0,0 @@ -export default function Permission (bot: any, config: any) { - bot.on("packet.entity_status", (packet: any) => { - if ( - packet.entityId !== bot.entityId - || - packet.entityStatus < 24 - || - packet.entityStatus > 28 - ) return - bot.selfcare.permission = packet.entityStatus - 24; - }) -} diff --git a/bot/util/ConvertNbtComponentToJson.js b/bot/util/ConvertNbtComponentToJson.js deleted file mode 100644 index 1ecda8c..0000000 --- a/bot/util/ConvertNbtComponentToJson.js +++ /dev/null @@ -1,65 +0,0 @@ -// taken from FNFBoyfriendBot v8.0.0 - -const BOOLEAN_TYPES = [ - "interpret", - "bold", - "italic", - "underlined", - "strikethrough", - "obfuscated", -]; -function convertNbtComponentToJson(key, tag) { - if (!tag) { - return null; - } else if (tag.type === "compound") { - const object = {}; - - for (const key of Object.keys(tag.value)) { - object[key === "" ? "text" : key] = convertNbtComponentToJson( - key, - tag.value[key], - ); - } - - return object; - } else if (tag.type === "list") { - const array = []; - - for (const item of tag.value.value) { - array.push( - convertNbtComponentToJson(null, { type: tag.value.type, value: item }), - ); - } - - return array; - } else if (tag.type === "byte") { - if (key && BOOLEAN_TYPES.includes(key)) return tag.value !== 0; - - return tag.value; - } else if (tag.type === "int") { - return tag.value; - } else if (tag.type === "string") { - return tag.value; - } else if (tag.type === "float") { - return tag.value - } else if (tag.type === "intArray") { - const array = []; - - for (const value of tag.value) { - array.push(value); - } - - return array; - } else if (tag.type === "short") { - return tag.value; - } else if (tag.type === "long") { - return tag.value - } else if (tag.type === "double") { - return tag.value - } else { - console.log("Failed to parse NBT component type " + tag.type); - - return { text: "" }; - } -} -module.exports = convertNbtComponentToJson; \ No newline at end of file diff --git a/bot/util/EntityUUID.ts b/bot/util/EntityUUID.ts deleted file mode 100644 index 773337f..0000000 --- a/bot/util/EntityUUID.ts +++ /dev/null @@ -1,5 +0,0 @@ -function entityUUID (uuid: any) { - // taken from https://gist.github.com/storycraft/7813dd0186e85daa393e1df9cfa19f2a - return uuid.replace(/-/g, '').match(/.{8}/g).map((str: any) => Number.parseInt(str, 16)).map((num: any) => Number.parseInt(num & 0x80000000 ? num - 0xffffffff - 1 : num)) -} -export = entityUUID \ No newline at end of file diff --git a/bot/util/LoadCommands.ts b/bot/util/LoadCommands.ts deleted file mode 100644 index 5c83835..0000000 --- a/bot/util/LoadCommands.ts +++ /dev/null @@ -1,26 +0,0 @@ -import fs from 'fs'; -import path from 'path'; - -export async function LoadCommands (bot: any, config: any) { - const foldersPath = path.join(__dirname, "../commands"); - const commandFolders = fs.readdirSync(foldersPath); - for (const folder of commandFolders) { - const commandsPath = path.join(foldersPath, folder); - const commandFiles = fs.readdirSync(commandsPath); - for (const filename of commandFiles) { - try { - const filePath = path.join(commandsPath, filename); - - if (filename.endsWith(".js")) { - const folderName = path.basename(path.dirname(filePath)); - const commands = await import(filePath); - const command = new commands.default(); - bot.commandManager.register(command, filename, folderName); - bot.commandManager.list.push(command); - } - } catch (error) { - console.error("Failed to load command", filename, ":", error); - } - } - } -} diff --git a/bot/util/LoadModules.ts b/bot/util/LoadModules.ts deleted file mode 100644 index 0b480d8..0000000 --- a/bot/util/LoadModules.ts +++ /dev/null @@ -1,23 +0,0 @@ -import fs from 'fs'; -import path from 'path'; - -export async function LoadModules (context: any) { - const bot = context.bot; - const config = context.config - for ( - const filename of fs.readdirSync( - path.join(__dirname, '../modules') - ) - ) { - try { - if (filename.endsWith('.js')) { - const module = await import(path.join(__dirname, '../modules/', filename)); - new module.default({ bot, config }); - //bot.modules.push(module) - } - } catch (e) { - console.error(`Failed to load module: ${filename} due to the following Error\n`); - console.error(e) - } - } -} diff --git a/bot/util/ParseToml.ts b/bot/util/ParseToml.ts deleted file mode 100644 index 6cb0e69..0000000 --- a/bot/util/ParseToml.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { readFileSync } from 'fs'; -import { join } from 'path'; -import toml from 'smol-toml'; -export function ParseToml (path: any) { - try { - const file = readFileSync(join(path), 'utf8'); - const parse = toml.parse(file) - /** - * stringify if the parsed toml is not stringified and then parsed again with JSON.stringify and JSON.parse it will error with - * Type 'TomlValue' must have a '[Symbol.iterator]()' method that returns an iterator. when we try to use it in a for const of statement - */ - const stringify = JSON.stringify(parse); - const parsed = JSON.parse(stringify) - return parsed - } catch (error: unknown) { - console.error(`\x1b[31mFailed to parse toml due to\x1b[0m\n${error}`) - } -} diff --git a/bot/util/UsernameGen.ts b/bot/util/UsernameGen.ts deleted file mode 100644 index 0ccfc90..0000000 --- a/bot/util/UsernameGen.ts +++ /dev/null @@ -1,10 +0,0 @@ -export function UsernameGen() { - const characters = - "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; - let username = ""; - for (let i = 0; i < 3 + Math.floor(Math.random() * 14); i++) { - const randomIndex = Math.floor(Math.random() * characters.length); - username += characters[randomIndex]; - } - return username; -} diff --git a/bot/commands/console/.gitkeep b/framework/compile.sh similarity index 100% rename from bot/commands/console/.gitkeep rename to framework/compile.sh diff --git a/bot/commands/owner/.gitkeep b/framework/install_packages.sh similarity index 100% rename from bot/commands/owner/.gitkeep rename to framework/install_packages.sh diff --git a/memoryTest.js b/memoryTest.js deleted file mode 100644 index 927b6c2..0000000 --- a/memoryTest.js +++ /dev/null @@ -1,11 +0,0 @@ -const v8 = require('v8'); -const { totalmem, freemem } = require('os'); -const { heap_size_limit } = v8.getHeapStatistics(); -const { heapUsed, heapTotal, rss } = process.memoryUsage(); -let mbDivide = 1048576; -setInterval(() => { - let osMemUsed = Math.floor((totalmem() / mbDivide) - freemem() / mbDivide) - console.log(`Heap mem: ${Math.floor(heapUsed / mbDivide)} MB / ${Math.floor(heapTotal / mbDivide)} MB`); - console.log(`Process mem: ${Math.floor(rss / mbDivide)} MB / ${Math.floor(heap_size_limit / mbDivide - 192)} MB`); - console.log(`OS mem: ${osMemUsed} MB / ${Math.floor(totalmem() / mbDivide)} MB`) -}, 1000) \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 6e3b38a..78300f3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,18 +1,20 @@ { - "name": "FNFBoyfriendBot-Madoka", + "name": "FNFBoyfriendBot-Night-of-Nights", "lockfileVersion": 3, "requires": true, "packages": { "": { "dependencies": { + "discord.js": "^14.25.1", "minecraft-protocol": "^1.62.0", + "mojangson": "^2.0.4", "prismarine-chat": "^1.12.0", - "prismarine-chunk": "^1.39.0", + "prismarine-nbt": "^2.8.0", "prismarine-registry": "^1.11.0", "prismarine-world": "^3.6.3", "smol-toml": "^1.5.2", "socket.io-client": "^4.8.1", - "vec3": "^0.1.10", + "undici": "^7.18.2", "yaml": "^2.8.2" }, "devDependencies": { @@ -42,6 +44,178 @@ "node": ">=16" } }, + "node_modules/@discordjs/builders": { + "version": "1.13.1", + "resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-1.13.1.tgz", + "integrity": "sha512-cOU0UDHc3lp/5nKByDxkmRiNZBpdp0kx55aarbiAfakfKJHlxv/yFW1zmIqCAmwH5CRlrH9iMFKJMpvW4DPB+w==", + "license": "Apache-2.0", + "dependencies": { + "@discordjs/formatters": "^0.6.2", + "@discordjs/util": "^1.2.0", + "@sapphire/shapeshift": "^4.0.0", + "discord-api-types": "^0.38.33", + "fast-deep-equal": "^3.1.3", + "ts-mixer": "^6.0.4", + "tslib": "^2.6.3" + }, + "engines": { + "node": ">=16.11.0" + }, + "funding": { + "url": "https://github.com/discordjs/discord.js?sponsor" + } + }, + "node_modules/@discordjs/collection": { + "version": "1.5.3", + "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-1.5.3.tgz", + "integrity": "sha512-SVb428OMd3WO1paV3rm6tSjM4wC+Kecaa1EUGX7vc6/fddvw/6lg90z4QtCqm21zvVe92vMMDt9+DkIvjXImQQ==", + "license": "Apache-2.0", + "engines": { + "node": ">=16.11.0" + } + }, + "node_modules/@discordjs/formatters": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/@discordjs/formatters/-/formatters-0.6.2.tgz", + "integrity": "sha512-y4UPwWhH6vChKRkGdMB4odasUbHOUwy7KL+OVwF86PvT6QVOwElx+TiI1/6kcmcEe+g5YRXJFiXSXUdabqZOvQ==", + "license": "Apache-2.0", + "dependencies": { + "discord-api-types": "^0.38.33" + }, + "engines": { + "node": ">=16.11.0" + }, + "funding": { + "url": "https://github.com/discordjs/discord.js?sponsor" + } + }, + "node_modules/@discordjs/rest": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/@discordjs/rest/-/rest-2.6.0.tgz", + "integrity": "sha512-RDYrhmpB7mTvmCKcpj+pc5k7POKszS4E2O9TYc+U+Y4iaCP+r910QdO43qmpOja8LRr1RJ0b3U+CqVsnPqzf4w==", + "license": "Apache-2.0", + "dependencies": { + "@discordjs/collection": "^2.1.1", + "@discordjs/util": "^1.1.1", + "@sapphire/async-queue": "^1.5.3", + "@sapphire/snowflake": "^3.5.3", + "@vladfrangu/async_event_emitter": "^2.4.6", + "discord-api-types": "^0.38.16", + "magic-bytes.js": "^1.10.0", + "tslib": "^2.6.3", + "undici": "6.21.3" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/discordjs/discord.js?sponsor" + } + }, + "node_modules/@discordjs/rest/node_modules/@discordjs/collection": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-2.1.1.tgz", + "integrity": "sha512-LiSusze9Tc7qF03sLCujF5iZp7K+vRNEDBZ86FT9aQAv3vxMLihUvKvpsCWiQ2DJq1tVckopKm1rxomgNUc9hg==", + "license": "Apache-2.0", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/discordjs/discord.js?sponsor" + } + }, + "node_modules/@discordjs/rest/node_modules/undici": { + "version": "6.21.3", + "resolved": "https://registry.npmjs.org/undici/-/undici-6.21.3.tgz", + "integrity": "sha512-gBLkYIlEnSp8pFbT64yFgGE6UIB9tAkhukC23PmMDCe5Nd+cRqKxSjw5y54MK2AZMgZfJWMaNE4nYUHgi1XEOw==", + "license": "MIT", + "engines": { + "node": ">=18.17" + } + }, + "node_modules/@discordjs/util": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@discordjs/util/-/util-1.2.0.tgz", + "integrity": "sha512-3LKP7F2+atl9vJFhaBjn4nOaSWahZ/yWjOvA4e5pnXkt2qyXRCHLxoBQy81GFtLGCq7K9lPm9R517M1U+/90Qg==", + "license": "Apache-2.0", + "dependencies": { + "discord-api-types": "^0.38.33" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/discordjs/discord.js?sponsor" + } + }, + "node_modules/@discordjs/ws": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/@discordjs/ws/-/ws-1.2.3.tgz", + "integrity": "sha512-wPlQDxEmlDg5IxhJPuxXr3Vy9AjYq5xCvFWGJyD7w7Np8ZGu+Mc+97LCoEc/+AYCo2IDpKioiH0/c/mj5ZR9Uw==", + "license": "Apache-2.0", + "dependencies": { + "@discordjs/collection": "^2.1.0", + "@discordjs/rest": "^2.5.1", + "@discordjs/util": "^1.1.0", + "@sapphire/async-queue": "^1.5.2", + "@types/ws": "^8.5.10", + "@vladfrangu/async_event_emitter": "^2.2.4", + "discord-api-types": "^0.38.1", + "tslib": "^2.6.2", + "ws": "^8.17.0" + }, + "engines": { + "node": ">=16.11.0" + }, + "funding": { + "url": "https://github.com/discordjs/discord.js?sponsor" + } + }, + "node_modules/@discordjs/ws/node_modules/@discordjs/collection": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-2.1.1.tgz", + "integrity": "sha512-LiSusze9Tc7qF03sLCujF5iZp7K+vRNEDBZ86FT9aQAv3vxMLihUvKvpsCWiQ2DJq1tVckopKm1rxomgNUc9hg==", + "license": "Apache-2.0", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/discordjs/discord.js?sponsor" + } + }, + "node_modules/@sapphire/async-queue": { + "version": "1.5.5", + "resolved": "https://registry.npmjs.org/@sapphire/async-queue/-/async-queue-1.5.5.tgz", + "integrity": "sha512-cvGzxbba6sav2zZkH8GPf2oGk9yYoD5qrNWdu9fRehifgnFZJMV+nuy2nON2roRO4yQQ+v7MK/Pktl/HgfsUXg==", + "license": "MIT", + "engines": { + "node": ">=v14.0.0", + "npm": ">=7.0.0" + } + }, + "node_modules/@sapphire/shapeshift": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@sapphire/shapeshift/-/shapeshift-4.0.0.tgz", + "integrity": "sha512-d9dUmWVA7MMiKobL3VpLF8P2aeanRTu6ypG2OIaEv/ZHH/SUQ2iHOVyi5wAPjQ+HmnMuL0whK9ez8I/raWbtIg==", + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.3", + "lodash": "^4.17.21" + }, + "engines": { + "node": ">=v16" + } + }, + "node_modules/@sapphire/snowflake": { + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/@sapphire/snowflake/-/snowflake-3.5.3.tgz", + "integrity": "sha512-jjmJywLAFoWeBi1W7994zZyiNWPIiqRRNAmSERxyg93xRGzNYvGjlZ0gR6x0F4gPRi2+0O6S71kOZYyr3cxaIQ==", + "license": "MIT", + "engines": { + "node": ">=v14.0.0", + "npm": ">=7.0.0" + } + }, "node_modules/@socket.io/component-emitter": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/@socket.io/component-emitter/-/component-emitter-3.1.2.tgz", @@ -75,6 +249,25 @@ "@types/node": "*" } }, + "node_modules/@types/ws": { + "version": "8.18.1", + "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.18.1.tgz", + "integrity": "sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg==", + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@vladfrangu/async_event_emitter": { + "version": "2.4.7", + "resolved": "https://registry.npmjs.org/@vladfrangu/async_event_emitter/-/async_event_emitter-2.4.7.tgz", + "integrity": "sha512-Xfe6rpCTxSxfbswi/W/Pz7zp1WWSNn4A0eW4mLkQUewCrXXtMj31lCg+iQyTkh/CkusZSq9eDflu7tjEDXUY6g==", + "license": "MIT", + "engines": { + "node": ">=v14.0.0", + "npm": ">=7.0.0" + } + }, "node_modules/@xboxreplay/errors": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/@xboxreplay/errors/-/errors-0.1.0.tgz", @@ -231,6 +424,51 @@ "integrity": "sha512-c68LpLbO+7kP/b1Hr1qs8/BJ09F5khZGTxqxZuhzxpmwJKOgRFHJWIb9/KmqnqHhLdO55aOxFH/EGBvUQbL/RQ==", "license": "MIT" }, + "node_modules/discord-api-types": { + "version": "0.38.37", + "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.38.37.tgz", + "integrity": "sha512-Cv47jzY1jkGkh5sv0bfHYqGgKOWO1peOrGMkDFM4UmaGMOTgOW8QSexhvixa9sVOiz8MnVOBryWYyw/CEVhj7w==", + "license": "MIT", + "workspaces": [ + "scripts/actions/documentation" + ] + }, + "node_modules/discord.js": { + "version": "14.25.1", + "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-14.25.1.tgz", + "integrity": "sha512-2l0gsPOLPs5t6GFZfQZKnL1OJNYFcuC/ETWsW4VtKVD/tg4ICa9x+jb9bkPffkMdRpRpuUaO/fKkHCBeiCKh8g==", + "license": "Apache-2.0", + "dependencies": { + "@discordjs/builders": "^1.13.0", + "@discordjs/collection": "1.5.3", + "@discordjs/formatters": "^0.6.2", + "@discordjs/rest": "^2.6.0", + "@discordjs/util": "^1.2.0", + "@discordjs/ws": "^1.2.3", + "@sapphire/snowflake": "3.5.3", + "discord-api-types": "^0.38.33", + "fast-deep-equal": "3.1.3", + "lodash.snakecase": "4.1.1", + "magic-bytes.js": "^1.10.0", + "tslib": "^2.6.3", + "undici": "6.21.3" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/discordjs/discord.js?sponsor" + } + }, + "node_modules/discord.js/node_modules/undici": { + "version": "6.21.3", + "resolved": "https://registry.npmjs.org/undici/-/undici-6.21.3.tgz", + "integrity": "sha512-gBLkYIlEnSp8pFbT64yFgGE6UIB9tAkhukC23PmMDCe5Nd+cRqKxSjw5y54MK2AZMgZfJWMaNE4nYUHgi1XEOw==", + "license": "MIT", + "engines": { + "node": ">=18.17" + } + }, "node_modules/ecdsa-sig-formatter": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz", @@ -404,6 +642,12 @@ "safe-buffer": "^5.0.1" } }, + "node_modules/lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", + "license": "MIT" + }, "node_modules/lodash.includes": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz", @@ -458,18 +702,29 @@ "integrity": "sha512-6raRe2vxCYBhpBu+B+TtNGUzah+hQjVdu3E17wfusjyrXBka2nBS8OH/gjVZ5PvHOhWmIZTYri09Z6n/QfnNMw==", "license": "MIT" }, + "node_modules/lodash.snakecase": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/lodash.snakecase/-/lodash.snakecase-4.1.1.tgz", + "integrity": "sha512-QZ1d4xoBHYUeuouhEq3lk3Uq7ldgyFXGBhg04+oRLnIz8o9T65Eh+8YdroUwn846zchkA9yDsDl5CVVaV2nqYw==", + "license": "MIT" + }, "node_modules/macaddress": { "version": "0.5.3", "resolved": "https://registry.npmjs.org/macaddress/-/macaddress-0.5.3.tgz", "integrity": "sha512-vGBKTA+jwM4KgjGZ+S/8/Mkj9rWzePyGY6jManXPGhiWu63RYwW8dKPyk5koP+8qNVhPhHgFa1y/MJ4wrjsNrg==", "license": "MIT" }, + "node_modules/magic-bytes.js": { + "version": "1.12.1", + "resolved": "https://registry.npmjs.org/magic-bytes.js/-/magic-bytes.js-1.12.1.tgz", + "integrity": "sha512-ThQLOhN86ZkJ7qemtVRGYM+gRgR8GEXNli9H/PMvpnZsE44Xfh3wx9kGJaldg314v85m+bFW6WBMaVHJc/c3zA==", + "license": "MIT" + }, "node_modules/minecraft-data": { "version": "3.101.0", "resolved": "https://registry.npmjs.org/minecraft-data/-/minecraft-data-3.101.0.tgz", "integrity": "sha512-9kD2sbI9BvjQtN/ZlMkCdgaLJIHPXDGruMEJ0DOO29RB9sVDmSBLjDkH9PyRmlAye/WZlqk/1/b54vWq6ObzxQ==", - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/minecraft-folder-path": { "version": "1.2.0", @@ -627,25 +882,6 @@ "prismarine-registry": "^1.4.0" } }, - "node_modules/prismarine-chunk": { - "version": "1.39.0", - "resolved": "https://registry.npmjs.org/prismarine-chunk/-/prismarine-chunk-1.39.0.tgz", - "integrity": "sha512-RJHACPV2T3ABGlj0+q/ZUDBLPcslWTIa12lWyE2jJb/svqpTBx8S/K6VjHxhyJ488L9ZWdEmOAr+CHMZJtwWHw==", - "license": "MIT", - "dependencies": { - "prismarine-biome": "^1.2.0", - "prismarine-block": "^1.14.1", - "prismarine-nbt": "^2.2.1", - "prismarine-registry": "^1.1.0", - "smart-buffer": "^4.1.0", - "uint4": "^0.1.2", - "vec3": "^0.1.3", - "xxhash-wasm": "^0.4.2" - }, - "engines": { - "node": ">=14" - } - }, "node_modules/prismarine-item": { "version": "1.17.0", "resolved": "https://registry.npmjs.org/prismarine-item/-/prismarine-item-1.17.0.tgz", @@ -657,9 +893,9 @@ } }, "node_modules/prismarine-nbt": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/prismarine-nbt/-/prismarine-nbt-2.7.0.tgz", - "integrity": "sha512-Du9OLQAcCj3y29YtewOJbbV4ARaSUEJiTguw0PPQbPBy83f+eCyDRkyBpnXTi/KPyEpgYCzsjGzElevLpFoYGQ==", + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/prismarine-nbt/-/prismarine-nbt-2.8.0.tgz", + "integrity": "sha512-5D6FUZq0PNtf3v/41ImDlwThVesOv5adyqCRMZLzmkUGEmRJNNh5C6AsnvrClBftXs+IF0yqPnZoj8kcNPiMGg==", "license": "MIT", "dependencies": { "protodef": "^1.18.0" @@ -680,7 +916,6 @@ "resolved": "https://registry.npmjs.org/prismarine-registry/-/prismarine-registry-1.11.0.tgz", "integrity": "sha512-uTvWE+bILxYv4i5MrrlxPQ0KYWINv1DJ3P2570GLC8uCdByDiDLBFfVyk4BrqOZBlDBft9CnaJMeOsC1Ly1iXw==", "license": "MIT", - "peer": true, "dependencies": { "minecraft-data": "^3.70.0", "prismarine-block": "^1.17.1", @@ -918,12 +1153,27 @@ "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", "license": "MIT" }, - "node_modules/uint4": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/uint4/-/uint4-0.1.2.tgz", - "integrity": "sha512-lhEx78gdTwFWG+mt6cWAZD/R6qrIj0TTBeH5xwyuDJyswLNlGe+KVlUPQ6+mx5Ld332pS0AMUTo9hIly7YsWxQ==", + "node_modules/ts-mixer": { + "version": "6.0.4", + "resolved": "https://registry.npmjs.org/ts-mixer/-/ts-mixer-6.0.4.tgz", + "integrity": "sha512-ufKpbmrugz5Aou4wcr5Wc1UUFWOLhq+Fm6qa6P0w0K5Qw2yhaUoiWszhCVuNQyNwrlGiscHOmqYoAox1PtvgjA==", "license": "MIT" }, + "node_modules/tslib": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "license": "0BSD" + }, + "node_modules/undici": { + "version": "7.18.2", + "resolved": "https://registry.npmjs.org/undici/-/undici-7.18.2.tgz", + "integrity": "sha512-y+8YjDFzWdQlSE9N5nzKMT3g4a5UBX1HKowfdXh0uvAnTaqqwqB92Jt4UXBAeKekDs5IaDKyJFR4X1gYVCgXcw==", + "license": "MIT", + "engines": { + "node": ">=20.18.1" + } + }, "node_modules/undici-types": { "version": "7.16.0", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.16.0.tgz", @@ -1008,12 +1258,6 @@ "node": ">=0.4.0" } }, - "node_modules/xxhash-wasm": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/xxhash-wasm/-/xxhash-wasm-0.4.2.tgz", - "integrity": "sha512-/eyHVRJQCirEkSZ1agRSCwriMhwlyUcFkXD5TPVSLP+IPzjsqMVzZwdoczLp1SoQU0R3dxz1RpIK+4YNQbCVOA==", - "license": "MIT" - }, "node_modules/yaml": { "version": "2.8.2", "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.8.2.tgz", diff --git a/package.json b/package.json index 96b1f53..4daf967 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,15 @@ { "dependencies": { + "discord.js": "^14.25.1", "minecraft-protocol": "^1.62.0", + "mojangson": "^2.0.4", "prismarine-chat": "^1.12.0", - "prismarine-chunk": "^1.39.0", + "prismarine-nbt": "^2.8.0", "prismarine-registry": "^1.11.0", "prismarine-world": "^3.6.3", "smol-toml": "^1.5.2", "socket.io-client": "^4.8.1", - "vec3": "^0.1.10", + "undici": "^7.18.2", "yaml": "^2.8.2" }, "devDependencies": { diff --git a/tsconfig.json b/tsconfig.json index 7405015..27a0b29 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,7 @@ { + "exclude": ["./build", "config.js", "./convertYaodesHardcode.js", "./bot.old"], "compilerOptions": { + "useUnknownInCatchVariables": false, "rootDir": "./bot", "outDir": "./build", "module": "commonjs", @@ -21,5 +23,4 @@ "esModuleInterop": true, "strictPropertyInitialization": false, }, - "exclude": ["./build", "./memoryTest.js"] -} +} \ No newline at end of file