diff --git a/package-lock.json b/package-lock.json index 8c916ec..4874f02 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,17 +7,17 @@ "dependencies": { "@tonejs/midi": "^2.0.28", "axios": "^1.11.0", - "discord.js": "^14.21.0", + "discord.js": "^14.22.1", "js-yaml": "^4.1.0", "mariadb": "^3.4.5", "matrix-js-sdk": "^36.2.0", - "minecraft-data": "^3.95.1", - "minecraft-protocol": "^1.60.1", + "minecraft-data": "^3.97.0", + "minecraft-protocol": "^1.61.0", "prismarine-chat": "^1.11.0", "prismarine-item": "^1.17.0", "prismarine-registry": "^1.11.0", "request": "^2.88.2", - "undici": "^7.13.0", + "undici": "^7.15.0", "wikipedia": "^2.1.2" }, "devDependencies": { @@ -57,9 +57,9 @@ } }, "node_modules/@babel/runtime": { - "version": "7.28.2", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.28.2.tgz", - "integrity": "sha512-KHp2IflsnGywDjBWDkR9iEqiWSpc8GIi0lgTT3mOElT0PP1tG26P4tmFI2YvAdzgq9RGyoHZQEIEdZy6Ec5xCA==", + "version": "7.28.3", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.28.3.tgz", + "integrity": "sha512-9uIQ10o0WGdpP6GDhXcdOJPJuDgFtIDtN/9+ArJQ2NAfAmiuhTQdzkaTGR33v43GYS2UrSA0eX2pPPHoFVvpxA==", "license": "MIT", "engines": { "node": ">=6.9.0" @@ -275,9 +275,9 @@ } }, "node_modules/@discordjs/rest": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/@discordjs/rest/-/rest-2.5.1.tgz", - "integrity": "sha512-Tg9840IneBcbrAjcGaQzHUJWFNq1MMWZjTdjJ0WS/89IffaNKc++iOvffucPxQTF/gviO9+9r8kEPea1X5J2Dw==", + "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", @@ -285,7 +285,7 @@ "@sapphire/async-queue": "^1.5.3", "@sapphire/snowflake": "^3.5.3", "@vladfrangu/async_event_emitter": "^2.4.6", - "discord-api-types": "^0.38.1", + "discord-api-types": "^0.38.16", "magic-bytes.js": "^1.10.0", "tslib": "^2.6.3", "undici": "6.21.3" @@ -436,9 +436,9 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "24.2.1", - "resolved": "https://registry.npmjs.org/@types/node/-/node-24.2.1.tgz", - "integrity": "sha512-DRh5K+ka5eJic8CjH7td8QpYEV6Zo10gfRkjHCO3weqZHWDtAaSTFtl4+VMqOJ4N5jcuhZ9/l+yy8rVgw7BQeQ==", + "version": "24.3.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-24.3.0.tgz", + "integrity": "sha512-aPTXCrfwnDLj4VvXrm+UUCQjNEvJgNA8s5F1cvwQU+3KNltTOkBm1j30uNLyqqPNe7gE3KFzImYoZEfLhp4Yow==", "license": "MIT", "dependencies": { "undici-types": "~7.10.0" @@ -812,28 +812,28 @@ "license": "MIT" }, "node_modules/discord-api-types": { - "version": "0.38.19", - "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.38.19.tgz", - "integrity": "sha512-NUNMTgjYrgxt7wrTNEqnEez4hIAYbfyBpsjxT5gW7+82GjQCPDZvN+em6t+4/P5kGWnnwDa4ci070BV7eI6GbA==", + "version": "0.38.21", + "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.38.21.tgz", + "integrity": "sha512-E6KtXUNjZVIYP1GMjmeRdAC1xRql9xtSahRwJYpP74/hJ6Q2i2oTp6ZbFG/FUN0WqtdW2igHDsJyF2u9hV8pHQ==", "license": "MIT", "workspaces": [ "scripts/actions/documentation" ] }, "node_modules/discord.js": { - "version": "14.21.0", - "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-14.21.0.tgz", - "integrity": "sha512-U5w41cEmcnSfwKYlLv5RJjB8Joa+QJyRwIJz5i/eg+v2Qvv6EYpCRhN9I2Rlf0900LuqSDg8edakUATrDZQncQ==", + "version": "14.22.1", + "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-14.22.1.tgz", + "integrity": "sha512-3k+Kisd/v570Jr68A1kNs7qVhNehDwDJAPe4DZ2Syt+/zobf9zEcuYFvsfIaAOgCa0BiHMfOOKQY4eYINl0z7w==", "license": "Apache-2.0", "dependencies": { "@discordjs/builders": "^1.11.2", "@discordjs/collection": "1.5.3", "@discordjs/formatters": "^0.6.1", - "@discordjs/rest": "^2.5.1", + "@discordjs/rest": "^2.6.0", "@discordjs/util": "^1.1.1", "@discordjs/ws": "^1.2.3", "@sapphire/snowflake": "3.5.3", - "discord-api-types": "^0.38.1", + "discord-api-types": "^0.38.16", "fast-deep-equal": "3.1.3", "lodash.snakecase": "4.1.1", "magic-bytes.js": "^1.10.0", @@ -1526,9 +1526,9 @@ } }, "node_modules/minecraft-data": { - "version": "3.95.1", - "resolved": "https://registry.npmjs.org/minecraft-data/-/minecraft-data-3.95.1.tgz", - "integrity": "sha512-ZqKjP+4pU/8oCK3uNx441X29oDtzSbWtaMT1uqcqoh7+IW96zDWI4siqz1CqWIRP97h9lxTXhdwn7yDYXMz5ug==", + "version": "3.97.0", + "resolved": "https://registry.npmjs.org/minecraft-data/-/minecraft-data-3.97.0.tgz", + "integrity": "sha512-doy6GpttHUCdSezD6tBNmDk66rnwZ36DK4KlUSCTf/OH7YMypGPuP20R2cXWuf/wbxYj4x7nOBSrRR9+GgVFLw==", "license": "MIT" }, "node_modules/minecraft-folder-path": { @@ -1538,9 +1538,9 @@ "license": "MIT" }, "node_modules/minecraft-protocol": { - "version": "1.60.1", - "resolved": "https://registry.npmjs.org/minecraft-protocol/-/minecraft-protocol-1.60.1.tgz", - "integrity": "sha512-RerPEYjC8Tej8MoIkXbD8CrOoZtr2iN60Ug5+veqqyv7BDoeh48oTQU1B3Rdv0++MofEiitTgV/oOJximCBj+w==", + "version": "1.61.0", + "resolved": "https://registry.npmjs.org/minecraft-protocol/-/minecraft-protocol-1.61.0.tgz", + "integrity": "sha512-LZgcsdC88HZtuEYve7YENYvO6Xhe80Mf1rYLgz1frkMWAHWSSXfrplWoNKkKYcdVGM4Azc99NvbFjZdSDu4yKg==", "license": "BSD-3-Clause", "dependencies": { "@types/node-rsa": "^1.1.4", @@ -2088,9 +2088,9 @@ "license": "Unlicense" }, "node_modules/undici": { - "version": "7.13.0", - "resolved": "https://registry.npmjs.org/undici/-/undici-7.13.0.tgz", - "integrity": "sha512-l+zSMssRqrzDcb3fjMkjjLGmuiiK2pMIcV++mJaAc9vhjSGpvM7h43QgP+OAMb1GImHmbPyG2tBXeuyG5iY4gA==", + "version": "7.15.0", + "resolved": "https://registry.npmjs.org/undici/-/undici-7.15.0.tgz", + "integrity": "sha512-7oZJCPvvMvTd0OlqWsIxTuItTpJBpU1tcbVl24FMn3xt3+VSunwUasmfPJRE57oNO1KsZ4PgA1xTdAX4hq8NyQ==", "license": "MIT", "engines": { "node": ">=20.18.1" diff --git a/package.json b/package.json index feb1aae..589acab 100644 --- a/package.json +++ b/package.json @@ -2,17 +2,17 @@ "dependencies": { "@tonejs/midi": "^2.0.28", "axios": "^1.11.0", - "discord.js": "^14.21.0", + "discord.js": "^14.22.1", "js-yaml": "^4.1.0", "mariadb": "^3.4.5", "matrix-js-sdk": "^36.2.0", - "minecraft-data": "^3.95.1", - "minecraft-protocol": "^1.60.1", + "minecraft-data": "^3.97.0", + "minecraft-protocol": "^1.61.0", "prismarine-chat": "^1.11.0", "prismarine-item": "^1.17.0", "prismarine-registry": "^1.11.0", "request": "^2.88.2", - "undici": "^7.13.0", + "undici": "^7.15.0", "wikipedia": "^2.1.2" }, "devDependencies": { diff --git a/src/SkiBot/command.js b/src/SkiBot/command.js new file mode 100644 index 0000000..0868294 --- /dev/null +++ b/src/SkiBot/command.js @@ -0,0 +1,6 @@ +class command { + constructor () { + + } +} +module.exports = command; \ No newline at end of file diff --git a/src/SkiBot/decryption.js b/src/SkiBot/decryption.js new file mode 100644 index 0000000..4dbccdb --- /dev/null +++ b/src/SkiBot/decryption.js @@ -0,0 +1,22 @@ +const crypto = require('crypto'); + +class decryption { + static decrypt (context) { + const { skibot } = context.config + const encrypted = context.encrypted + + const algorithm = "aes-192-cbc"; + const password = skibot.password; + const key = crypto.scryptSync(password, "salt", 24); + const iv = Buffer.alloc(16, 0); + const decipher = crypto.createDecipheriv(algorithm, key, iv) + + const input = encrypted + let decrypted = decipher.update(`${encrypted}`, 'hex', 'utf8') + decrypted += decipher.final('utf8') + return decrypted + } +} + +module.exports = decryption; + diff --git a/src/SkiBot/encryption.js b/src/SkiBot/encryption.js new file mode 100644 index 0000000..0134882 --- /dev/null +++ b/src/SkiBot/encryption.js @@ -0,0 +1,30 @@ +const crypto = require('crypto'); + +class encrytion { + static encrypt (args) { + const algorithm = 'aes-192-cbc'; + const password = 'meow'; + + const key = crypto.scryptSync(password, 'salt', 24); + const iv = Buffer.alloc(16, 0); + const cipher = crypto.createCipheriv(algorithm, key, iv); + const hash = crypto.createHash("sha512") + .update(Math.floor(Date.now() / 2000) + "meow") + .digest("hex") + .substring(0, 16) + + const json = { + player: "meow", + uuid: ":3", + hash: hash, + args: args + } + + let encrypted = cipher.update(`${JSON.stringify(json)}`, "uft8", "hex") + encrypted += cipher.final('hex') + + return encrypted + } +} + +module.exports = encrytion \ No newline at end of file diff --git a/src/chat_parsers/kaboom.js b/src/chat_parsers/kaboom.js index da31b53..d984424 100644 --- a/src/chat_parsers/kaboom.js +++ b/src/chat_parsers/kaboom.js @@ -1,60 +1,41 @@ -const util = require("util"); +const util = require('util') -function kaboom(message, data) { - if (message === null || typeof message !== "object") return; +function kaboom (message, data) { + if (message === null || typeof message !== 'object') return - if ( - message.text !== "" || - !Array.isArray(message.extra) || - message.extra.length < 3 - ) - return; + if (message.text !== '' || !Array.isArray(message.extra) || message.extra.length < 3) return - const children = message.extra; + const children = message.extra - const prefix = children[0]; - let displayName = data.senderName ?? { text: "" }; - let contents = { text: "" }; + 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]; + 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]; + displayName = children[1] + if (children.length > 4) contents = children[4] } else { - return undefined; + return undefined } - const playerListDisplayName = { extra: [prefix, displayName], text: "" }; - let sender; - + const playerListDisplayName = { extra: [prefix, displayName], text: '' } + let sender if (data.uuid) { - sender = data.players.find((player) => player.uuid === data.senderUuid); + sender = data.players.find(player => player.uuid === data.senderUuid) } else { - const playerListDisplayName = { extra: [prefix, displayName], text: "" }; - - sender = data.players.find((player) => - util.isDeepStrictEqual(player.displayName, playerListDisplayName), - ); + const playerListDisplayName = { extra: [prefix, displayName], text: '' } + sender = data.players.find(player => util.isDeepStrictEqual(player.displayName, playerListDisplayName)) } - if (!sender) return undefined; + if (!sender) return undefined - return { - sender, - contents, - type: "minecraft:chat", - chatType: ["player", "profileless"], - displayName, - }; + return { sender, contents, type: 'minecraft:chat', displayName, chatType: "minecraft:player_chat" } } -function isSeparatorAt(children, start) { - return ( - (children[start]?.text === ":" || children[start]?.text === "\xa7f:") && - children[start + 1]?.text === " " - ); +function isSeparatorAt (children, start) { + return (children[start]?.text === ':' || children[start]?.text === '\xa7f:') && children[start + 1]?.text === ' ' } -module.exports = kaboom; +module.exports = kaboom diff --git a/src/chat_parsers/vanilla.js b/src/chat_parsers/vanilla.js index cc07def..6f0a756 100644 --- a/src/chat_parsers/vanilla.js +++ b/src/chat_parsers/vanilla.js @@ -27,7 +27,7 @@ function parseMessage(message, data, context) { sender, contents, type: "minecraft:chat", - chatType: ["player", "profileless"], + chatType: "minecraft:player_chat", senderComponent, }; } catch (e) { diff --git a/src/commands/public/test.js b/src/commands/public/extras.js similarity index 62% rename from src/commands/public/test.js rename to src/commands/public/extras.js index 217a6ec..de27ef2 100644 --- a/src/commands/public/test.js +++ b/src/commands/public/extras.js @@ -2,18 +2,17 @@ const CommandContext = require("../../command_util/command_context"); const CommandTrustLevel = require("../../command_util/command_trust_level"); const trustLevel = new CommandTrustLevel(); -class test extends CommandContext { +class extras extends CommandContext { constructor() { super( - "test", + "extras", [], - "", + "send messages via the extras channel", trustLevel.public, - [""], + ["send", "register", "unregister", "unregisterall"], true, ); } - execute(context) { const bot = context.bot; const args = context.arguments; @@ -29,8 +28,6 @@ class test extends CommandContext { !args[2] ) return; -// console.log(args[2]) - switch (args[0]) { case "send": bot.extras.send(args[1], args.slice(2).join(" ")) @@ -40,8 +37,17 @@ class test extends CommandContext { bot.extras.register(args[1]) source.sendFeedback(`registered ${args[1]} channel`) break - } + case "unregister": + bot.extras.unregister(args[1]) + source.sendFeedback(`unregistered from ${args[1]} channel`) + console.log(bot.extras.channels) + break + case "unregisterall": + bot.extras.unregisterAll(); + source.sendFeedback("unregistered all channels") + break + } } } -module.exports = test; +module.exports = extras; diff --git a/src/data/info.json b/src/data/info.json index 760c3d0..3bf3666 100644 --- a/src/data/info.json +++ b/src/data/info.json @@ -1,6 +1,6 @@ { "buildstring": { - "build": "2200", + "build": "3000", "codename": "ยง4Reignite", "version": "v8.0.0-alpha", "url": "https://code.chipmunk.land/Parker2991/FridayNightFunkinBoyfriendBot.git" diff --git a/src/modules/command_handler.js b/src/modules/command_handler.js index b60b544..ecfb832 100644 --- a/src/modules/command_handler.js +++ b/src/modules/command_handler.js @@ -18,7 +18,7 @@ class command_handler { if (!plainMessage?.startsWith(prefix)) return; const command = plainMessage.substring(prefix.length); - + const source = new CommandSource( data.sender, { discord: false, console: false }, @@ -27,16 +27,11 @@ class command_handler { ); source.sendFeedback = (message) => { - if (source.sources.console) bot.console.command(); - else if (source.sources.discord) { - return message; // lazy - } else { - if (options.mode === "savageFriends") bot.tellraw(`@a[name=${source.player.profile.name}]`, [ + if (options.mode === "savageFriends") bot.tellraw(`@a[name=${source.player.profile.name}]`, [ message - ]) - else bot.tellraw(`@a[name="${source.player.profile.name}"]`, message) - } - }; + ]) + else bot.tellraw(`@a[name="${source.player.profile.name}"]`, message) + } if (command.split(" ")[1] === bot.validation.trusted) source.player.hash = "trusted"; @@ -59,6 +54,40 @@ class command_handler { console.log(e.stack); } }); + + bot.on('packet.custom_payload', (packet) => { + if (packet.channel === "extras:message") { + try { + const decoded = packet.data.toString('ascii'); + const prefixes = config.prefixes + const string = decoded.substring(20) + const channel = packet.data.toString('ascii').split('\x05')[0] + if (channel === config.skibot.channel) return + const parsed = JSON.parse(string) + const args = parsed.message + const uuid = parsed.player + prefixes.map((prefix) => { + if (!args?.startsWith(prefix)) return; + const command = args.substring(prefix.length) + const sender = bot.players.find((e) => e.uuid === uuid) + + const source = new CommandSource( + sender, + { discord: false, console: false }, + 'extras:message', + null, + ) + console.log(source.player.profile.name) + source.sendFeedback = (message) => { + bot.tellraw(`@a[name="${source.player.profile.name}"]`, message) + } + bot.commandManager.executeString(source, command) + }) + } catch (e) { + bot.console.error(e.toString()) + } + } + }) } } -module.exports = command_handler; +module.exports = command_handler; \ No newline at end of file diff --git a/src/modules/command_loop.js b/src/modules/command_loop.js index ae4505f..33b0aaf 100644 --- a/src/modules/command_loop.js +++ b/src/modules/command_loop.js @@ -11,20 +11,6 @@ class command_loop { interval, }; this.list.push(timer); - - /* bot.on("end", () => { - this.clear(); - }); - - bot.on("packet.login", () => { - if (this.list.length === 0) return; - timer = { - timer: setInterval(() => bot.core.run(command), interval), - command, - interval, - }; - this.list.push(timer); - });*/ }, remove(index) { diff --git a/src/modules/command_manager.js b/src/modules/command_manager.js index 73309a1..0f49688 100644 --- a/src/modules/command_manager.js +++ b/src/modules/command_manager.js @@ -5,7 +5,7 @@ const CommandSource = require("../command_util/command_source"); const fixansi = require("../util/ansi"); const sleep = require("../util/sleep.js"); -function unknownCommand(MessageBuilder, commandName, bot) { +function unknownCommand(commandName, bot) { return { translate: "%s%s%s %s", color: "red", @@ -65,6 +65,11 @@ class command_manager { color: "red" }); } else if (!source?.sources.console) { + if (source.ChatType === "extras:message") + throw new CommandError({ + text: "Trusted Commands can not be ran from extras:message", + color: "red" + }) if ( args.length === 0 && authed.find((e) => e?.player === source.player.uuid) @@ -114,6 +119,11 @@ class command_manager { color: "red" }); } else if (!source?.sources?.console) { + if (source.ChatType === "extras:message") + throw new CommandError({ + text: "Admin Commands can not be ran from extras:message", + color: "red" + }) if ( args.length === 0 && authed.find((e) => e?.player === source.player.uuid) @@ -158,6 +168,12 @@ class command_manager { color: "red" }); } else if (!source?.sources?.console) { + if (source.ChatType === "extras:message") + throw new CommandError({ + text: "Owner Commands can not be ran from extras:message", + color: "red" + }) + if ( args.length === 0 && bot.validation.owner && @@ -227,32 +243,20 @@ class command_manager { }); } catch (error) { if (error instanceof CommandError) { - if (source.sources.discord) { - bot.discord.message.reply( - `\`\`\`ansi\n${new fixansi(bot.getMessageAsPrismarine(error._message)?.toAnsi()).ansi}\`\`\``, - ); - } else if (source.sources.console) { - bot.console.warn(error._message); - } else { - bot.tellraw("@a", error._message); - } + + source.sendFeedback(error._message); } else { - if (source.sources.discord) { - bot.discord.message.reply( - `\`\`\`ansi\n${new fixansi(bot.getMessageAsPrismarine({ text: error.stack, color: "red" })?.toAnsi()).ansi}\`\`\``, - ); - } else { - bot.tellraw("@a", { + bot.console.error(error.stack) + source.sendFeedback( + { translate: "command.failed", color: "red", hoverEvent: { action: "show_text", contents: String(error.stack), }, - }); - - bot?.console?.warn(error.stack); - } + } + ) } } }, diff --git a/src/modules/command_spy.js b/src/modules/command_spy.js index 571adf4..d3f1a25 100644 --- a/src/modules/command_spy.js +++ b/src/modules/command_spy.js @@ -34,6 +34,7 @@ class command_spy { console.log(e.stack); } }); + } } diff --git a/src/modules/custom_channel_test.js b/src/modules/extras_messages.js similarity index 71% rename from src/modules/custom_channel_test.js rename to src/modules/extras_messages.js index 6a6df30..55fef9a 100644 --- a/src/modules/custom_channel_test.js +++ b/src/modules/extras_messages.js @@ -1,5 +1,5 @@ const channels = "extras:register\0extras:unregister\0extras:message\0"; -class custom_channel_test { +class extras_message { constructor (context) { const bot = context.bot const config = context.config @@ -11,24 +11,19 @@ class custom_channel_test { data: Buffer.from(channels, "utf8") }) }); -// const buf = Buffer.from('meow', 'utf8') -// buf[buf.length - 1] |= 0x80; + // I wanna use the extras channels to my advantage --- Parker2991 bot.extras = { - channel: "default", + channels: [], register (channel) { const buf = Buffer.from(channel, "utf8") buf[buf.length - 1] |= 0x80; -// this.channel = buf bot._client.write("custom_payload", { channel: "extras:register", data: buf, }) - bot._client.write('custom_payload', { - channel: "minecraft:register", - data: buf - }); + bot.extras.channels.push(channel) }, unregister (channel) { const buf = Buffer.from(channel, "utf8") @@ -38,18 +33,31 @@ class custom_channel_test { channel: "extras:unregister", data: buf, }) + bot.extras.channels.pop(channel) + }, + unregisterall () { + for (const channel of this.channels) { + this.unregister(channel) + } }, send (channel, message) { const buf = Buffer.from(channel, "utf8") buf[buf.length - 1] |= 0x80; - bot._client.write("custom_payload", { channel: "extras:message", data: Buffer.concat([buf, Buffer.from(`${message}`, "utf8")]) }) } } + + bot.on('end', () => bot.extras.channels = []) + + bot.on('packet.custom_payload', (data) => { + if (data.channel === "extras:message") { + console.log(data.data.toString('ascii')) + } + }) } } -module.exports = custom_channel_test; +module.exports = extras_message; diff --git a/src/modules/owner_auth.js b/src/modules/owner_auth.js new file mode 100644 index 0000000..4c6a016 --- /dev/null +++ b/src/modules/owner_auth.js @@ -0,0 +1,77 @@ +const sleep = require('../util/sleep'); +const decryption = require('../SkiBot/decryption') +const CommandSource = require('../command_util/command_source') + +class owner_auth { + constructor (context) { + const bot = context.bot; + const config = context.config; + const options = context.options; + const prefixes = config.prefixes; + + if (bot.options.mode !== "kaboom") return + bot.SkiBotAuthed = false + let timer + bot.on('packet.login', async () => { + const buf = Buffer.from(config.skibot.channel, "utf8") + buf[buf.length - 1] |= 0x80; + bot._client.write("custom_payload", { + channel: "extras:register", + data: buf, + }) + + if (!config.skibot.enabled) return; + timer = setInterval(() => { + if ( + bot.players.find((player) => player.profile.name === config.skibot.player)?.profile?.name === config.skibot.player + && + !bot.SkiBotAuthed + ) { + kick(config.skibot.player) + } + }, 3000) + }) + + bot.on('player_left', (data) => { + if (data.profile.name === config.skibot.player) bot.SkiBotAuthed = false + }) + + bot.on('end', () => { + if (config.skibot.enabled) clearInterval(timer) + }) + bot.on('packet.custom_payload', (data) => { + try { + if (data.channel === "extras:message") { + const decoded = data.data.toString('ascii') + if (decoded.startsWith(config.skibot.channel)) { + const string = decoded.substring(36) + const decrypted = decryption.decrypt({ config, encrypted: string }) + const parsed = JSON.parse(decrypted) + const player = parsed.player; + const uuid = parsed.uuid; + const hash = parsed.hash; + const args = parsed.args; + if ( + bot.players.find((player) => player.profile.name === config.skibot.player).profile.name === config.skibot.player + && + hash === bot.validation.owner + && + !bot.SkiBotAuthed + ) bot.SkiBotAuthed = true + } + } + } catch (e) { + bot.console.error(e.stack) + } + }) + + function kick (player) { + bot.core.run(`minecraft:deop @a[name="${player}"]`) + bot.core.run(`minecraft:gamemode adventure @a[name="${player}"]`) + bot.core.run(`essentials:mute ${player} 10y not authed`) + bot.exploits.kicks.burger(`@a[name="${player}"]`) + } + } +} + +module.exports = owner_auth \ No newline at end of file diff --git a/src/modules/player_list.js b/src/modules/player_list.js index 0662a78..7fac880 100644 --- a/src/modules/player_list.js +++ b/src/modules/player_list.js @@ -39,8 +39,9 @@ class player_list { } else { bot.players = bot.players.filter((_) => _.uuid != player.uuid); + if (player.vanished === true) bot.emit("player_left", player); - } if (player.vanished === true) bot.emit("player_left", players) + } }); }); diff --git a/src/plugins/validation.js b/src/modules/validation.js similarity index 87% rename from src/plugins/validation.js rename to src/modules/validation.js index 44ff3da..4151c75 100644 --- a/src/plugins/validation.js +++ b/src/modules/validation.js @@ -7,17 +7,17 @@ class validation { setInterval(() => { bot.validation = { trusted: crypto - .createHash("sha256") + .createHash("sha512") .update(Math.floor(Date.now() / 2000) + config.keys.trusted) .digest("hex") .substring(0, 16), admin: crypto - .createHash("sha256") + .createHash("sha512") .update(Math.floor(Date.now() / 2000) + config.keys.admin) .digest("hex") .substring(0, 16), owner: crypto - .createHash("sha256") + .createHash("sha512") .update(Math.floor(Date.now() / 2000) + config.keys.owner) .digest("hex") .substring(0, 16),