From f6ab36973c3bf2808d9e837b455db6559ca73fcb Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sat, 6 Jul 2024 10:59:34 -0400 Subject: [PATCH 001/362] Initial commit --- .gitignore | 151 +++++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 2 + 2 files changed, 153 insertions(+) create mode 100644 .gitignore create mode 100644 README.md diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f59b42a --- /dev/null +++ b/.gitignore @@ -0,0 +1,151 @@ +# ---> VisualStudioCode +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +!.vscode/*.code-snippets + +# Local History for Visual Studio Code +.history/ + +# Built Visual Studio Code Extensions +*.vsix + +# ---> Kate +# Swap Files # +.*.kate-swp +.swp.* + +# ---> Node +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* +.pnpm-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) +web_modules/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional stylelint cache +.stylelintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variable files +.env +.env.development.local +.env.test.local +.env.production.local +.env.local + +# parcel-bundler cache (https://parceljs.org/) +.cache +.parcel-cache + +# Next.js build output +.next +out + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and not Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# vuepress v2.x temp and cache directory +.temp +.cache + +# Docusaurus cache and generated files +.docusaurus + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port + +# Stores VSCode versions used for testing VSCode extensions +.vscode-test + +# yarn v2 +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* + diff --git a/README.md b/README.md new file mode 100644 index 0000000..aa73dc4 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# botvX + From de780654386bc98dc9ffe3ec2bd1c1e0f86d7395 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sat, 6 Jul 2024 11:02:11 -0400 Subject: [PATCH 002/362] Initial commit --- index.js | 80 ++++ package-lock.json | 830 +++++++++++++++++++++++++++++++++ package.json | 15 + plugins/!chat.js | 50 ++ plugins/command.js | 50 ++ plugins/commandblock.js | 107 +++++ plugins/commands/about.js | 15 + plugins/commands/help.js | 11 + plugins/commands/logoff.js | 9 + plugins/commands/say.js | 23 + plugins/commands/serverinfo.js | 86 ++++ plugins/commands/template.js | 21 + plugins/commands/testing.js | 8 + plugins/console.js | 55 +++ plugins/cq.js | 25 + plugins/rejoin.js | 19 + plugins/sc.js | 34 ++ plugins/sc_op.js | 19 + plugins/testing.js | 8 + settings.json | 22 + util/Command.js | 22 + util/ConsoleCommand.js | 36 ++ util/chatparse.js | 71 +++ util/chatparse_1204.js | 9 + util/timeformat.js | 24 + util/uuidtoint.js | 5 + 26 files changed, 1654 insertions(+) create mode 100755 index.js create mode 100755 package-lock.json create mode 100755 package.json create mode 100755 plugins/!chat.js create mode 100755 plugins/command.js create mode 100755 plugins/commandblock.js create mode 100644 plugins/commands/about.js create mode 100644 plugins/commands/help.js create mode 100644 plugins/commands/logoff.js create mode 100644 plugins/commands/say.js create mode 100755 plugins/commands/serverinfo.js create mode 100644 plugins/commands/template.js create mode 100755 plugins/commands/testing.js create mode 100644 plugins/console.js create mode 100755 plugins/cq.js create mode 100755 plugins/rejoin.js create mode 100755 plugins/sc.js create mode 100755 plugins/sc_op.js create mode 100755 plugins/testing.js create mode 100755 settings.json create mode 100644 util/Command.js create mode 100644 util/ConsoleCommand.js create mode 100644 util/chatparse.js create mode 100644 util/chatparse_1204.js create mode 100755 util/timeformat.js create mode 100644 util/uuidtoint.js diff --git a/index.js b/index.js new file mode 100755 index 0000000..fdcde5a --- /dev/null +++ b/index.js @@ -0,0 +1,80 @@ +const m = require("minecraft-protocol") +const settings = require("./settings.json") +const secret = require(settings.secret) +const EventEmitter = require("node:events") +const crypto = require("crypto") +const fs=require("fs") + +module.exports.bot=[]; + +const generateUser = function generateUser(){ + return "@s["+crypto.randomBytes(2).toString("hex")+"_=\xa7c "+crypto.randomBytes(2).toString("hex") +} + +const loadplug = (botno) => { + const botplug = [] + const bpl = fs.readdirSync('plugins') + for (const i in bpl) { + if (!bpl[i].endsWith('.js')) { + continue + } + try { + botplug.push(require(`./plugins/${bpl[i]}`)) + } catch (e) { console.log(e) } + } + botplug.forEach((plug) => { + try { + if (botno !== undefined) { + if (plug.loadBot) { + plug.loadBot(module.exports.bot[botno]) + } + } else { + plug.load() + } + } catch (e) { console.log(e) } + }) +} +loadplug() + +const createBot = function createBot(host,oldId){ + const bot = new EventEmitter(); + bot._client = m.createClient({ + host: host.host, + port: host.port ? host.port : 25565, + username: generateUser(), + version: settings.version_mc + }) + bot._client.on("success",()=>{ + //console.log(bot); + }) + if(typeof oldId !== "undefined"){ + delete bot[oldId]; + bot.id=oldId; + module.exports.bot[oldId]=bot; + console.log("Re-creating bot "+bot.id) + } else { + bot.id=module.exports.bot.length; + module.exports.bot.push(bot); + console.log("Creating bot "+bot.id) + } + + bot.host=host; + bot.interval={}; + + bot.info=(msg)=>{ + console.log(`[${bot.id}] [info] ${msg}`) + } + /*bot.error=(msg){ + console.log(`[${bot.id}] [error] ${msg}`) + }*/ + loadplug(bot.id); + bot._client.on("error",(err)=>{ + console.log(err) + }) +} + + +for(const i in settings.servers){ + createBot(settings.servers[i]); +} +module.exports.createBot = createBot; diff --git a/package-lock.json b/package-lock.json new file mode 100755 index 0000000..9b6b4b3 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,830 @@ +{ + "name": "botv10", + "version": "10.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "botv10", + "version": "10.0.0", + "license": "UNLICENSED", + "dependencies": { + "minecraft-protocol": "^1.45.0", + "prismarine-chat": "^1.10.0" + } + }, + "node_modules/@azure/msal-common": { + "version": "14.13.0", + "resolved": "https://registry.npmjs.org/@azure/msal-common/-/msal-common-14.13.0.tgz", + "integrity": "sha512-b4M/tqRzJ4jGU91BiwCsLTqChveUEyFK3qY2wGfZ0zBswIBZjAxopx5CYt5wzZFKuN15HqRDYXQbztttuIC3nA==", + "license": "MIT", + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/@azure/msal-node": { + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/@azure/msal-node/-/msal-node-2.10.0.tgz", + "integrity": "sha512-JxsSE0464a8IA/+q5EHKmchwNyUFJHtCH00tSXsLaOddwLjG6yVvTH6lGgPcWMhO7YWUXj/XVgVgeE9kZtsPUQ==", + "license": "MIT", + "dependencies": { + "@azure/msal-common": "14.13.0", + "jsonwebtoken": "^9.0.0", + "uuid": "^8.3.0" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/@types/node": { + "version": "20.14.10", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.10.tgz", + "integrity": "sha512-MdiXf+nDuMvY0gJKxyfZ7/6UFsETO7mGKF54MVD/ekJS6HdFtpZFBgrh6Pseu64XTb2MLyFPlbW6hj8HYRQNOQ==", + "license": "MIT", + "dependencies": { + "undici-types": "~5.26.4" + } + }, + "node_modules/@types/readable-stream": { + "version": "4.0.14", + "resolved": "https://registry.npmjs.org/@types/readable-stream/-/readable-stream-4.0.14.tgz", + "integrity": "sha512-xZn/AuUbCMShGsqH/ehZtGDwQtbx00M9rZ2ENLe4tOjFZ/JFeWMhEZkk2fEe1jAUqqEAURIkFJ7Az/go8mM1/w==", + "license": "MIT", + "dependencies": { + "@types/node": "*", + "safe-buffer": "~5.1.1" + } + }, + "node_modules/@xboxreplay/errors": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/@xboxreplay/errors/-/errors-0.1.0.tgz", + "integrity": "sha512-Tgz1d/OIPDWPeyOvuL5+aai5VCcqObhPnlI3skQuf80GVF3k1I0lPCnGC+8Cm5PV9aLBT5m8qPcJoIUQ2U4y9g==", + "license": "MIT" + }, + "node_modules/@xboxreplay/xboxlive-auth": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/@xboxreplay/xboxlive-auth/-/xboxlive-auth-3.3.3.tgz", + "integrity": "sha512-j0AU8pW10LM8O68CTZ5QHnvOjSsnPICy0oQcP7zyM7eWkDQ/InkiQiirQKsPn1XRYDl4ccNu0WM582s3UKwcBg==", + "license": "MIT", + "dependencies": { + "@xboxreplay/errors": "^0.1.0", + "axios": "^0.21.1" + } + }, + "node_modules/abort-controller": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", + "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", + "license": "MIT", + "dependencies": { + "event-target-shim": "^5.0.0" + }, + "engines": { + "node": ">=6.5" + } + }, + "node_modules/aes-js": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/aes-js/-/aes-js-3.1.2.tgz", + "integrity": "sha512-e5pEa2kBnBOgR4Y/p20pskXI74UEz7de8ZGVo58asOtvSVG5YAbJeELPZxOmt+Bnz3rX753YKhfIn4X4l1PPRQ==", + "license": "MIT" + }, + "node_modules/ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/asn1": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz", + "integrity": "sha512-6i37w/+EhlWlGUJff3T/Q8u1RGmP5wgbiwYnOnbOqvtrPxT63/sYFyP9RcpxtxGymtfA075IvmOnL7ycNOWl3w==", + "license": "MIT" + }, + "node_modules/axios": { + "version": "0.21.4", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz", + "integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==", + "license": "MIT", + "dependencies": { + "follow-redirects": "^1.14.0" + } + }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/buffer": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", + "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" + } + }, + "node_modules/buffer-equal": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/buffer-equal/-/buffer-equal-1.0.1.tgz", + "integrity": "sha512-QoV3ptgEaQpvVwbXdSO39iqPQTCxSF7A5U99AxbHYqUdCizL/lH2Z0A2y6nbZucxMEOtNyZfG2s6gsVugGpKkg==", + "license": "MIT", + "engines": { + "node": ">=0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/buffer-equal-constant-time": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", + "integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==", + "license": "BSD-3-Clause" + }, + "node_modules/commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "license": "MIT" + }, + "node_modules/debug": { + "version": "4.3.5", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.5.tgz", + "integrity": "sha512-pt0bNEmneDIvdL1Xsd9oDQ/wrQRkXDT4AUWlNZNPKvW5x/jyO9VFXkJUP07vQ2upmw5PlaITaPKc31jK13V+jg==", + "license": "MIT", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/discontinuous-range": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/discontinuous-range/-/discontinuous-range-1.0.0.tgz", + "integrity": "sha512-c68LpLbO+7kP/b1Hr1qs8/BJ09F5khZGTxqxZuhzxpmwJKOgRFHJWIb9/KmqnqHhLdO55aOxFH/EGBvUQbL/RQ==", + "license": "MIT" + }, + "node_modules/ecdsa-sig-formatter": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz", + "integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==", + "license": "Apache-2.0", + "dependencies": { + "safe-buffer": "^5.0.1" + } + }, + "node_modules/endian-toggle": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/endian-toggle/-/endian-toggle-0.0.0.tgz", + "integrity": "sha512-ShfqhXeHRE4TmggSlHXG8CMGIcsOsqDw/GcoPcosToE59Rm9e4aXaMhEQf2kPBsBRrKem1bbOAv5gOKnkliMFQ==", + "license": "MIT" + }, + "node_modules/event-target-shim": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", + "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/events": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", + "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==", + "license": "MIT", + "engines": { + "node": ">=0.8.x" + } + }, + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "license": "MIT" + }, + "node_modules/fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "license": "MIT" + }, + "node_modules/follow-redirects": { + "version": "1.15.6", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz", + "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "license": "MIT", + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, + "node_modules/ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "BSD-3-Clause" + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "license": "ISC" + }, + "node_modules/jose": { + "version": "4.15.9", + "resolved": "https://registry.npmjs.org/jose/-/jose-4.15.9.tgz", + "integrity": "sha512-1vUQX+IdDMVPj4k8kOxgUqlcK518yluMuGZwqlr44FS1ppZB/5GWh4rZG89erpOBOJjU/OBsnCVFfapsRz6nEA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/panva" + } + }, + "node_modules/json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "license": "MIT" + }, + "node_modules/jsonwebtoken": { + "version": "9.0.2", + "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-9.0.2.tgz", + "integrity": "sha512-PRp66vJ865SSqOlgqS8hujT5U4AOgMfhrwYIuIhfKaoSCZcirrmASQr8CX7cUg+RMih+hgznrjp99o+W4pJLHQ==", + "license": "MIT", + "dependencies": { + "jws": "^3.2.2", + "lodash.includes": "^4.3.0", + "lodash.isboolean": "^3.0.3", + "lodash.isinteger": "^4.0.4", + "lodash.isnumber": "^3.0.3", + "lodash.isplainobject": "^4.0.6", + "lodash.isstring": "^4.0.1", + "lodash.once": "^4.0.0", + "ms": "^2.1.1", + "semver": "^7.5.4" + }, + "engines": { + "node": ">=12", + "npm": ">=6" + } + }, + "node_modules/jwa": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/jwa/-/jwa-1.4.1.tgz", + "integrity": "sha512-qiLX/xhEEFKUAJ6FiBMbes3w9ATzyk5W7Hvzpa/SLYdxNtng+gcurvrI7TbACjIXlsJyr05/S1oUhZrc63evQA==", + "license": "MIT", + "dependencies": { + "buffer-equal-constant-time": "1.0.1", + "ecdsa-sig-formatter": "1.0.11", + "safe-buffer": "^5.0.1" + } + }, + "node_modules/jws": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/jws/-/jws-3.2.2.tgz", + "integrity": "sha512-YHlZCB6lMTllWDtSPHz/ZXTsi8S00usEV6v1tjq8tOUZzw7DpSDWVXjXDre6ed1w/pd495ODpHZYSdkRTsa0HA==", + "license": "MIT", + "dependencies": { + "jwa": "^1.4.1", + "safe-buffer": "^5.0.1" + } + }, + "node_modules/lodash.get": { + "version": "4.4.2", + "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", + "integrity": "sha512-z+Uw/vLuy6gQe8cfaFWD7p0wVv8fJl3mbzXh33RS+0oW2wvUqiRXiQ69gLWSLpgB5/6sU+r6BlQR0MBILadqTQ==", + "license": "MIT" + }, + "node_modules/lodash.includes": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz", + "integrity": "sha512-W3Bx6mdkRTGtlJISOvVD/lbqjTlPPUDTMnlXZFnVwi9NKJ6tiAk6LVdlhZMm17VZisqhKcgzpO5Wz91PCt5b0w==", + "license": "MIT" + }, + "node_modules/lodash.isboolean": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz", + "integrity": "sha512-Bz5mupy2SVbPHURB98VAcw+aHh4vRV5IPNhILUCsOzRmsTmSQ17jIuqopAentWoehktxGd9e/hbIXq980/1QJg==", + "license": "MIT" + }, + "node_modules/lodash.isinteger": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz", + "integrity": "sha512-DBwtEWN2caHQ9/imiNeEA5ys1JoRtRfY3d7V9wkqtbycnAmTvRRmbHKDV4a0EYc678/dia0jrte4tjYwVBaZUA==", + "license": "MIT" + }, + "node_modules/lodash.isnumber": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz", + "integrity": "sha512-QYqzpfwO3/CWf3XP+Z+tkQsfaLL/EnUlXWVkIk5FUPc4sBdTehEqZONuyRt2P67PXAk+NXmTBcc97zw9t1FQrw==", + "license": "MIT" + }, + "node_modules/lodash.isplainobject": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", + "integrity": "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==", + "license": "MIT" + }, + "node_modules/lodash.isstring": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz", + "integrity": "sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw==", + "license": "MIT" + }, + "node_modules/lodash.merge": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", + "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", + "license": "MIT" + }, + "node_modules/lodash.once": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz", + "integrity": "sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==", + "license": "MIT" + }, + "node_modules/lodash.reduce": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/lodash.reduce/-/lodash.reduce-4.6.0.tgz", + "integrity": "sha512-6raRe2vxCYBhpBu+B+TtNGUzah+hQjVdu3E17wfusjyrXBka2nBS8OH/gjVZ5PvHOhWmIZTYri09Z6n/QfnNMw==", + "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/minecraft-data": { + "version": "3.66.0", + "resolved": "https://registry.npmjs.org/minecraft-data/-/minecraft-data-3.66.0.tgz", + "integrity": "sha512-EevNbhPVGVeQ2OAnZ9uFVkA/MnI8Z3Zvx/Brtc6UyoQ29B8D14qfedTWbtUQLMzSOYRW79pBlSqzHCijd7iBsA==", + "license": "MIT" + }, + "node_modules/minecraft-folder-path": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minecraft-folder-path/-/minecraft-folder-path-1.2.0.tgz", + "integrity": "sha512-qaUSbKWoOsH9brn0JQuBhxNAzTDMwrOXorwuRxdJKKKDYvZhtml+6GVCUrY5HRiEsieBEjCUnhVpDuQiKsiFaw==", + "license": "MIT" + }, + "node_modules/minecraft-protocol": { + "version": "1.47.0", + "resolved": "https://registry.npmjs.org/minecraft-protocol/-/minecraft-protocol-1.47.0.tgz", + "integrity": "sha512-IHL8faXLLIWv1O+2v2NgyKlooilu/OiSL9orI8Kqed/rZvVOrFPzs2PwMAYjpQX9gxLPhiSU19KqZ8CjfNuqhg==", + "license": "BSD-3-Clause", + "dependencies": { + "@types/readable-stream": "^4.0.0", + "aes-js": "^3.1.2", + "buffer-equal": "^1.0.0", + "debug": "^4.3.2", + "endian-toggle": "^0.0.0", + "lodash.get": "^4.1.2", + "lodash.merge": "^4.3.0", + "minecraft-data": "^3.55.0", + "minecraft-folder-path": "^1.2.0", + "node-fetch": "^2.6.1", + "node-rsa": "^0.4.2", + "prismarine-auth": "^2.2.0", + "prismarine-chat": "^1.10.0", + "prismarine-nbt": "^2.5.0", + "prismarine-realms": "^1.2.0", + "protodef": "^1.8.0", + "readable-stream": "^4.1.0", + "uuid-1345": "^1.0.1", + "yggdrasil": "^1.4.0" + }, + "engines": { + "node": ">=14" + } + }, + "node_modules/mojangson": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/mojangson/-/mojangson-2.0.4.tgz", + "integrity": "sha512-HYmhgDjr1gzF7trGgvcC/huIg2L8FsVbi/KacRe6r1AswbboGVZDS47SOZlomPuMWvZLas8m9vuHHucdZMwTmQ==", + "license": "MIT", + "dependencies": { + "nearley": "^2.19.5" + } + }, + "node_modules/moo": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/moo/-/moo-0.5.2.tgz", + "integrity": "sha512-iSAJLHYKnX41mKcJKjqvnAN9sf0LMDTXDEvFv+ffuRR9a1MIuXLjMNL6EsnDHSkKLTWNqQQ5uo61P4EbU4NU+Q==", + "license": "BSD-3-Clause" + }, + "node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "license": "MIT" + }, + "node_modules/nearley": { + "version": "2.20.1", + "resolved": "https://registry.npmjs.org/nearley/-/nearley-2.20.1.tgz", + "integrity": "sha512-+Mc8UaAebFzgV+KpI5n7DasuuQCHA89dmwm7JXw3TV43ukfNQ9DnBH3Mdb2g/I4Fdxc26pwimBWvjIw0UAILSQ==", + "license": "MIT", + "dependencies": { + "commander": "^2.19.0", + "moo": "^0.5.0", + "railroad-diagrams": "^1.0.0", + "randexp": "0.4.6" + }, + "bin": { + "nearley-railroad": "bin/nearley-railroad.js", + "nearley-test": "bin/nearley-test.js", + "nearley-unparse": "bin/nearley-unparse.js", + "nearleyc": "bin/nearleyc.js" + }, + "funding": { + "type": "individual", + "url": "https://nearley.js.org/#give-to-nearley" + } + }, + "node_modules/node-fetch": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", + "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "license": "MIT", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, + "node_modules/node-rsa": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/node-rsa/-/node-rsa-0.4.2.tgz", + "integrity": "sha512-Bvso6Zi9LY4otIZefYrscsUpo2mUpiAVIEmSZV2q41sP8tHZoert3Yu6zv4f/RXJqMNZQKCtnhDugIuCma23YA==", + "license": "MIT", + "dependencies": { + "asn1": "0.2.3" + } + }, + "node_modules/prismarine-auth": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/prismarine-auth/-/prismarine-auth-2.5.0.tgz", + "integrity": "sha512-CRv/pL6d/T+4cdjWS223PXG+ygHbz40Kef04L59SLMT+axNdAQro23eZZhgiIIu6u7rlvJcZYlIY93gFNtKxXA==", + "license": "MIT", + "dependencies": { + "@azure/msal-node": "^2.0.2", + "@xboxreplay/xboxlive-auth": "^3.3.3", + "debug": "^4.3.3", + "jose": "^4.1.4", + "node-fetch": "^2.6.1", + "smart-buffer": "^4.1.0", + "uuid-1345": "^1.0.2" + } + }, + "node_modules/prismarine-chat": { + "version": "1.10.1", + "resolved": "https://registry.npmjs.org/prismarine-chat/-/prismarine-chat-1.10.1.tgz", + "integrity": "sha512-XukYcuueuhDxzEXG7r8BZyt6jOObrPPB4JESCgb+/XenB9nExoSHF8eTQWWj8faKPLqm1dRQaYwFJlNBlJZJUw==", + "license": "MIT", + "dependencies": { + "mojangson": "^2.0.1", + "prismarine-nbt": "^2.0.0", + "prismarine-registry": "^1.4.0" + } + }, + "node_modules/prismarine-nbt": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/prismarine-nbt/-/prismarine-nbt-2.5.0.tgz", + "integrity": "sha512-F0/8UAa9SDDnAGrBYqZc4nG8h2zj5cE2eAJU5xlDR/IsQQ3moVxkOjE3h3nMv6SbvZrvAcgX7waA/nd9LLHYdA==", + "license": "MIT", + "dependencies": { + "protodef": "^1.9.0" + } + }, + "node_modules/prismarine-realms": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/prismarine-realms/-/prismarine-realms-1.3.2.tgz", + "integrity": "sha512-5apl9Ru8veTj5q2OozRc4GZOuSIcs3yY4UEtALiLKHstBe8bRw8vNlaz4Zla3jsQ8yP/ul1b1IJINTRbocuA6g==", + "license": "MIT", + "dependencies": { + "debug": "^4.3.3", + "node-fetch": "^2.6.1" + } + }, + "node_modules/prismarine-registry": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/prismarine-registry/-/prismarine-registry-1.7.0.tgz", + "integrity": "sha512-yyva0FpWI078nNeMhx8ekVza5uUTYhEv+C+ADu3wUQXiG8qhXkvrf0uzsnhTgZL8BLdsi2axgCEiKw9qSKIuxQ==", + "license": "MIT", + "dependencies": { + "minecraft-data": "^3.0.0", + "prismarine-nbt": "^2.0.0" + } + }, + "node_modules/process": { + "version": "0.11.10", + "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", + "integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==", + "license": "MIT", + "engines": { + "node": ">= 0.6.0" + } + }, + "node_modules/protodef": { + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/protodef/-/protodef-1.15.0.tgz", + "integrity": "sha512-bZ2Omw8dT+DACjJHLrBWZlqN4MlT9g9oSpJDdkUAJOStUzgJp+Zn42FJfPUdwutUxjaxA0PftN0PDlNa2XbneA==", + "license": "MIT", + "dependencies": { + "lodash.get": "^4.4.2", + "lodash.reduce": "^4.6.0", + "protodef-validator": "^1.3.0", + "readable-stream": "^3.0.3" + }, + "engines": { + "node": ">=14" + } + }, + "node_modules/protodef-validator": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/protodef-validator/-/protodef-validator-1.3.1.tgz", + "integrity": "sha512-lZ5FWKZYR9xOjpMw1+EfZRfCjzNRQWPq+Dk+jki47Sikl2EeWEPnTfnJERwnU/EwFq6us+0zqHHzSsmLeYX+Lg==", + "license": "MIT", + "dependencies": { + "ajv": "^6.5.4" + }, + "bin": { + "protodef-validator": "cli.js" + } + }, + "node_modules/protodef/node_modules/readable-stream": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", + "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", + "license": "MIT", + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/punycode": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/railroad-diagrams": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/railroad-diagrams/-/railroad-diagrams-1.0.0.tgz", + "integrity": "sha512-cz93DjNeLY0idrCNOH6PviZGRN9GJhsdm9hpn1YCS879fj4W+x5IFJhhkRZcwVgMmFF7R82UA/7Oh+R8lLZg6A==", + "license": "CC0-1.0" + }, + "node_modules/randexp": { + "version": "0.4.6", + "resolved": "https://registry.npmjs.org/randexp/-/randexp-0.4.6.tgz", + "integrity": "sha512-80WNmd9DA0tmZrw9qQa62GPPWfuXJknrmVmLcxvq4uZBdYqb1wYoKTmnlGUchvVWe0XiLupYkBoXVOxz3C8DYQ==", + "license": "MIT", + "dependencies": { + "discontinuous-range": "1.0.0", + "ret": "~0.1.10" + }, + "engines": { + "node": ">=0.12" + } + }, + "node_modules/readable-stream": { + "version": "4.5.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-4.5.2.tgz", + "integrity": "sha512-yjavECdqeZ3GLXNgRXgeQEdz9fvDDkNKyHnbHRFtOr7/LcfgBcmct7t/ET+HaCTqfh06OzoAxrkN/IfjJBVe+g==", + "license": "MIT", + "dependencies": { + "abort-controller": "^3.0.0", + "buffer": "^6.0.3", + "events": "^3.3.0", + "process": "^0.11.10", + "string_decoder": "^1.3.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + } + }, + "node_modules/ret": { + "version": "0.1.15", + "resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz", + "integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==", + "license": "MIT", + "engines": { + "node": ">=0.12" + } + }, + "node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "license": "MIT" + }, + "node_modules/semver": { + "version": "7.6.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.2.tgz", + "integrity": "sha512-FNAIBWCx9qcRhoHcgcJ0gvU7SN1lYU2ZXuSfl04bSC5OpvDHFyJCjdNHomPXxjQlCBU67YW64PzY7/VIEH7F2w==", + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/smart-buffer": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz", + "integrity": "sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg==", + "license": "MIT", + "engines": { + "node": ">= 6.0.0", + "npm": ">= 3.0.0" + } + }, + "node_modules/string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "license": "MIT", + "dependencies": { + "safe-buffer": "~5.2.0" + } + }, + "node_modules/string_decoder/node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", + "license": "MIT" + }, + "node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "license": "MIT" + }, + "node_modules/uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "license": "BSD-2-Clause", + "dependencies": { + "punycode": "^2.1.0" + } + }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", + "license": "MIT" + }, + "node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "license": "MIT", + "bin": { + "uuid": "dist/bin/uuid" + } + }, + "node_modules/uuid-1345": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/uuid-1345/-/uuid-1345-1.0.2.tgz", + "integrity": "sha512-bA5zYZui+3nwAc0s3VdGQGBfbVsJLVX7Np7ch2aqcEWFi5lsAEcmO3+lx3djM1npgpZI8KY2FITZ2uYTnYUYyw==", + "license": "MIT", + "dependencies": { + "macaddress": "^0.5.1" + } + }, + "node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", + "license": "BSD-2-Clause" + }, + "node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "license": "MIT", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, + "node_modules/yggdrasil": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/yggdrasil/-/yggdrasil-1.7.0.tgz", + "integrity": "sha512-QBIo5fiNd7688G3FqXXYGr36uyrYzczlNuzpWFy2zL3+R+3KT2lF+wFxm51synfA3l3z6IBiGOc1/EVXWCYY1Q==", + "license": "MIT", + "dependencies": { + "node-fetch": "^2.6.1", + "uuid": "^8.2.0" + } + } + } +} diff --git a/package.json b/package.json new file mode 100755 index 0000000..fb310c1 --- /dev/null +++ b/package.json @@ -0,0 +1,15 @@ +{ + "dependencies": { + "minecraft-protocol": "^1.45.0", + "prismarine-chat": "^1.10.0" + }, + "name": "botv10", + "version": "10.0.0", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "UNLICENSED", + "description": "" +} diff --git a/plugins/!chat.js b/plugins/!chat.js new file mode 100755 index 0000000..d3a85ab --- /dev/null +++ b/plugins/!chat.js @@ -0,0 +1,50 @@ +const console2 = require("./console.js") +const parse = require("../util/chatparse.js") +const parse1204 = require("../util/chatparse_1204.js") +module.exports={ + load:()=>{ + //console.log("Loaded on global") + }, + loadBot:(b)=>{ + //profileless_chat player_chat system_chat + /*pxc { + message: '{"text":"gex"}', + type: 5, + name: '{"bold":true,"italic":false,"color":"yellow","text":"NothingCore"}', + target: undefined +} +*/ + b._client.on("profileless_chat",(data)=>{ + //console.log("pxc", data) + if(data.type==4){ + //const parsedmessage = parse(JSON.parse(data.message)); + //console.log(parsedmessage) + b.emit("chat",{json:parse1204(data.message),type:"profileless",uuid:"N/A", message: ""}) + } + }) + + b._client.on("player_chat",(data)=>{ + //console.log("pc", data) + if(data.type==4){ + b.emit("chat",{json:parse1204(data.unsignedChatContent),type:"player",uuid:data.senderUuid, message: data.plainMessage}) + } + }) + b._client.on("system_chat",(data)=>{ + //console.log("sc", data) + //console.log(data) + b.emit("chat",{json:parse1204(data.content),type:"system",uuid:"N/A", message: ""}) + }) + b.on("chat",(data)=>{ + const msg=parse(data.json); + console2.write(`[${b.id}] [${data.type}] `+msg[0]) + let fullCommand = ""; + if(data.type=="player") fullCommand=data.message; + //console.log(name, fullCommand) + if(fullCommand.startsWith(b.prefix)){ + const command=fullCommand.slice(b.prefix.length); + b.runCommand("N/A",data.uuid,command); + } + }) + }, + parse +} diff --git a/plugins/command.js b/plugins/command.js new file mode 100755 index 0000000..84b5d11 --- /dev/null +++ b/plugins/command.js @@ -0,0 +1,50 @@ +const fs=require("fs"); +const Command=require("../util/Command.js"); +let cmds={}; +module.exports={ + load:()=>{ + module.exports.loadCMD(); + }, + loadBot:(b)=>{ + b.prefix="\"" + b.lastCmd=0; + b.runCommand=(name, uuid, text)=>{ + if(Date.now-b.lastCmd<=1000){ + console.log("Executed too early, "+(Date.now-b.lastCmd)+"ms left") + } + const cmd=text.split(" "); + if(cmds[cmd[0].toLowerCase()]){ + try{ + cmds[cmd[0].toLowerCase()].execute(new Command(uuid,name,"nick N/A",text,"prefix N/A",b,false)) + } catch(e) { console.log(e); b.chat("An error occured (check console for more info)") } + } else { + b.chat("Command not found") + } + } + b.printHelp=(uuid)=>{ + let helpCmds=[]; + for(const i in cmds){ + if(cmds[i].hidden) continue; + helpCmds.push(b.prefix+i) + } + b.tellraw(uuid,JSON.stringify({"text":"Commands: "+helpCmds.join(" ")})); + } + b.printCmdHelp=(uuid,cmd)=>{ + b.tellraw(uuid,JSON.stringify({"text":"Commands: "+cmd+cmds[cmd].usage+" - "+cmds[cmd].desc})); + } + }, + loadCMD:()=>{ + const botplug = [] + const bpl = fs.readdirSync('./plugins/commands') + for (const i in bpl) { + if (!bpl[i].endsWith('.js')) { + continue + } + try { + cmds[bpl[i].split(".js")[0]]=require(`./commands/${bpl[i]}`); + console.log("Loaded command "+bpl[i].split(".js")[0]) + } catch (e) { console.log(e); } + } + }, + cmds +} diff --git a/plugins/commandblock.js b/plugins/commandblock.js new file mode 100755 index 0000000..01f3690 --- /dev/null +++ b/plugins/commandblock.js @@ -0,0 +1,107 @@ +const uuidToInt = require('../util/uuidtoint.js') +module.exports = { + cs: 1, + cs_v: 6, + load: function () { + + }, + loadBot: function (b) { + b.interval.commandFill = setInterval(() => { b.chat(`/fill ~ 10 ~ ~ 15 ~ command_block`) }, 60000) + b.ccq = [] + b.blocknoX = 0 + b.blocknoZ = 0 + b.ccStarted = 0 + b.blocknoY = 0 + b.pos = { x: 0, y: 0, z: 0, correct: 0 } + + b.advanceccq = function () { + if (b.ccq[0] && b.ccq[0].length != 0) { + b._client.write('update_command_block', { + command: b.ccq[0], + location: { + x: b.commandPos.x1 + b.blocknoX, + y: b.commandPos.y1 + b.blocknoY, + z: b.commandPos.z1 + b.blocknoZ + }, + mode: 2, + flags: 1 + }) + b._client.write('update_command_block', { + command: b.ccq[0], + location: { + x: b.commandPos.x1 + b.blocknoX, + y: b.commandPos.y1 + b.blocknoY, + z: b.commandPos.z1 + b.blocknoZ + }, + mode: 2, + flags: 5 + }) + b.blocknoX++ + if (b.blocknoX == module.exports.cs) { + b.blocknoY++ + b.blocknoX = 0 + if (b.blocknoY == module.exports.cs_v) { + b.blocknoZ++ + b.blocknoY = 0 + if (b.blocknoZ == module.exports.cs) { + b.blocknoZ = 0 + } + } + } + // console.log(b.blocknoX,b.blocknoY,b.blocknoZ) + // console.log(b.blocknoX,b.blocknoZ) + } + b.ccq.splice(0, 1) + } + b._client.on("login",()=>{ + b.chat(`/fill ~ 10 ~ ~ 15 ~ command_block`) + }) + b.on('ccstart', () => { + setTimeout(() => { b.ccqi = setInterval(b.advanceccq, 12) }, 1000) // 1 Second and 12 Milliseconds + b.ccStarted = true; + b.info("Command block!"); + }) + b.on('chat', (data) => { // + if (!b.ccStarted && (data.json.translate == 'commands.fill.failed' || (data.json.extra && data.json.extra[0] && data.json.extra[0].translate == 'commands.fill.failed') || + data.json.translate == 'commands.fill.success' || (data.json.extra && data.json.extra[0] && data.json.extra[0].translate == 'commands.fill.success'))) { + b.emit('ccstart') + } + }) + b._client.on('position', function (a) { + if (!b.ccStarted) { + b.original_pos = { x: a.x, y: a.y, z: a.z } + b.pos = { x: a.x, y: a.y, z: a.z, correct: 1 } + } else { + b.pos = { x: a.x, y: a.y, z: a.z, correct: 1 } + if (a.x != b.original_pos.x || a.z != b.original_pos.z) { + b.original_pos = { x: a.x, y: a.y, z: a.z } + b.pos.correct = 0 + b.chat(`/fill ~ 10 ~ ~ 15 ~ command_block`) + } + } + + // console.log(b.pos); + b.commandPos = { + x1: Math.floor(a.x), + x2: Math.ceil(a.x) + 3, + z1: Math.floor(a.z), + z2: Math.ceil(a.z) + 3, + y1: 10, + y2: 10 + } + // b.send("/fill ~5 0 ~5 ~-5 0 ~-5 command_block") + b._client.write('teleport_confirm', { teleportId: a.teleportId }) + }) + b.tellraw = (uuid, message) => { + let finalname = '' + if (uuid == '@a') { + finalname = '@a' + } else if (uuid.match(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/)) { + finalname = `@a[nbt={UUID:[I;${uuidToInt(uuid)}]}]` + } else { + finalname = uuid + } + b.ccq.push(`/tellraw ${finalname} ${message}`) + } + } +} diff --git a/plugins/commands/about.js b/plugins/commands/about.js new file mode 100644 index 0000000..26ac41c --- /dev/null +++ b/plugins/commands/about.js @@ -0,0 +1,15 @@ +// This is not C source code +//const settings = require('../settings.json') +module.exports = { + execute: function (c) { + c.reply('{"text":"UBot - a minecraft bot made by a \\"baby\\""}'); + c.reply('{"text":""}'); + c.reply('{"text":"To view system information, run the command \\"serverinfo\\"."}') + c.reply('{"text":""}'); + c.reply('{"text":"This is a new version so most features from version 9 and older have not been re-implemented."}') + c.reply('{"text":""}'); + c.reply('{"text":"The first version of UBot was made in August 2020."}') + }, + desc: 'About the bot', + usage: '' +} diff --git a/plugins/commands/help.js b/plugins/commands/help.js new file mode 100644 index 0000000..480f9ff --- /dev/null +++ b/plugins/commands/help.js @@ -0,0 +1,11 @@ +module.exports={ + execute: (c)=>{ + if(c.args.length>0){ + c.bot.printCmdHelp(c.uuid,c.args[0]); + } else { + c.bot.printHelp(c.uuid); + } + }, + desc: "Shows command help", + usage: ' [cmd]' +} diff --git a/plugins/commands/logoff.js b/plugins/commands/logoff.js new file mode 100644 index 0000000..2a513af --- /dev/null +++ b/plugins/commands/logoff.js @@ -0,0 +1,9 @@ +module.exports={ + execute: (c)=>{ + c.bot._client.end(); + }, + desc: "Does nothing", // Command description + usage: ' [optional]', // Command usage + hidden: true, + consoleIndex: true +} diff --git a/plugins/commands/say.js b/plugins/commands/say.js new file mode 100644 index 0000000..14f20d2 --- /dev/null +++ b/plugins/commands/say.js @@ -0,0 +1,23 @@ +module.exports={ + execute: (c)=>{ + //Blank template + /* + c.send(text, user?): Send text to all ("/tellraw @a") + c.reply(text): Send text to command sender + c.uuid: Unique identifier (UUID for Minecraft, Discord ID for Discord) + c.username: Username of sender + c.nickname: Nickname of sender when applicable + c.command: Command string + c.args: Arguments of command (above without the first section, and split at every space) + c.prefix: Prefix being used to send the command (when applicable) + c.bot: Bot that received the command. Will be different type based on where it was received + c.type: Type of bot receiving the command ("minecraft", "console", "discord") + */ + if(c.args[0].startsWith("/")) return; + c.bot.chat(c.args.join(" ")) + }, + desc: "Sends a message to chat", // Command description + usage: ' ', // Command usage + hidden: true, + consoleIndex: true //To show the command on the help command list, remove this line +} diff --git a/plugins/commands/serverinfo.js b/plugins/commands/serverinfo.js new file mode 100755 index 0000000..6ef794a --- /dev/null +++ b/plugins/commands/serverinfo.js @@ -0,0 +1,86 @@ +const os = require('os') +const cp = require('child_process') +const settings = require('../../settings.json') +const timeformat = require('../../util/timeformat.js') +const fs=require("fs") +const VoolEagler58 = function (text, value, color) { + if (!color) color = 'white' + return JSON.stringify({ + translate: '%s: %s', + with: [ + { + text, + color + }, + { + text: value, + color + } + ], + hoverEvent: { + action: 'show_text', + contents: { + text: 'Click to copy!' + } + }, + clickEvent: { + action: 'copy_to_clipboard', + value + } + }) +} + +const os2 = function (o2) { + switch (o2) { + case 'win32': + return os.version() + break + case 'android': + return 'Android' + break + case 'linux': + return 'Linux' + ' ' + os.release() + break + default: + return o2 + } +} +// b.tellraw(sender,VoolEagler58("Example",example)) +module.exports = { + execute: function (c) { + c.reply(VoolEagler58('Operating system', os2(process.platform))) + c.reply(VoolEagler58('CPU', os.cpus()[0].model)) + c.reply(VoolEagler58('Architecture', os.machine())) + c.reply(VoolEagler58('Username', os.userInfo().username)) + c.reply(VoolEagler58('Bot uptime', timeformat(process.uptime() * 1000))) + c.reply(VoolEagler58('System uptime', timeformat(os.uptime() * 1000))) + // b.tellraw(sender,VoolEagler58('System memory (total)',Math.floor(os.totalmem()/1000000)+'MB')); + c.reply(VoolEagler58('Node.js version', process.version)) + if (process.platform == 'linux' || process.platform == 'freebsd') { + // const android_sdk=+cp.execSync("getprop ro.build.version.sdk").toString("UTF-8").split("\n")[0]; + /* /etc/os-release parser */ + const osrelease = fs.readFileSync("/etc/os-release").toString("UTF-8").split("\n"); + let osrelease2={}; + for(const i in osrelease){ + if(!osrelease[i].includes("=")) continue; + let osr_value=osrelease[i].split("=")[1]; + if(osr_value.startsWith("\"") && osr_value.endsWith("\"")){osr_value=osr_value.slice(1,osr_value.length-1)}; + osrelease2[osrelease[i].split("=")[0]]=osr_value; + } + + if(osrelease2.PRETTY_NAME){ + c.reply(VoolEagler58('Linux release', osrelease2.PRETTY_NAME, 'dark_green')) + } + } else if (process.platform == 'android') { + // const android_sdk=+cp.execSync("getprop ro.build.version.sdk").toString("UTF-8").split("\n")[0]; + const android_version = cp.execSync('getprop ro.build.version.release').toString('UTF-8').split('\n')[0] + c.reply(VoolEagler58('Android version', android_version, 'green')) + c.reply(VoolEagler58('Device model', cp.execSync('getprop ro.product.model').toString('UTF-8').split('\n')[0], 'green')) + c.reply(VoolEagler58('Device brand', cp.execSync('getprop ro.product.brand').toString('UTF-8').split('\n')[0], 'green')) + } + c.reply(VoolEagler58('Bot name', settings.name, 'yellow')) + c.reply(VoolEagler58('Bot version', settings.version, 'yellow')) + }, + desc: 'Get system/bot info (ported from V9). Not complete.', + usage: '' +} diff --git a/plugins/commands/template.js b/plugins/commands/template.js new file mode 100644 index 0000000..ff37388 --- /dev/null +++ b/plugins/commands/template.js @@ -0,0 +1,21 @@ +module.exports={ + execute: (c)=>{ + //Blank template + /* + c.send(text, user?): Send text to all ("/tellraw @a") + c.reply(text): Send text to command sender + c.uuid: Unique identifier (UUID for Minecraft, Discord ID for Discord) + c.username: Username of sender + c.nickname: Nickname of sender when applicable + c.command: Command string + c.args: Arguments of command (above without the first section, and split at every space) + c.prefix: Prefix being used to send the command (when applicable) + c.bot: Bot that received the command. Will be different type based on where it was received + c.type: Type of bot receiving the command ("minecraft", "console", "discord") + */ + }, + desc: "Does nothing", // Command description + usage: ' [optional]', // Command usage + hidden: true, // To show the command on the help command list, remove this line + consoleIndex: true // When run from console, the second argument will be a bot ID +} diff --git a/plugins/commands/testing.js b/plugins/commands/testing.js new file mode 100755 index 0000000..8c4c82d --- /dev/null +++ b/plugins/commands/testing.js @@ -0,0 +1,8 @@ +module.exports={ + load:()=>{ + console.log("Loaded on global") + }, + loadBot:(b)=>{ + console.log(`Loaded on bot ${b.id}`) + } +} \ No newline at end of file diff --git a/plugins/console.js b/plugins/console.js new file mode 100644 index 0000000..12b48ee --- /dev/null +++ b/plugins/console.js @@ -0,0 +1,55 @@ +// copied from u6, u9 +// Old name: 020000_console.js +const readln = require('readline') +const index = require('../index.js') +const ConsoleCommand = require('../util/ConsoleCommand.js') +const fs = require('fs') +const newercommands = require('./command.js').cmds; +let rl +module.exports = { + load: () => { + rl = readln.createInterface({ + input: process.stdin, + output: process.stdout, + prompt: '\x1b[0m\x1b[38;5;15m> ' + }) + rl.on('line', (l) => { + // 00000000-0000-0000-0000-Console00000 + try { + if(newercommands[l.split(' ')[0].toLowerCase()]){ + if(newercommands[l.split(' ')[0].toLowerCase()].consoleIndex){ + let tmpcmd = l.split(' '); + const index2 = tmpcmd.splice(1,1)[0]; + + + if (index2 === '*') { + for (let i = 0; i < index.bot.length; i++) { + //if(index.bot[i].o.disabled) continue; + const cmd = new ConsoleCommand(tmpcmd.join(' '),i); + newercommands[l.split(' ')[0].toLowerCase()].execute(cmd) + } + } else { + const cmd = new ConsoleCommand(tmpcmd.join(' '),+index2); + newercommands[l.split(' ')[0].toLowerCase()].execute(cmd) + } + } else { + const cmd = new ConsoleCommand(l,-2); + newercommands[l.split(' ')[0].toLowerCase()].execute(cmd) + } + } + // things.consolecmds[l.toString().toLowerCase().split(" ")[0]].command(l,things) + } catch (e) { + console.log(e) + } + rl.prompt(false) + }) + rl.prompt() + }, + rl, + write: (text) => { + readln.cursorTo(process.stdout, 0) + readln.clearLine(process.stdout, 0) + process.stdout.write(text + '\n') + rl.prompt(true) + } +} diff --git a/plugins/cq.js b/plugins/cq.js new file mode 100755 index 0000000..5d8a430 --- /dev/null +++ b/plugins/cq.js @@ -0,0 +1,25 @@ +module.exports={//profileless_chat player_chat system_chat + load:()=>{ + //console.log("Loaded on global") + }, + loadBot:(b)=>{ + //console.log(`Loaded on bot ${b.id}`) + b._client.on("login",()=>{ + b.interval.chatQueue=setInterval(()=>{ + if(b.chatqueue.length!=0){ + b._client.chat(b.chatqueue[0]); + b.chatqueue.splice(0,1) + } + },150) + //b.chat("Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. ") + }) + b.chatqueue=[];//"Prefix: \""]; + b.chat=function chat(msg){ + if(msg.length==0) return; + msg.match(/.{1,250}/g).forEach(element => { + b.chatqueue.push(element) + }); + } + + } +} diff --git a/plugins/rejoin.js b/plugins/rejoin.js new file mode 100755 index 0000000..1b30169 --- /dev/null +++ b/plugins/rejoin.js @@ -0,0 +1,19 @@ +const index = require('../index.js') +module.exports={ + load:()=>{ + //console.log("Loaded on global") + }, + loadBot:(b)=>{ + b._client.on("end",()=>{ + b.info("bot "+b.id+" disconnected"); + for(const i in b.interval){ + clearInterval(b.interval[i]) + } + setTimeout(()=>{ + b.info("Re-connecting bot "+b.id) + const b_id = b.id; + index.createBot(b.host,b.id); + },5000) + }) + } +} diff --git a/plugins/sc.js b/plugins/sc.js new file mode 100755 index 0000000..9e495cc --- /dev/null +++ b/plugins/sc.js @@ -0,0 +1,34 @@ +class SCTask{ + constructor (failTask,chatCommand){ + /* + * failed: Whether to run this task + * failTask: Command to run when failed is true + * chatCommand: Whether to run failTask in chat rather than in command block + */ + this.failed=false; + this.failTask=failTask; + this.chatCommand=chatCommand; + } +} +module.exports={ + load:()=>{ + + }, + loadBot:(b)=>{ + b.sc_tasks={}; + b.interval.sc=setInterval(()=>{ + for(const i in b.sc_tasks){ + if(b.sc_tasks[i].failed){ + if(b.sc_tasks[i].chatCommand){ + b.chat(b.sc_tasks[i].failTask) + } else { + b.ccq.push(b.sc_tasks[i].failTask) //Does not automatically reset + } + } + } + },1000) + b.add_sc_task=(name,failTask,chatCommand)=>{ + b.sc_tasks[name] = new SCTask(failTask,chatCommand); + } + } +} diff --git a/plugins/sc_op.js b/plugins/sc_op.js new file mode 100755 index 0000000..07ba7f6 --- /dev/null +++ b/plugins/sc_op.js @@ -0,0 +1,19 @@ + +module.exports={ + load:()=>{ + + }, + loadBot:(b)=>{ + b.add_sc_task("op","/op @s[type=player]", true) + b._client.on('login', (p) => { + b.entityId = p.entityId + }) + b._client.on('entity_status', (p) => { + if (p.entityId == b.entityId && p.entityStatus == 24) { + b.sc_tasks["op"].failed = 1 + } else if (p.entityId == b.entityId && p.entityStatus == 28) { + b.sc_tasks["op"].failed = 0 + } + }) + } +} diff --git a/plugins/testing.js b/plugins/testing.js new file mode 100755 index 0000000..8c4c82d --- /dev/null +++ b/plugins/testing.js @@ -0,0 +1,8 @@ +module.exports={ + load:()=>{ + console.log("Loaded on global") + }, + loadBot:(b)=>{ + console.log(`Loaded on bot ${b.id}`) + } +} \ No newline at end of file diff --git a/settings.json b/settings.json new file mode 100755 index 0000000..0e00c1b --- /dev/null +++ b/settings.json @@ -0,0 +1,22 @@ +{ + "secret":"/home/name3/settings10.json", + "name": "botvX alpha", + "version": "10.0.0-alpha.5", + "version_mc": "1.20.4", + "servers":[ + { + "host": "kaboom.pw", + "port": 25565, + "options":{ + "name": "kaboom" + } + }, + { + "host": "chipmunk.land", + "port": 25565, + "options":{ + "name": "chipmunk" + } + } + ] +} diff --git a/util/Command.js b/util/Command.js new file mode 100644 index 0000000..eec245e --- /dev/null +++ b/util/Command.js @@ -0,0 +1,22 @@ +//HOW TO WRITE CLASS JS +const parse = require("../util/chatparse.js") +class Command{ + constructor (uuid,user,nick,cmd,prefix,bot,verify){ + this.send = ()=>{}; + this.reply = text => bot.tellraw(uuid,text); + this.uuid = uuid; + this.username = user; + this.nickname = nick; + this.command = cmd; + this.prefix = prefix; + this.bot = bot; + this.type = 'minecraft'; + this.index = bot.id; + this.args = cmd.split(' ').slice(1); + this.verify = verify; + this.host = bot.host; + this.port = bot.port; + } +} + +module.exports = Command; diff --git a/util/ConsoleCommand.js b/util/ConsoleCommand.js new file mode 100644 index 0000000..9510a57 --- /dev/null +++ b/util/ConsoleCommand.js @@ -0,0 +1,36 @@ +//HOW TO WRITE CLASS JS +const index = require('../index.js') +const { cmds } = require('../plugins/command.js'); +const parse = require("../util/chatparse.js") +class ConsoleCommand{ + constructor (cmd,index2){ + this.send = ()=>{}; //not needed for console + this.reply = text => process.stdout.write(parse(JSON.parse(text))[0]+'\n'); + this.uuid = 'dde5a2a6-ebdd-4bbb-8eac-f75b10c10446_console'; //hard-coded because uuid does not exist at console + this.username = 'Owner'; + this.nickname = 'Console'; + this.command = cmd; + this.prefix = ''; //prefix does not exist at console + this.bot = index2 >= 0 ? index.bot[index2] : { + printHelp:()=>{ + let helpCmds=[]; + for(const i in cmds){ + //if(cmds[i].hidden) continue; + helpCmds.push(i) + } + console.log("Commands: "+helpCmds.join(" ")) + }, + printCmdHelp:(cmd)=>{ + console.log(cmd+cmds[cmd].usage+" - "+cmds[cmd].desc); + } + }; //bot does not exist at console + this.type = 'console'; + this.index = index2; + this.args = cmd.split(' ').slice(1); + this.verify = true; + this.host = ""; + this.port = "3"; // :3 + } +} + +module.exports = ConsoleCommand; diff --git a/util/chatparse.js b/util/chatparse.js new file mode 100644 index 0000000..1d1ee3d --- /dev/null +++ b/util/chatparse.js @@ -0,0 +1,71 @@ +const lang = require("minecraft-data")("1.20.2").language; +const parse=function(data, l){ + const out=["","",""]; //console plain minecraft + if (l === undefined) l = 0 + if (l >= 8) { + return ['', '', ''] + } + + + if(data.text){ + out[0]+=data.text; + out[1]+=data.text; + out[2]+=data.text; + } + if (data.translate) { + let trans = data.translate + let trans2 = data.translate.replace(/%%/g, '\ue123') + let trans3 = data.translate.replace(/%%/g, '\ue123') + if (lang[trans] !== undefined) { + trans = lang[trans].replace(/%%/g, '\ue123') + trans2 = lang[trans2].replace(/%%/g, '\ue123') + trans3 = lang[trans3].replace(/%%/g, '\ue123') + } + for (const i in data.with) { + const j2 = parse(data.with[i], l + 1) + trans = trans.replace(/%s/, j2[0].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + trans2 = trans2.replace(/%s/, j2[1].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + trans3 = trans3.replace(/%s/, j2[2].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + } + // %n$s only goes up to 4 normally + if (data.with) { + if (data.with[0]) { + const j2_1 = parse(data.with[0], l + 1) + trans = trans.replace(/%1\$s/g, j2_1[0].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + trans2 = trans2.replace(/%1\$s/g, j2_1[1].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + trans3 = trans3.replace(/%1\$s/g, j2_1[2].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + } + if (data.with[1]) { + const j2_2 = parse(data.with[1], l + 1) + trans = trans.replace(/%2\$s/g, j2_2[0].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + trans2 = trans2.replace(/%2\$s/g, j2_2[1].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + trans3 = trans3.replace(/%2\$s/g, j2_2[2].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + } + if (data.with[2]) { + const j2_3 = parse(data.with[2], l + 1) + trans = trans.replace(/%3\$s/g, j2_3[0].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + trans2 = trans2.replace(/%3\$s/g, j2_3[1].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + trans3 = trans3.replace(/%3\$s/g, j2_3[2].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + } + if (data.with[3]) { + const j2_4 = parse(data.with[3], l + 1) + trans = trans.replace(/%4\$s/g, j2_4[0].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + trans2 = trans2.replace(/%4\$s/g, j2_4[1].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + trans3 = trans3.replace(/%4\$s/g, j2_4[2].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + } + } + out[1] += trans.replace(/%([0-9]*\$){0,1}s/g, '').replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s') + out[0] += trans2.replace(/%([0-9]*\$){0,1}s/g, '').replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s').replace(/\n/g, '\n') + out[2] += trans3.replace(/%([0-9]*\$){0,1}s/g, '').replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s') + } + if(data.extra){ + for(const i in data.extra){ + parsed=parse(data.extra[i]) + out[0]+=parsed[0]; + out[1]+=parsed[1]; + out[2]+=parsed[2]; + } + } + return out; +} +module.exports = parse diff --git a/util/chatparse_1204.js b/util/chatparse_1204.js new file mode 100644 index 0000000..693e363 --- /dev/null +++ b/util/chatparse_1204.js @@ -0,0 +1,9 @@ +const {processNbtMessage} = require("prismarine-chat"); +const parse=function(data){ + if(typeof data.type=="string"){ + return JSON.parse(processNbtMessage(data)); + } else { + return data; + } +} +module.exports = parse diff --git a/util/timeformat.js b/util/timeformat.js new file mode 100755 index 0000000..44f23e1 --- /dev/null +++ b/util/timeformat.js @@ -0,0 +1,24 @@ +module.exports = function (time) { + let finalString = '' + const seconds = Math.floor(time / 1000) % 60 + const minutes = Math.floor(time / 60000) % 60 + const hours = Math.floor(time / 3600000) % 24 + const days = Math.floor(time / 86400000) % 7 + const weeks = Math.floor(time / 604800000) + if (weeks != 0) { + finalString += `${weeks} week${weeks == 1 ? '' : 's'} ` + } + if (days != 0) { + finalString += `${days} day${days == 1 ? '' : 's'} ` + } + if (hours != 0) { + finalString += `${hours} hour${hours == 1 ? '' : 's'} ` + } + if (minutes != 0) { + finalString += `${minutes} minute${minutes == 1 ? '' : 's'} ` + } + if (seconds != 0) { + finalString += `${seconds} second${seconds == 1 ? '' : 's'} ` + } + return finalString +} diff --git a/util/uuidtoint.js b/util/uuidtoint.js new file mode 100644 index 0000000..30a286c --- /dev/null +++ b/util/uuidtoint.js @@ -0,0 +1,5 @@ +module.exports = function (uuid) { + const split_uuid = uuid.replace(/[^0-9a-f]/g, '').replace(/.{1,8}/g, a => { return '0x' + a }).match(/.{1,10}/g) + const num_uuid = [+split_uuid[0] << 0, +split_uuid[1] << 0, +split_uuid[2] << 0, +split_uuid[3] << 0] + return num_uuid +} From 2652fabf3c88dab05087e25a6a8ff272a4baeb5d Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sun, 7 Jul 2024 02:04:04 -0400 Subject: [PATCH 003/362] Fix message parsing --- util/chatparse.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/util/chatparse.js b/util/chatparse.js index 1d1ee3d..49e0300 100644 --- a/util/chatparse.js +++ b/util/chatparse.js @@ -6,7 +6,9 @@ const parse=function(data, l){ return ['', '', ''] } - + if(data[""]){ + data.text=data[""]; + } if(data.text){ out[0]+=data.text; out[1]+=data.text; From 6f41287349d5006569a977c267243fba40042d44 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 16 Jul 2024 09:51:21 -0400 Subject: [PATCH 004/362] Add color parsing to message parser --- util/chatparse.js | 52 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 44 insertions(+), 8 deletions(-) diff --git a/util/chatparse.js b/util/chatparse.js index 49e0300..59ba177 100644 --- a/util/chatparse.js +++ b/util/chatparse.js @@ -1,15 +1,51 @@ const lang = require("minecraft-data")("1.20.2").language; -const parse=function(data, l){ +const consoleColors={ + "dark_red":"\x1B[38;5;1m", + "red":"\x1B[38;5;9m", + "dark_green":"\x1B[38;5;2m", + "green":"\x1B[38;5;10m", + "gold":"\x1B[38;5;3m", + "yellow":"\x1B[38;5;11m", + "dark_blue":"\x1B[38;5;4m", + "blue":"\x1B[38;5;12m", + "dark_purple":"\x1B[38;5;5m", + "light_purple":"\x1B[38;5;13m", + "dark_aqua":"\x1B[38;5;6m", + "aqua":"\x1B[38;5;14m", + "black":"\x1B[38;5;0m", + "gray":"\x1B[38;5;7m", + "dark_gray":"\x1B[38;5;8m", + "white":"\x1B[38;5;15m", + "reset":"\x1B[0m\x1B[38;5;15m" +} +const parse=function(data, l, resetColor){ + //console.log(data) + let nkt=false; + if(!resetColor){ + resetColor=[consoleColors.reset]; + } const out=["","",""]; //console plain minecraft if (l === undefined) l = 0 - if (l >= 8) { + if (l >= 12) { return ['', '', ''] } if(data[""]){ data.text=data[""]; + nkt=true; + } + if(data.color){ + if(data.color=="reset"){ + out[0]+=resetColor[0] + } else { + out[0]+=consoleColors[data.color]; + } } if(data.text){ + if(nkt){ + out[0]+=resetColor[0]; + out[2]+=resetColor[1]; + } out[0]+=data.text; out[1]+=data.text; out[2]+=data.text; @@ -24,7 +60,7 @@ const parse=function(data, l){ trans3 = lang[trans3].replace(/%%/g, '\ue123') } for (const i in data.with) { - const j2 = parse(data.with[i], l + 1) + const j2 = parse(data.with[i], l + 1, data.color?[consoleColors[data.color],""]:resetColor) trans = trans.replace(/%s/, j2[0].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) trans2 = trans2.replace(/%s/, j2[1].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) trans3 = trans3.replace(/%s/, j2[2].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) @@ -32,25 +68,25 @@ const parse=function(data, l){ // %n$s only goes up to 4 normally if (data.with) { if (data.with[0]) { - const j2_1 = parse(data.with[0], l + 1) + const j2_1 = parse(data.with[0], l + 1, data.color?[consoleColors[data.color],""]:resetColor) trans = trans.replace(/%1\$s/g, j2_1[0].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) trans2 = trans2.replace(/%1\$s/g, j2_1[1].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) trans3 = trans3.replace(/%1\$s/g, j2_1[2].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) } if (data.with[1]) { - const j2_2 = parse(data.with[1], l + 1) + const j2_2 = parse(data.with[1], l + 1, data.color?[consoleColors[data.color],""]:resetColor) trans = trans.replace(/%2\$s/g, j2_2[0].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) trans2 = trans2.replace(/%2\$s/g, j2_2[1].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) trans3 = trans3.replace(/%2\$s/g, j2_2[2].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) } if (data.with[2]) { - const j2_3 = parse(data.with[2], l + 1) + const j2_3 = parse(data.with[2], l + 1, data.color?[consoleColors[data.color],""]:resetColor) trans = trans.replace(/%3\$s/g, j2_3[0].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) trans2 = trans2.replace(/%3\$s/g, j2_3[1].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) trans3 = trans3.replace(/%3\$s/g, j2_3[2].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) } if (data.with[3]) { - const j2_4 = parse(data.with[3], l + 1) + const j2_4 = parse(data.with[3], l + 1, data.color?[consoleColors[data.color],""]:resetColor) trans = trans.replace(/%4\$s/g, j2_4[0].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) trans2 = trans2.replace(/%4\$s/g, j2_4[1].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) trans3 = trans3.replace(/%4\$s/g, j2_4[2].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) @@ -62,7 +98,7 @@ const parse=function(data, l){ } if(data.extra){ for(const i in data.extra){ - parsed=parse(data.extra[i]) + parsed=parse(data.extra[i], l + 1, data.color?[consoleColors[data.color],""]:resetColor) out[0]+=parsed[0]; out[1]+=parsed[1]; out[2]+=parsed[2]; From dace4321ae82f5e273c7b261b9e46f82ae150a34 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 16 Jul 2024 09:56:08 -0400 Subject: [PATCH 005/362] Change about command message --- plugins/commands/about.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/plugins/commands/about.js b/plugins/commands/about.js index 26ac41c..2e83206 100644 --- a/plugins/commands/about.js +++ b/plugins/commands/about.js @@ -1,14 +1,13 @@ // This is not C source code //const settings = require('../settings.json') +const settings = require("../../settings.json") module.exports = { execute: function (c) { c.reply('{"text":"UBot - a minecraft bot made by a \\"baby\\""}'); c.reply('{"text":""}'); + c.reply('{"text":"Version '+settings.version+'"}'); + c.reply('{"text":""}'); c.reply('{"text":"To view system information, run the command \\"serverinfo\\"."}') - c.reply('{"text":""}'); - c.reply('{"text":"This is a new version so most features from version 9 and older have not been re-implemented."}') - c.reply('{"text":""}'); - c.reply('{"text":"The first version of UBot was made in August 2020."}') }, desc: 'About the bot', usage: '' From 59ae343117c08f9f35e9716cf5853ce119e7178e Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 16 Jul 2024 09:59:37 -0400 Subject: [PATCH 006/362] Prevent rapid execution of commands --- plugins/command.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/command.js b/plugins/command.js index 84b5d11..2386ee3 100755 --- a/plugins/command.js +++ b/plugins/command.js @@ -10,7 +10,8 @@ module.exports={ b.lastCmd=0; b.runCommand=(name, uuid, text)=>{ if(Date.now-b.lastCmd<=1000){ - console.log("Executed too early, "+(Date.now-b.lastCmd)+"ms left") + console.log("Executed too early, "+(Date.now-b.lastCmd)+"ms left"); + return; } const cmd=text.split(" "); if(cmds[cmd[0].toLowerCase()]){ From 01cad10e7b56bcb0744e110a0d330ed7388a4559 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 16 Jul 2024 10:02:42 -0400 Subject: [PATCH 007/362] Prevent logoff from running in minecraft --- plugins/commands/logoff.js | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/commands/logoff.js b/plugins/commands/logoff.js index 2a513af..22df5ae 100644 --- a/plugins/commands/logoff.js +++ b/plugins/commands/logoff.js @@ -1,5 +1,6 @@ module.exports={ execute: (c)=>{ + if(c.type!=console) return; c.bot._client.end(); }, desc: "Does nothing", // Command description From b959bdf2afc5a06e80556b63b701d96187db3995 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 16 Jul 2024 10:06:31 -0400 Subject: [PATCH 008/362] Add "stop command To restart the bot. --- plugins/commands/stop.js | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 plugins/commands/stop.js diff --git a/plugins/commands/stop.js b/plugins/commands/stop.js new file mode 100644 index 0000000..f940e93 --- /dev/null +++ b/plugins/commands/stop.js @@ -0,0 +1,10 @@ +module.exports={ + execute: (c)=>{ + if(c.type!=console) return; + process.exit(0); + }, + desc: "Restart bot", // Command description + usage: ' [optional]', // Command usage + hidden: true, + consoleIndex: true +} From b9bf7b4bec02ebacfa13f12070bc2adbc6231ddd Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 16 Jul 2024 10:10:02 -0400 Subject: [PATCH 009/362] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index aa73dc4..5b11671 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,3 @@ # botvX +The X is Roman Numeral for "10". \ No newline at end of file From db765ace5dee6c81c1e12f90b8a25e31bbeec824 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 16 Jul 2024 10:19:22 -0400 Subject: [PATCH 010/362] Stop command does not need consoleIndex --- plugins/commands/stop.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/plugins/commands/stop.js b/plugins/commands/stop.js index f940e93..38a99d0 100644 --- a/plugins/commands/stop.js +++ b/plugins/commands/stop.js @@ -5,6 +5,4 @@ module.exports={ }, desc: "Restart bot", // Command description usage: ' [optional]', // Command usage - hidden: true, - consoleIndex: true -} + hidden: true From b6d0c06e7bb677004f01bae3e55741e4cda12c87 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 16 Jul 2024 10:19:48 -0400 Subject: [PATCH 011/362] Please enter the commit message for your changes. --- plugins/commands/stop.js | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/commands/stop.js b/plugins/commands/stop.js index 38a99d0..473700e 100644 --- a/plugins/commands/stop.js +++ b/plugins/commands/stop.js @@ -6,3 +6,4 @@ module.exports={ desc: "Restart bot", // Command description usage: ' [optional]', // Command usage hidden: true +} From 037181d2e04671326f1ad187457c84b0daf83184 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 16 Jul 2024 10:43:20 -0400 Subject: [PATCH 012/362] Add command aliases + several bug fixes --- plugins/command.js | 18 +++++++++++++++--- plugins/commands/help.js | 2 +- plugins/commands/logoff.js | 2 +- plugins/commands/stop.js | 5 +++-- plugins/console.js | 3 --- 5 files changed, 20 insertions(+), 10 deletions(-) diff --git a/plugins/command.js b/plugins/command.js index 2386ee3..e8887bb 100755 --- a/plugins/command.js +++ b/plugins/command.js @@ -31,7 +31,7 @@ module.exports={ b.tellraw(uuid,JSON.stringify({"text":"Commands: "+helpCmds.join(" ")})); } b.printCmdHelp=(uuid,cmd)=>{ - b.tellraw(uuid,JSON.stringify({"text":"Commands: "+cmd+cmds[cmd].usage+" - "+cmds[cmd].desc})); + b.tellraw(uuid,JSON.stringify({"text":cmd+cmds[cmd].usage+" - "+cmds[cmd].desc})); } }, loadCMD:()=>{ @@ -42,8 +42,20 @@ module.exports={ continue } try { - cmds[bpl[i].split(".js")[0]]=require(`./commands/${bpl[i]}`); - console.log("Loaded command "+bpl[i].split(".js")[0]) + commandName=bpl[i].split(".js")[0]; + cmds[commandName]=require(`./commands/${bpl[i]}`); + console.log("Loaded command "+commandName) + if(cmds[commandName].aliases){ + for(const j in cmds[commandName].aliases){ + cmds[cmds[commandName].aliases[j]]={ + execute:cmds[commandName].execute, + desc:"Alias to "+commandName, + usage:cmds[commandName].usage, + hidden:true, + consoleIndex:cmds[commandName].consoleIndex + }; + } + } } catch (e) { console.log(e); } } }, diff --git a/plugins/commands/help.js b/plugins/commands/help.js index 480f9ff..0a3ccf3 100644 --- a/plugins/commands/help.js +++ b/plugins/commands/help.js @@ -3,7 +3,7 @@ module.exports={ if(c.args.length>0){ c.bot.printCmdHelp(c.uuid,c.args[0]); } else { - c.bot.printHelp(c.uuid); + c.bot.printHelp(c.args[0]); } }, desc: "Shows command help", diff --git a/plugins/commands/logoff.js b/plugins/commands/logoff.js index 22df5ae..71ef3ce 100644 --- a/plugins/commands/logoff.js +++ b/plugins/commands/logoff.js @@ -1,6 +1,6 @@ module.exports={ execute: (c)=>{ - if(c.type!=console) return; + if(c.type!="console") return; c.bot._client.end(); }, desc: "Does nothing", // Command description diff --git a/plugins/commands/stop.js b/plugins/commands/stop.js index 473700e..e04608c 100644 --- a/plugins/commands/stop.js +++ b/plugins/commands/stop.js @@ -1,9 +1,10 @@ module.exports={ execute: (c)=>{ - if(c.type!=console) return; + if(c.type!="console") return; process.exit(0); }, desc: "Restart bot", // Command description usage: ' [optional]', // Command usage - hidden: true + hidden: true, + aliases: ["restart"] } diff --git a/plugins/console.js b/plugins/console.js index 12b48ee..ac6d22c 100644 --- a/plugins/console.js +++ b/plugins/console.js @@ -14,14 +14,11 @@ module.exports = { prompt: '\x1b[0m\x1b[38;5;15m> ' }) rl.on('line', (l) => { - // 00000000-0000-0000-0000-Console00000 try { if(newercommands[l.split(' ')[0].toLowerCase()]){ if(newercommands[l.split(' ')[0].toLowerCase()].consoleIndex){ let tmpcmd = l.split(' '); const index2 = tmpcmd.splice(1,1)[0]; - - if (index2 === '*') { for (let i = 0; i < index.bot.length; i++) { //if(index.bot[i].o.disabled) continue; From c5852bb38187072e2beb9991d8d70f2f4f7dd08b Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 16 Jul 2024 11:13:07 -0400 Subject: [PATCH 013/362] Fixed 2 bugs and changed chat colors --- plugins/commands/help.js | 2 +- plugins/commands/testing.js | 8 -------- util/ConsoleCommand.js | 2 +- util/chatparse.js | 34 +++++++++++++++++----------------- 4 files changed, 19 insertions(+), 27 deletions(-) delete mode 100755 plugins/commands/testing.js diff --git a/plugins/commands/help.js b/plugins/commands/help.js index 0a3ccf3..480f9ff 100644 --- a/plugins/commands/help.js +++ b/plugins/commands/help.js @@ -3,7 +3,7 @@ module.exports={ if(c.args.length>0){ c.bot.printCmdHelp(c.uuid,c.args[0]); } else { - c.bot.printHelp(c.args[0]); + c.bot.printHelp(c.uuid); } }, desc: "Shows command help", diff --git a/plugins/commands/testing.js b/plugins/commands/testing.js deleted file mode 100755 index 8c4c82d..0000000 --- a/plugins/commands/testing.js +++ /dev/null @@ -1,8 +0,0 @@ -module.exports={ - load:()=>{ - console.log("Loaded on global") - }, - loadBot:(b)=>{ - console.log(`Loaded on bot ${b.id}`) - } -} \ No newline at end of file diff --git a/util/ConsoleCommand.js b/util/ConsoleCommand.js index 9510a57..e2987f5 100644 --- a/util/ConsoleCommand.js +++ b/util/ConsoleCommand.js @@ -20,7 +20,7 @@ class ConsoleCommand{ } console.log("Commands: "+helpCmds.join(" ")) }, - printCmdHelp:(cmd)=>{ + printCmdHelp:(uuid,cmd)=>{ console.log(cmd+cmds[cmd].usage+" - "+cmds[cmd].desc); } }; //bot does not exist at console diff --git a/util/chatparse.js b/util/chatparse.js index 59ba177..f6c3174 100644 --- a/util/chatparse.js +++ b/util/chatparse.js @@ -1,22 +1,22 @@ const lang = require("minecraft-data")("1.20.2").language; const consoleColors={ - "dark_red":"\x1B[38;5;1m", - "red":"\x1B[38;5;9m", - "dark_green":"\x1B[38;5;2m", - "green":"\x1B[38;5;10m", - "gold":"\x1B[38;5;3m", - "yellow":"\x1B[38;5;11m", - "dark_blue":"\x1B[38;5;4m", - "blue":"\x1B[38;5;12m", - "dark_purple":"\x1B[38;5;5m", - "light_purple":"\x1B[38;5;13m", - "dark_aqua":"\x1B[38;5;6m", - "aqua":"\x1B[38;5;14m", - "black":"\x1B[38;5;0m", - "gray":"\x1B[38;5;7m", - "dark_gray":"\x1B[38;5;8m", - "white":"\x1B[38;5;15m", - "reset":"\x1B[0m\x1B[38;5;15m" + "dark_red":"\x1B[0m\x1B[38;2;170;0;0m", + "red":"\x1B[0m\x1B[38;2;255;85;85m", + "dark_green":"\x1B[0m\x1B[38;2;0;170;0m", + "green":"\x1B[0m\x1B[38;2;85;255;85m", + "gold":"\x1B[0m\x1B[38;2;255;170;0m", + "yellow":"\x1B[0m\x1B[38;2;255;255;85m", + "dark_blue":"\x1B[0m\x1B[38;2;0;0;170m", + "blue":"\x1B[0m\x1B[38;2;85;85;255m", + "dark_purple":"\x1B[0m\x1B[38;2;170;0;170m", + "light_purple":"\x1B[0m\x1B[38;2;255;85;255m", + "dark_aqua":"\x1B[0m\x1B[38;2;0;170;170m", + "aqua":"\x1B[0m\x1B[38;2;85;255;255m", + "black":"\x1B[0m\x1B[48;2;127;127;127m\x1B[38;2;0;0;0m", + "gray":"\x1B[0m\x1B[38;2;170;170;170m", + "dark_gray":"\x1B[0m\x1B[38;2;85;85;85m", + "white":"\x1B[0m\x1B[38;2;255;255;255m", + "reset":"\x1B[0m\x1B[38;2;255;255;255m" } const parse=function(data, l, resetColor){ //console.log(data) From ae432da2779b6e6c54f513ed181798af014ed07d Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 16 Jul 2024 11:14:33 -0400 Subject: [PATCH 014/362] Ignore hexadecimal colors --- util/chatparse.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/util/chatparse.js b/util/chatparse.js index f6c3174..270bfcc 100644 --- a/util/chatparse.js +++ b/util/chatparse.js @@ -37,6 +37,8 @@ const parse=function(data, l, resetColor){ if(data.color){ if(data.color=="reset"){ out[0]+=resetColor[0] + } else if (data.color.startsWith("#")){ + out[0]+=""; } else { out[0]+=consoleColors[data.color]; } From 099a806f48f625cc9ce8894f368490dccc6504d4 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 16 Jul 2024 11:24:35 -0400 Subject: [PATCH 015/362] Rename VoolEagler58 and add /etc/os-release check --- plugins/commands/serverinfo.js | 57 +++++++++++++++++----------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/plugins/commands/serverinfo.js b/plugins/commands/serverinfo.js index 6ef794a..50b74df 100755 --- a/plugins/commands/serverinfo.js +++ b/plugins/commands/serverinfo.js @@ -3,7 +3,7 @@ const cp = require('child_process') const settings = require('../../settings.json') const timeformat = require('../../util/timeformat.js') const fs=require("fs") -const VoolEagler58 = function (text, value, color) { +const gr = function (text, value, color) { if (!color) color = 'white' return JSON.stringify({ translate: '%s: %s', @@ -45,41 +45,42 @@ const os2 = function (o2) { return o2 } } -// b.tellraw(sender,VoolEagler58("Example",example)) +// b.tellraw(sender,gr("Example",example)) module.exports = { execute: function (c) { - c.reply(VoolEagler58('Operating system', os2(process.platform))) - c.reply(VoolEagler58('CPU', os.cpus()[0].model)) - c.reply(VoolEagler58('Architecture', os.machine())) - c.reply(VoolEagler58('Username', os.userInfo().username)) - c.reply(VoolEagler58('Bot uptime', timeformat(process.uptime() * 1000))) - c.reply(VoolEagler58('System uptime', timeformat(os.uptime() * 1000))) - // b.tellraw(sender,VoolEagler58('System memory (total)',Math.floor(os.totalmem()/1000000)+'MB')); - c.reply(VoolEagler58('Node.js version', process.version)) + c.reply(gr('Operating system', os2(process.platform))) + c.reply(gr('CPU', os.cpus()[0].model)) + c.reply(gr('Architecture', os.machine())) + c.reply(gr('Username', os.userInfo().username)) + c.reply(gr('Bot uptime', timeformat(process.uptime() * 1000))) + c.reply(gr('System uptime', timeformat(os.uptime() * 1000))) + c.reply(gr('Node.js version', process.version)) if (process.platform == 'linux' || process.platform == 'freebsd') { - // const android_sdk=+cp.execSync("getprop ro.build.version.sdk").toString("UTF-8").split("\n")[0]; - /* /etc/os-release parser */ - const osrelease = fs.readFileSync("/etc/os-release").toString("UTF-8").split("\n"); - let osrelease2={}; - for(const i in osrelease){ - if(!osrelease[i].includes("=")) continue; - let osr_value=osrelease[i].split("=")[1]; - if(osr_value.startsWith("\"") && osr_value.endsWith("\"")){osr_value=osr_value.slice(1,osr_value.length-1)}; - osrelease2[osrelease[i].split("=")[0]]=osr_value; - } + try{ + const osrelease = fs.readFileSync("/etc/os-release").toString("UTF-8").split("\n"); + let osrelease2={}; + for(const i in osrelease){ + if(!osrelease[i].includes("=")) continue; + let osr_value=osrelease[i].split("=")[1]; + if(osr_value.startsWith("\"") && osr_value.endsWith("\"")){osr_value=osr_value.slice(1,osr_value.length-1)}; + osrelease2[osrelease[i].split("=")[0]]=osr_value; + } - if(osrelease2.PRETTY_NAME){ - c.reply(VoolEagler58('Linux release', osrelease2.PRETTY_NAME, 'dark_green')) + if(osrelease2.PRETTY_NAME){ + c.reply(gr('Linux release', osrelease2.PRETTY_NAME, 'dark_green')) + } + } catch(e){ + c.reply('{"text":"/etc/os-release does not exist. Information may be limited."}') } } else if (process.platform == 'android') { - // const android_sdk=+cp.execSync("getprop ro.build.version.sdk").toString("UTF-8").split("\n")[0]; const android_version = cp.execSync('getprop ro.build.version.release').toString('UTF-8').split('\n')[0] - c.reply(VoolEagler58('Android version', android_version, 'green')) - c.reply(VoolEagler58('Device model', cp.execSync('getprop ro.product.model').toString('UTF-8').split('\n')[0], 'green')) - c.reply(VoolEagler58('Device brand', cp.execSync('getprop ro.product.brand').toString('UTF-8').split('\n')[0], 'green')) + c.reply(gr('Android version', android_version, 'green')) + const dModel=cp.execSync('getprop ro.product.model').toString('UTF-8').split('\n')[0]; + const dBrand=cp.execSync('getprop ro.product.brand').toString('UTF-8').split('\n')[0]; + c.reply(gr('Device model', dBrand+dModel, 'green')) } - c.reply(VoolEagler58('Bot name', settings.name, 'yellow')) - c.reply(VoolEagler58('Bot version', settings.version, 'yellow')) + c.reply(gr('Bot name', settings.name, 'yellow')) + c.reply(gr('Bot version', settings.version, 'yellow')) }, desc: 'Get system/bot info (ported from V9). Not complete.', usage: '' From 2d9898a791bc5623d11e8fa2552987f51cb46e7c Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 16 Jul 2024 11:53:32 -0400 Subject: [PATCH 016/362] Add multi-prefix support --- plugins/!chat.js | 8 +++++--- plugins/command.js | 10 +++++----- plugins/commands/help.js | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/plugins/!chat.js b/plugins/!chat.js index d3a85ab..085fbd7 100755 --- a/plugins/!chat.js +++ b/plugins/!chat.js @@ -40,9 +40,11 @@ module.exports={ let fullCommand = ""; if(data.type=="player") fullCommand=data.message; //console.log(name, fullCommand) - if(fullCommand.startsWith(b.prefix)){ - const command=fullCommand.slice(b.prefix.length); - b.runCommand("N/A",data.uuid,command); + for(const i in b.prefix){ + if(fullCommand.startsWith(b.prefix[i])){ + const command=fullCommand.slice(b.prefix[i].length); + b.runCommand("N/A",data.uuid,command,b.prefix[i]); + } } }) }, diff --git a/plugins/command.js b/plugins/command.js index e8887bb..8a716ea 100755 --- a/plugins/command.js +++ b/plugins/command.js @@ -6,9 +6,9 @@ module.exports={ module.exports.loadCMD(); }, loadBot:(b)=>{ - b.prefix="\"" + b.prefix=["\"", "ubot:"] b.lastCmd=0; - b.runCommand=(name, uuid, text)=>{ + b.runCommand=(name, uuid, text, prefix)=>{ if(Date.now-b.lastCmd<=1000){ console.log("Executed too early, "+(Date.now-b.lastCmd)+"ms left"); return; @@ -16,17 +16,17 @@ module.exports={ const cmd=text.split(" "); if(cmds[cmd[0].toLowerCase()]){ try{ - cmds[cmd[0].toLowerCase()].execute(new Command(uuid,name,"nick N/A",text,"prefix N/A",b,false)) + cmds[cmd[0].toLowerCase()].execute(new Command(uuid,name,"nick N/A",text,prefix,b,false)) } catch(e) { console.log(e); b.chat("An error occured (check console for more info)") } } else { b.chat("Command not found") } } - b.printHelp=(uuid)=>{ + b.printHelp=(uuid,prefix)=>{ let helpCmds=[]; for(const i in cmds){ if(cmds[i].hidden) continue; - helpCmds.push(b.prefix+i) + helpCmds.push(prefix+i) } b.tellraw(uuid,JSON.stringify({"text":"Commands: "+helpCmds.join(" ")})); } diff --git a/plugins/commands/help.js b/plugins/commands/help.js index 480f9ff..7787210 100644 --- a/plugins/commands/help.js +++ b/plugins/commands/help.js @@ -3,7 +3,7 @@ module.exports={ if(c.args.length>0){ c.bot.printCmdHelp(c.uuid,c.args[0]); } else { - c.bot.printHelp(c.uuid); + c.bot.printHelp(c.uuid,c.prefix); } }, desc: "Shows command help", From 37be78000772f4bb12d487f1d8c2aeb8c7c7833d Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 16 Jul 2024 12:04:16 -0400 Subject: [PATCH 017/362] Bump version to 10.0.0-alpha.6 --- settings.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/settings.json b/settings.json index 0e00c1b..5ba4f20 100755 --- a/settings.json +++ b/settings.json @@ -1,8 +1,8 @@ { "secret":"/home/name3/settings10.json", "name": "botvX alpha", - "version": "10.0.0-alpha.5", - "version_mc": "1.20.4", + "version": "10.0.0-alpha.6", + "version_mc": "1.20.6", "servers":[ { "host": "kaboom.pw", From e42c82ed07b1eda2c866ba90162f50b0aecc5e2f Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 16 Jul 2024 12:14:07 -0400 Subject: [PATCH 018/362] Fix no message bug --- util/chatparse.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/util/chatparse.js b/util/chatparse.js index 270bfcc..76eccf9 100644 --- a/util/chatparse.js +++ b/util/chatparse.js @@ -18,8 +18,13 @@ const consoleColors={ "white":"\x1B[0m\x1B[38;2;255;255;255m", "reset":"\x1B[0m\x1B[38;2;255;255;255m" } -const parse=function(data, l, resetColor){ - //console.log(data) +const parse=function(_data, l, resetColor){ + let data; + if(typeof _data == "string"){ + data=JSON.parse(_data); + } else { + data=_data; + } let nkt=false; if(!resetColor){ resetColor=[consoleColors.reset]; From a13cbd91926e1183dfaeb0e774a630eb14aecfa0 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 16 Jul 2024 12:52:35 -0400 Subject: [PATCH 019/362] 1.20 chat parser fix --- plugins/!chat.js | 1 + settings.json | 2 +- util/chatparse.js | 8 +++++++- util/chatparse_1204.js | 2 ++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/plugins/!chat.js b/plugins/!chat.js index 085fbd7..053e443 100755 --- a/plugins/!chat.js +++ b/plugins/!chat.js @@ -36,6 +36,7 @@ module.exports={ }) b.on("chat",(data)=>{ const msg=parse(data.json); + console.log(data.json); console2.write(`[${b.id}] [${data.type}] `+msg[0]) let fullCommand = ""; if(data.type=="player") fullCommand=data.message; diff --git a/settings.json b/settings.json index 5ba4f20..30d33e2 100755 --- a/settings.json +++ b/settings.json @@ -2,7 +2,7 @@ "secret":"/home/name3/settings10.json", "name": "botvX alpha", "version": "10.0.0-alpha.6", - "version_mc": "1.20.6", + "version_mc": "1.20.4", "servers":[ { "host": "kaboom.pw", diff --git a/util/chatparse.js b/util/chatparse.js index 76eccf9..59442d2 100644 --- a/util/chatparse.js +++ b/util/chatparse.js @@ -21,7 +21,11 @@ const consoleColors={ const parse=function(_data, l, resetColor){ let data; if(typeof _data == "string"){ - data=JSON.parse(_data); + try { + data=JSON.parse(_data); + } catch(e){ + data={text:_data, color: "reset"} + } } else { data=_data; } @@ -47,6 +51,8 @@ const parse=function(_data, l, resetColor){ } else { out[0]+=consoleColors[data.color]; } + } else { + out[0]+=resetColor[0] } if(data.text){ if(nkt){ diff --git a/util/chatparse_1204.js b/util/chatparse_1204.js index 693e363..9461335 100644 --- a/util/chatparse_1204.js +++ b/util/chatparse_1204.js @@ -2,6 +2,8 @@ const {processNbtMessage} = require("prismarine-chat"); const parse=function(data){ if(typeof data.type=="string"){ return JSON.parse(processNbtMessage(data)); + } else if(typeof data=="string"){ + return JSON.parse(data); } else { return data; } From b6af4edc5fe57d1ed088acbf1c18e173e3eed546 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 16 Jul 2024 12:54:58 -0400 Subject: [PATCH 020/362] remove temu debugger --- plugins/!chat.js | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/!chat.js b/plugins/!chat.js index 053e443..085fbd7 100755 --- a/plugins/!chat.js +++ b/plugins/!chat.js @@ -36,7 +36,6 @@ module.exports={ }) b.on("chat",(data)=>{ const msg=parse(data.json); - console.log(data.json); console2.write(`[${b.id}] [${data.type}] `+msg[0]) let fullCommand = ""; if(data.type=="player") fullCommand=data.message; From bee724d945d9e2cd313b40a6755fc94bf410263e Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 16 Jul 2024 13:22:34 -0400 Subject: [PATCH 021/362] Fix chat parser bugs --- util/chatparse.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/util/chatparse.js b/util/chatparse.js index 59442d2..27b362f 100644 --- a/util/chatparse.js +++ b/util/chatparse.js @@ -64,7 +64,7 @@ const parse=function(_data, l, resetColor){ out[2]+=data.text; } if (data.translate) { - let trans = data.translate + let trans = data.translate.replace(/%%/g, '\ue123') let trans2 = data.translate.replace(/%%/g, '\ue123') let trans3 = data.translate.replace(/%%/g, '\ue123') if (lang[trans] !== undefined) { @@ -72,7 +72,7 @@ const parse=function(_data, l, resetColor){ trans2 = lang[trans2].replace(/%%/g, '\ue123') trans3 = lang[trans3].replace(/%%/g, '\ue123') } - for (const i in data.with) { + for (const i in data.with) { const j2 = parse(data.with[i], l + 1, data.color?[consoleColors[data.color],""]:resetColor) trans = trans.replace(/%s/, j2[0].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) trans2 = trans2.replace(/%s/, j2[1].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) @@ -105,8 +105,8 @@ const parse=function(_data, l, resetColor){ trans3 = trans3.replace(/%4\$s/g, j2_4[2].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) } } - out[1] += trans.replace(/%([0-9]*\$){0,1}s/g, '').replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s') - out[0] += trans2.replace(/%([0-9]*\$){0,1}s/g, '').replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s').replace(/\n/g, '\n') + out[0] += trans.replace(/%([0-9]*\$){0,1}s/g, '').replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s') + out[1] += trans2.replace(/%([0-9]*\$){0,1}s/g, '').replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s') out[2] += trans3.replace(/%([0-9]*\$){0,1}s/g, '').replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s') } if(data.extra){ From 8fcd6233f2731aad03257276f39a38e7d971fcdd Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 16 Jul 2024 13:32:43 -0400 Subject: [PATCH 022/362] Add legacy chat support to chat parser --- plugins/!chat.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/!chat.js b/plugins/!chat.js index 085fbd7..c3eace3 100755 --- a/plugins/!chat.js +++ b/plugins/!chat.js @@ -34,6 +34,11 @@ module.exports={ //console.log(data) b.emit("chat",{json:parse1204(data.content),type:"system",uuid:"N/A", message: ""}) }) + b._client.on("chat",(data)=>{ //Legacy chat + //console.log("sc", data) + //console.log(data) + b.emit("chat",{json:parse1204(data.message),type:"legacy",uuid:data.uuid?data.uuid:"5bcefaf5-a9b8-ffff-fff5-a9b85bcefa00", message: ""}) + }) b.on("chat",(data)=>{ const msg=parse(data.json); console2.write(`[${b.id}] [${data.type}] `+msg[0]) From 00bc495096303fa86411d36d6caf035d3d203efb Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 16 Jul 2024 13:52:41 -0400 Subject: [PATCH 023/362] Make say command support commands from console --- plugins/commands/say.js | 2 +- plugins/cq.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/commands/say.js b/plugins/commands/say.js index 14f20d2..ddde9a7 100644 --- a/plugins/commands/say.js +++ b/plugins/commands/say.js @@ -13,7 +13,7 @@ module.exports={ c.bot: Bot that received the command. Will be different type based on where it was received c.type: Type of bot receiving the command ("minecraft", "console", "discord") */ - if(c.args[0].startsWith("/")) return; + if(c.args[0].startsWith("/") && !c.type=="console") return; c.bot.chat(c.args.join(" ")) }, desc: "Sends a message to chat", // Command description diff --git a/plugins/cq.js b/plugins/cq.js index 5d8a430..ad69d0f 100755 --- a/plugins/cq.js +++ b/plugins/cq.js @@ -13,7 +13,7 @@ module.exports={//profileless_chat player_chat system_chat },150) //b.chat("Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. ") }) - b.chatqueue=[];//"Prefix: \""]; + b.chatqueue=[]; b.chat=function chat(msg){ if(msg.length==0) return; msg.match(/.{1,250}/g).forEach(element => { From 4020cf00a3be4ad0908df93b7e47631e87d38ae1 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 16 Jul 2024 14:28:31 -0400 Subject: [PATCH 024/362] Add UUID/name detector to chat parser player.js only contains stubs at this point --- plugins/!chat.js | 34 +++++++++++++++++++++++++++------- plugins/player.js | 12 ++++++++++++ 2 files changed, 39 insertions(+), 7 deletions(-) create mode 100644 plugins/player.js diff --git a/plugins/!chat.js b/plugins/!chat.js index c3eace3..381e6a1 100755 --- a/plugins/!chat.js +++ b/plugins/!chat.js @@ -17,30 +17,50 @@ module.exports={ b._client.on("profileless_chat",(data)=>{ //console.log("pxc", data) if(data.type==4){ - //const parsedmessage = parse(JSON.parse(data.message)); - //console.log(parsedmessage) - b.emit("chat",{json:parse1204(data.message),type:"profileless",uuid:"N/A", message: ""}) + const json=parse1204(data.message); + const parsed=parse(json)[1]; + let split=parsed.split(": "); + const beforeColon = split.splice(0,1)[0].split(" "); + const chatName = beforeColon[beforeColon.length-1] + const username=b.findRealName(chatName); + const uuid=b.findUUID(username) + b.emit("chat",{json,type:"profileless",uuid,message: split.join(": "), username}) } }) b._client.on("player_chat",(data)=>{ - //console.log("pc", data) + console.log("pc", data) if(data.type==4){ - b.emit("chat",{json:parse1204(data.unsignedChatContent),type:"player",uuid:data.senderUuid, message: data.plainMessage}) + b.emit("chat",{json:parse1204(data.unsignedChatContent),type:"player",uuid:data.senderUuid, message: data.plainMessage, username: parse(parse1204(data.networkName))[1]}) } }) b._client.on("system_chat",(data)=>{ //console.log("sc", data) //console.log(data) - b.emit("chat",{json:parse1204(data.content),type:"system",uuid:"N/A", message: ""}) + const json=parse1204(data.content); + const parsed=parse(json)[1]; + let split=parsed.split(": "); + const beforeColon = split.splice(0,1)[0].split(" "); + const chatName = beforeColon[beforeColon.length-1] + const username=b.findRealName(chatName); + const uuid=b.findUUID(username) + b.emit("chat",{json,type:"system",uuid, message: split.join(": "), username}) }) b._client.on("chat",(data)=>{ //Legacy chat //console.log("sc", data) //console.log(data) - b.emit("chat",{json:parse1204(data.message),type:"legacy",uuid:data.uuid?data.uuid:"5bcefaf5-a9b8-ffff-fff5-a9b85bcefa00", message: ""}) + const json=parse1204(data.message); + const parsed=parse(json)[1]; + let split=parsed.split(": "); + const beforeColon = split.splice(0,1)[0].split(" "); + const chatName = beforeColon[beforeColon.length-1] + const username=b.findRealName(chatName); + const uuid=b.findUUID(username) + b.emit("chat",{json,type:"legacy",uuid:data.uuid?data.uuid:uuid, message: split.join(": "), username}) }) b.on("chat",(data)=>{ const msg=parse(data.json); + console2.write(data.username+" ("+data.uuid+"): "+data.message) console2.write(`[${b.id}] [${data.type}] `+msg[0]) let fullCommand = ""; if(data.type=="player") fullCommand=data.message; diff --git a/plugins/player.js b/plugins/player.js new file mode 100644 index 0000000..bb32af9 --- /dev/null +++ b/plugins/player.js @@ -0,0 +1,12 @@ +module.exports={ + load:()=>{ + }, + loadBot:(b)=>{ + b.findUUID=(name)=>{ + return "00000000-0000-0000-0000-000000000000" + } + b.findRealName=(name)=>{ + return "Stereo Madness" + } + } +} \ No newline at end of file From 596ab8641d49abe510bfb2a1bd1ec1b07141d138 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 16 Jul 2024 15:26:40 -0400 Subject: [PATCH 025/362] Add player name/UUID detection from profileless, system and legacy chat --- plugins/!chat.js | 16 ++++++---------- plugins/player.js | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 10 deletions(-) diff --git a/plugins/!chat.js b/plugins/!chat.js index 381e6a1..ebc7d7f 100755 --- a/plugins/!chat.js +++ b/plugins/!chat.js @@ -20,8 +20,7 @@ module.exports={ const json=parse1204(data.message); const parsed=parse(json)[1]; let split=parsed.split(": "); - const beforeColon = split.splice(0,1)[0].split(" "); - const chatName = beforeColon[beforeColon.length-1] + const chatName = split.splice(0,1)[0] const username=b.findRealName(chatName); const uuid=b.findUUID(username) b.emit("chat",{json,type:"profileless",uuid,message: split.join(": "), username}) @@ -40,8 +39,7 @@ module.exports={ const json=parse1204(data.content); const parsed=parse(json)[1]; let split=parsed.split(": "); - const beforeColon = split.splice(0,1)[0].split(" "); - const chatName = beforeColon[beforeColon.length-1] + const chatName = split.splice(0,1)[0] const username=b.findRealName(chatName); const uuid=b.findUUID(username) b.emit("chat",{json,type:"system",uuid, message: split.join(": "), username}) @@ -52,23 +50,21 @@ module.exports={ const json=parse1204(data.message); const parsed=parse(json)[1]; let split=parsed.split(": "); - const beforeColon = split.splice(0,1)[0].split(" "); - const chatName = beforeColon[beforeColon.length-1] + const chatName = split.splice(0,1)[0] const username=b.findRealName(chatName); const uuid=b.findUUID(username) b.emit("chat",{json,type:"legacy",uuid:data.uuid?data.uuid:uuid, message: split.join(": "), username}) }) b.on("chat",(data)=>{ const msg=parse(data.json); - console2.write(data.username+" ("+data.uuid+"): "+data.message) console2.write(`[${b.id}] [${data.type}] `+msg[0]) - let fullCommand = ""; - if(data.type=="player") fullCommand=data.message; + let fullCommand = data.message; + //console.log(name, fullCommand) for(const i in b.prefix){ if(fullCommand.startsWith(b.prefix[i])){ const command=fullCommand.slice(b.prefix[i].length); - b.runCommand("N/A",data.uuid,command,b.prefix[i]); + b.runCommand(data.username,data.uuid,command,b.prefix[i]); } } }) diff --git a/plugins/player.js b/plugins/player.js index bb32af9..8f308c9 100644 --- a/plugins/player.js +++ b/plugins/player.js @@ -1,11 +1,48 @@ +const parse = require("../util/chatparse.js") +const parse1204 = require("../util/chatparse_1204.js") module.exports={ load:()=>{ }, loadBot:(b)=>{ + b.players={}; + b._client.on("player_info",(data)=>{ + console.log + let buffer2={}; + for(const i in data.data){ + let uuid; + if(data.data[i].uuid){ + uuid=data.data[i].uuid + } else if(data.data[i].UUID){ + uuid=data.data[i].UUID + } + if(data.data[i].player && data.data[i].player.name!==undefined){ + buffer2[uuid]={realName: data.data[i].player.name, displayName: parse(parse1204(data.data[i].displayName))[1]} + } else if(data.data[i].name!==undefined){ + buffer2[uuid]={realName: data.data[i].name, displayName: parse(parse1204(data.data[i].displayName))[1]} + } else if(data.data[i].displayName!==undefined){ + buffer2[uuid]={displayName: parse(parse1204(data.data[i].displayName))[1]} + } + } + for(const uuid in buffer2){ + if(!b.players[uuid]) b.players[uuid]={displayName:"",realName:""}; + if(buffer2[uuid].displayName) b.players[uuid].displayName=buffer2[uuid].displayName; + if(buffer2[uuid].realName) b.players[uuid].realName=buffer2[uuid].realName; + } + }) b.findUUID=(name)=>{ + for(const i in b.players){ + if(b.players[i].realName==name){ + return i; + } + } return "00000000-0000-0000-0000-000000000000" } b.findRealName=(name)=>{ + for(const i in b.players){ + if(b.players[i].displayName==name){ + return b.players[i].realName + } + } return "Stereo Madness" } } From cb65edf815bc8c6b6ed4f0ae9d42b99fe0f134e0 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 16 Jul 2024 16:41:49 -0400 Subject: [PATCH 026/362] Implement c.send --- util/Command.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/Command.js b/util/Command.js index eec245e..36ae182 100644 --- a/util/Command.js +++ b/util/Command.js @@ -2,7 +2,7 @@ const parse = require("../util/chatparse.js") class Command{ constructor (uuid,user,nick,cmd,prefix,bot,verify){ - this.send = ()=>{}; + this.send = (uuid,text)=>{bot.tellraw(uuid,text)}; this.reply = text => bot.tellraw(uuid,text); this.uuid = uuid; this.username = user; From 8965e533d6f32acb25dfeec33226a5e7b37cf545 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 16 Jul 2024 16:43:54 -0400 Subject: [PATCH 027/362] Implement @a support for c.send --- util/Command.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/Command.js b/util/Command.js index 36ae182..37d0969 100644 --- a/util/Command.js +++ b/util/Command.js @@ -2,7 +2,7 @@ const parse = require("../util/chatparse.js") class Command{ constructor (uuid,user,nick,cmd,prefix,bot,verify){ - this.send = (uuid,text)=>{bot.tellraw(uuid,text)}; + this.send = (text,uuid)=>{bot.tellraw(uuid?uuid:"@a",text)}; this.reply = text => bot.tellraw(uuid,text); this.uuid = uuid; this.username = user; From c9bf673a4d316306e77cb27b97253c51a2042e97 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 16 Jul 2024 16:59:18 -0400 Subject: [PATCH 028/362] Remove player chat logging --- plugins/!chat.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/plugins/!chat.js b/plugins/!chat.js index ebc7d7f..7251298 100755 --- a/plugins/!chat.js +++ b/plugins/!chat.js @@ -15,7 +15,6 @@ module.exports={ } */ b._client.on("profileless_chat",(data)=>{ - //console.log("pxc", data) if(data.type==4){ const json=parse1204(data.message); const parsed=parse(json)[1]; @@ -28,14 +27,11 @@ module.exports={ }) b._client.on("player_chat",(data)=>{ - console.log("pc", data) if(data.type==4){ b.emit("chat",{json:parse1204(data.unsignedChatContent),type:"player",uuid:data.senderUuid, message: data.plainMessage, username: parse(parse1204(data.networkName))[1]}) } }) b._client.on("system_chat",(data)=>{ - //console.log("sc", data) - //console.log(data) const json=parse1204(data.content); const parsed=parse(json)[1]; let split=parsed.split(": "); @@ -45,8 +41,6 @@ module.exports={ b.emit("chat",{json,type:"system",uuid, message: split.join(": "), username}) }) b._client.on("chat",(data)=>{ //Legacy chat - //console.log("sc", data) - //console.log(data) const json=parse1204(data.message); const parsed=parse(json)[1]; let split=parsed.split(": "); From 1d0f1e97f5a69b46798cd454af85e0586eacaa36 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 16 Jul 2024 17:12:33 -0400 Subject: [PATCH 029/362] Fix c.host and c.port --- util/Command.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util/Command.js b/util/Command.js index 37d0969..9539630 100644 --- a/util/Command.js +++ b/util/Command.js @@ -14,8 +14,8 @@ class Command{ this.index = bot.id; this.args = cmd.split(' ').slice(1); this.verify = verify; - this.host = bot.host; - this.port = bot.port; + this.host = bot.host.host; + this.port = bot.host.port; } } From 5eafd63404b46c83477210dda46b8a7ac97a119f Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 16 Jul 2024 17:21:33 -0400 Subject: [PATCH 030/362] Block 0000 uuid from running commands --- plugins/command.js | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/command.js b/plugins/command.js index 8a716ea..dfc1970 100755 --- a/plugins/command.js +++ b/plugins/command.js @@ -9,6 +9,7 @@ module.exports={ b.prefix=["\"", "ubot:"] b.lastCmd=0; b.runCommand=(name, uuid, text, prefix)=>{ + if(uuid="00000000-0000-0000-0000-000000000000") return; if(Date.now-b.lastCmd<=1000){ console.log("Executed too early, "+(Date.now-b.lastCmd)+"ms left"); return; From 672780014b9aa7221324be765513cd4bff450c00 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 16 Jul 2024 17:22:42 -0400 Subject: [PATCH 031/362] Add a single equal sign --- plugins/command.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/command.js b/plugins/command.js index dfc1970..d5c90d2 100755 --- a/plugins/command.js +++ b/plugins/command.js @@ -9,7 +9,7 @@ module.exports={ b.prefix=["\"", "ubot:"] b.lastCmd=0; b.runCommand=(name, uuid, text, prefix)=>{ - if(uuid="00000000-0000-0000-0000-000000000000") return; + if(uuid=="00000000-0000-0000-0000-000000000000") return; if(Date.now-b.lastCmd<=1000){ console.log("Executed too early, "+(Date.now-b.lastCmd)+"ms left"); return; From 754ad09d61cc1e292027575ea2c545d0885ce853 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 16 Jul 2024 17:26:50 -0400 Subject: [PATCH 032/362] Rename Stereo Madness to Geometrical Dominator /username Stereo Madness could break some commands. Geometrical Dominator is more than 16 characters. --- plugins/player.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/player.js b/plugins/player.js index 8f308c9..019416f 100644 --- a/plugins/player.js +++ b/plugins/player.js @@ -43,7 +43,7 @@ module.exports={ return b.players[i].realName } } - return "Stereo Madness" + return "Geometrical Dominator" } } } \ No newline at end of file From 5a58c878d608805e8c45df66996f2153c503f8ac Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 16 Jul 2024 17:29:29 -0400 Subject: [PATCH 033/362] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5b11671..11e840c 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ # botvX -The X is Roman Numeral for "10". \ No newline at end of file +The X is Roman Numeral for "10" because this is the 10th version, although it uses code from older versions down to version 6. From 2b707aca1af4a6900b27c9556748c0e232c755da Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 16 Jul 2024 17:30:37 -0400 Subject: [PATCH 034/362] Add netmsg command --- plugins/commands/netmsg.js | 39 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 plugins/commands/netmsg.js diff --git a/plugins/commands/netmsg.js b/plugins/commands/netmsg.js new file mode 100644 index 0000000..6dff7fd --- /dev/null +++ b/plugins/commands/netmsg.js @@ -0,0 +1,39 @@ +const {bot}=require("../../index.js"); +module.exports={ + execute: (c)=>{ + const json={ + translate: "[%s] %s: %s", + with:[ + { + translate: "%s:%s", + with:[ + { + text: c.host, + color: "light_purple" + }, + { + text: c.port+"", + color: "light_purple" + } + ], + color: "gray" + }, + { + text: c.username, + color: "light_purple" + }, + { + text: c.args.join(" ") + }, + ], + color: "white" + } + for(const i in bot){ + bot[i].tellraw("@a",JSON.stringify(json)) + } + }, + desc: "Send a message to all servers the bot is connected to", // Command description + usage: ' ', // Command usage + hidden: true, // To show the command on the help command list, remove this line + consoleIndex: true // When run from console, the second argument will be a bot ID +} From ffaa85a096ab4dde6e3065eb3cecf839526839a2 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 16 Jul 2024 18:23:48 -0400 Subject: [PATCH 035/362] Fix chat color parser --- util/chatparse.js | 1 + 1 file changed, 1 insertion(+) diff --git a/util/chatparse.js b/util/chatparse.js index 27b362f..48fc0de 100644 --- a/util/chatparse.js +++ b/util/chatparse.js @@ -117,6 +117,7 @@ const parse=function(_data, l, resetColor){ out[2]+=parsed[2]; } } + out[0]+=resetColor[0]; return out; } module.exports = parse From b25aad71a104f01b9cd5545d8ea0159d5820dc11 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 16 Jul 2024 18:27:19 -0400 Subject: [PATCH 036/362] Add number support to chat parser --- util/chatparse.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/util/chatparse.js b/util/chatparse.js index 48fc0de..d329886 100644 --- a/util/chatparse.js +++ b/util/chatparse.js @@ -26,6 +26,8 @@ const parse=function(_data, l, resetColor){ } catch(e){ data={text:_data, color: "reset"} } + } else if(typeof _data == "number"){ + data={text:_data+"", color: "reset"} } else { data=_data; } From e48ce14155b5c4da2245431631de58035f6d11c5 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Wed, 17 Jul 2024 08:23:06 -0400 Subject: [PATCH 037/362] Run clearInterval when reconnecting --- index.js | 5 ++++- plugins/commandblock.js | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index fdcde5a..adaef7d 100755 --- a/index.js +++ b/index.js @@ -48,7 +48,10 @@ const createBot = function createBot(host,oldId){ //console.log(bot); }) if(typeof oldId !== "undefined"){ - delete bot[oldId]; + for(const i in module.exports.bot[oldId].interval){ + clearInterval(module.exports.bot[oldId].interval[i]); + } + delete module.exports.bot[oldId]; bot.id=oldId; module.exports.bot[oldId]=bot; console.log("Re-creating bot "+bot.id) diff --git a/plugins/commandblock.js b/plugins/commandblock.js index 01f3690..1e2d8de 100755 --- a/plugins/commandblock.js +++ b/plugins/commandblock.js @@ -57,7 +57,7 @@ module.exports = { b.chat(`/fill ~ 10 ~ ~ 15 ~ command_block`) }) b.on('ccstart', () => { - setTimeout(() => { b.ccqi = setInterval(b.advanceccq, 12) }, 1000) // 1 Second and 12 Milliseconds + setTimeout(() => { b.interval.ccqi = setInterval(b.advanceccq, 12) }, 1000) // 1 Second and 12 Milliseconds b.ccStarted = true; b.info("Command block!"); }) From c04314ed00203faca4507df0aa4e86a23444d302 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Wed, 17 Jul 2024 08:23:35 -0400 Subject: [PATCH 038/362] Remove Command block! --- plugins/commandblock.js | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/commandblock.js b/plugins/commandblock.js index 1e2d8de..71c4808 100755 --- a/plugins/commandblock.js +++ b/plugins/commandblock.js @@ -59,7 +59,6 @@ module.exports = { b.on('ccstart', () => { setTimeout(() => { b.interval.ccqi = setInterval(b.advanceccq, 12) }, 1000) // 1 Second and 12 Milliseconds b.ccStarted = true; - b.info("Command block!"); }) b.on('chat', (data) => { // if (!b.ccStarted && (data.json.translate == 'commands.fill.failed' || (data.json.extra && data.json.extra[0] && data.json.extra[0].translate == 'commands.fill.failed') || From d676094098371f5bc09d0ec557662e9411293032 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Wed, 17 Jul 2024 08:30:56 -0400 Subject: [PATCH 039/362] Replace b.info with different function when console plugin is loaded --- plugins/console.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/plugins/console.js b/plugins/console.js index ac6d22c..9429ba9 100644 --- a/plugins/console.js +++ b/plugins/console.js @@ -6,6 +6,12 @@ const ConsoleCommand = require('../util/ConsoleCommand.js') const fs = require('fs') const newercommands = require('./command.js').cmds; let rl +function consoleWrite(text) { + readln.cursorTo(process.stdout, 0) + readln.clearLine(process.stdout, 0) + process.stdout.write(text + '\n') + rl.prompt(true) +} module.exports = { load: () => { rl = readln.createInterface({ @@ -21,7 +27,6 @@ module.exports = { const index2 = tmpcmd.splice(1,1)[0]; if (index2 === '*') { for (let i = 0; i < index.bot.length; i++) { - //if(index.bot[i].o.disabled) continue; const cmd = new ConsoleCommand(tmpcmd.join(' '),i); newercommands[l.split(' ')[0].toLowerCase()].execute(cmd) } @@ -34,7 +39,6 @@ module.exports = { newercommands[l.split(' ')[0].toLowerCase()].execute(cmd) } } - // things.consolecmds[l.toString().toLowerCase().split(" ")[0]].command(l,things) } catch (e) { console.log(e) } @@ -42,11 +46,11 @@ module.exports = { }) rl.prompt() }, + loadBot: (b)=>{ + b.info=(msg)=>{ + consoleWrite(`[${b.id}] [info] ${msg}`) + } + }, rl, - write: (text) => { - readln.cursorTo(process.stdout, 0) - readln.clearLine(process.stdout, 0) - process.stdout.write(text + '\n') - rl.prompt(true) - } + write: consoleWrite } From 603f4d0100e38f5725a3dee869db882d8d1f99fa Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Wed, 17 Jul 2024 09:55:43 -0400 Subject: [PATCH 040/362] Change command execution rate --- plugins/commandblock.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/plugins/commandblock.js b/plugins/commandblock.js index 71c4808..cb5cfa7 100755 --- a/plugins/commandblock.js +++ b/plugins/commandblock.js @@ -1,12 +1,12 @@ const uuidToInt = require('../util/uuidtoint.js') module.exports = { - cs: 1, + cs: 4, cs_v: 6, load: function () { }, loadBot: function (b) { - b.interval.commandFill = setInterval(() => { b.chat(`/fill ~ 10 ~ ~ 15 ~ command_block`) }, 60000) + b.interval.commandFill = setInterval(() => { b.chat(`/fill ~ 10 ~ ~3 15 ~3 command_block`) }, 60000) b.ccq = [] b.blocknoX = 0 b.blocknoZ = 0 @@ -16,7 +16,7 @@ module.exports = { b.advanceccq = function () { if (b.ccq[0] && b.ccq[0].length != 0) { - b._client.write('update_command_block', { + /*b._client.write('update_command_block', { command: b.ccq[0], location: { x: b.commandPos.x1 + b.blocknoX, @@ -25,7 +25,7 @@ module.exports = { }, mode: 2, flags: 1 - }) + })*/ b._client.write('update_command_block', { command: b.ccq[0], location: { @@ -33,7 +33,7 @@ module.exports = { y: b.commandPos.y1 + b.blocknoY, z: b.commandPos.z1 + b.blocknoZ }, - mode: 2, + mode: 1, flags: 5 }) b.blocknoX++ @@ -48,16 +48,16 @@ module.exports = { } } } - // console.log(b.blocknoX,b.blocknoY,b.blocknoZ) + console.log(b.blocknoX,b.blocknoY,b.blocknoZ) // console.log(b.blocknoX,b.blocknoZ) } b.ccq.splice(0, 1) } b._client.on("login",()=>{ - b.chat(`/fill ~ 10 ~ ~ 15 ~ command_block`) + b.chat(`/fill ~ 10 ~ ~3 15 ~3 command_block`) }) b.on('ccstart', () => { - setTimeout(() => { b.interval.ccqi = setInterval(b.advanceccq, 12) }, 1000) // 1 Second and 12 Milliseconds + setTimeout(() => { b.interval.ccqi = setInterval(b.advanceccq, 3) }, 1000) // 1 Second and 3 Milliseconds b.ccStarted = true; }) b.on('chat', (data) => { // @@ -75,7 +75,7 @@ module.exports = { if (a.x != b.original_pos.x || a.z != b.original_pos.z) { b.original_pos = { x: a.x, y: a.y, z: a.z } b.pos.correct = 0 - b.chat(`/fill ~ 10 ~ ~ 15 ~ command_block`) + b.chat(`/fill ~ 10 ~ ~3 15 ~3 command_block`) } } From 071b2698d81a1884f5ea72199cebe6d8318a00dd Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Wed, 17 Jul 2024 09:57:44 -0400 Subject: [PATCH 041/362] remove command not found message --- plugins/command.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/plugins/command.js b/plugins/command.js index d5c90d2..9d43976 100755 --- a/plugins/command.js +++ b/plugins/command.js @@ -19,8 +19,6 @@ module.exports={ try{ cmds[cmd[0].toLowerCase()].execute(new Command(uuid,name,"nick N/A",text,prefix,b,false)) } catch(e) { console.log(e); b.chat("An error occured (check console for more info)") } - } else { - b.chat("Command not found") } } b.printHelp=(uuid,prefix)=>{ From 6920625109c9f86759b1c80f1dd9b803fbd1398c Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Wed, 17 Jul 2024 10:12:42 -0400 Subject: [PATCH 042/362] Move command blocks up --- plugins/commandblock.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/commandblock.js b/plugins/commandblock.js index cb5cfa7..fee912d 100755 --- a/plugins/commandblock.js +++ b/plugins/commandblock.js @@ -6,7 +6,7 @@ module.exports = { }, loadBot: function (b) { - b.interval.commandFill = setInterval(() => { b.chat(`/fill ~ 10 ~ ~3 15 ~3 command_block`) }, 60000) + b.interval.commandFill = setInterval(() => { b.chat(`/fill ~ 220 ~ ~3 225 ~3 command_block`) }, 60000) b.ccq = [] b.blocknoX = 0 b.blocknoZ = 0 @@ -54,7 +54,7 @@ module.exports = { b.ccq.splice(0, 1) } b._client.on("login",()=>{ - b.chat(`/fill ~ 10 ~ ~3 15 ~3 command_block`) + b.chat(`/fill ~ 220 ~ ~3 225 ~3 command_block`) }) b.on('ccstart', () => { setTimeout(() => { b.interval.ccqi = setInterval(b.advanceccq, 3) }, 1000) // 1 Second and 3 Milliseconds @@ -75,7 +75,7 @@ module.exports = { if (a.x != b.original_pos.x || a.z != b.original_pos.z) { b.original_pos = { x: a.x, y: a.y, z: a.z } b.pos.correct = 0 - b.chat(`/fill ~ 10 ~ ~3 15 ~3 command_block`) + b.chat(`/fill ~ 220 ~ ~3 225 ~3 command_block`) } } @@ -85,7 +85,7 @@ module.exports = { x2: Math.ceil(a.x) + 3, z1: Math.floor(a.z), z2: Math.ceil(a.z) + 3, - y1: 10, + y1: 220, y2: 10 } // b.send("/fill ~5 0 ~5 ~-5 0 ~-5 command_block") From 7b3e1940966dd5ff0c9445a2caebc20ec8e24818 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Wed, 17 Jul 2024 10:16:59 -0400 Subject: [PATCH 043/362] Add plain chat event --- plugins/!chat.js | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/!chat.js b/plugins/!chat.js index 7251298..734fe2b 100755 --- a/plugins/!chat.js +++ b/plugins/!chat.js @@ -51,6 +51,7 @@ module.exports={ }) b.on("chat",(data)=>{ const msg=parse(data.json); + b.emit("plainchat",msg[1]) console2.write(`[${b.id}] [${data.type}] `+msg[0]) let fullCommand = data.message; From 69f9bcf90f0aed6f94a6beef1c513f53875db8c3 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Wed, 17 Jul 2024 10:20:32 -0400 Subject: [PATCH 044/362] Add command spy SC Task --- plugins/sc_cspy.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100755 plugins/sc_cspy.js diff --git a/plugins/sc_cspy.js b/plugins/sc_cspy.js new file mode 100755 index 0000000..7d28434 --- /dev/null +++ b/plugins/sc_cspy.js @@ -0,0 +1,16 @@ + +module.exports={ + load:()=>{ + + }, + loadBot:(b)=>{ + b.add_sc_task("cspy","/cspy on", true) + b.on('plainchat', (msg) => { + if (msg == "Successfully disabled CommandSpy") { + b.sc_tasks["cspy"].failed = 1 + } else if (msg == "Successfully enabled CommandSpy") { + b.sc_tasks["cspy"].failed = 0 + } + }) + } +} From 2a6a3b5e477d1b85a6f05833e229c4fae4c9f416 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Wed, 17 Jul 2024 11:26:24 -0400 Subject: [PATCH 045/362] Change command block name --- plugins/commandblock.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/commandblock.js b/plugins/commandblock.js index fee912d..bb42f5f 100755 --- a/plugins/commandblock.js +++ b/plugins/commandblock.js @@ -6,7 +6,7 @@ module.exports = { }, loadBot: function (b) { - b.interval.commandFill = setInterval(() => { b.chat(`/fill ~ 220 ~ ~3 225 ~3 command_block`) }, 60000) + b.interval.commandFill = setInterval(() => { b.chat(`/fill ~ 220 ~ ~3 225 ~3 command_block{CustomName:'{"translate":"pack.dropConfirm","color":"#FFAAFF"}'}`) }, 60000) b.ccq = [] b.blocknoX = 0 b.blocknoZ = 0 @@ -54,7 +54,7 @@ module.exports = { b.ccq.splice(0, 1) } b._client.on("login",()=>{ - b.chat(`/fill ~ 220 ~ ~3 225 ~3 command_block`) + b.chat(`/fill ~ 220 ~ ~3 225 ~3 command_block{CustomName:'{"translate":"pack.dropConfirm","color":"#FFAAFF"}'}`) }) b.on('ccstart', () => { setTimeout(() => { b.interval.ccqi = setInterval(b.advanceccq, 3) }, 1000) // 1 Second and 3 Milliseconds @@ -75,7 +75,7 @@ module.exports = { if (a.x != b.original_pos.x || a.z != b.original_pos.z) { b.original_pos = { x: a.x, y: a.y, z: a.z } b.pos.correct = 0 - b.chat(`/fill ~ 220 ~ ~3 225 ~3 command_block`) + b.chat(`/fill ~ 220 ~ ~3 225 ~3 command_block{CustomName:'{"translate":"pack.dropConfirm","color":"#FFAAFF"}'}`) } } From e6aaab63f44c00c2c0aef8922a6d9b3c1a851b8b Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Wed, 17 Jul 2024 11:41:18 -0400 Subject: [PATCH 046/362] Add gamemode SC task --- plugins/sc_gamemode.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100755 plugins/sc_gamemode.js diff --git a/plugins/sc_gamemode.js b/plugins/sc_gamemode.js new file mode 100755 index 0000000..03446bc --- /dev/null +++ b/plugins/sc_gamemode.js @@ -0,0 +1,16 @@ + +module.exports={ + load:()=>{ + + }, + loadBot:(b)=>{ + b.add_sc_task("gamemode","/minecraft:gamemode creative", true) + b._client.on('game_state_change', (p) => { + if (p.reason == 3 && p.gameMode != 1) { + b.sc_tasks["gamemode"].failed = 1 + } else if (p.reason == 3 && p.gameMode == 1) { + b.sc_tasks["gamemode"].failed = 0 + } + }) + } +} From 89d9fe24368310333fd59c622529cba6b7eaa944 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Wed, 17 Jul 2024 12:43:41 -0400 Subject: [PATCH 047/362] Move command blocks down --- plugins/commandblock.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/commandblock.js b/plugins/commandblock.js index bb42f5f..407f6f1 100755 --- a/plugins/commandblock.js +++ b/plugins/commandblock.js @@ -6,7 +6,7 @@ module.exports = { }, loadBot: function (b) { - b.interval.commandFill = setInterval(() => { b.chat(`/fill ~ 220 ~ ~3 225 ~3 command_block{CustomName:'{"translate":"pack.dropConfirm","color":"#FFAAFF"}'}`) }, 60000) + b.interval.commandFill = setInterval(() => { b.chat(`/fill ~ 20 ~ ~3 25 ~3 command_block{CustomName:'{"translate":"pack.dropConfirm","color":"#FFAAFF"}'}`) }, 60000) b.ccq = [] b.blocknoX = 0 b.blocknoZ = 0 @@ -54,7 +54,7 @@ module.exports = { b.ccq.splice(0, 1) } b._client.on("login",()=>{ - b.chat(`/fill ~ 220 ~ ~3 225 ~3 command_block{CustomName:'{"translate":"pack.dropConfirm","color":"#FFAAFF"}'}`) + b.chat(`/fill ~ 20 ~ ~3 25 ~3 command_block{CustomName:'{"translate":"pack.dropConfirm","color":"#FFAAFF"}'}`) }) b.on('ccstart', () => { setTimeout(() => { b.interval.ccqi = setInterval(b.advanceccq, 3) }, 1000) // 1 Second and 3 Milliseconds @@ -75,7 +75,7 @@ module.exports = { if (a.x != b.original_pos.x || a.z != b.original_pos.z) { b.original_pos = { x: a.x, y: a.y, z: a.z } b.pos.correct = 0 - b.chat(`/fill ~ 220 ~ ~3 225 ~3 command_block{CustomName:'{"translate":"pack.dropConfirm","color":"#FFAAFF"}'}`) + b.chat(`/fill ~ 20 ~ ~3 25 ~3 command_block{CustomName:'{"translate":"pack.dropConfirm","color":"#FFAAFF"}'}`) } } @@ -85,7 +85,7 @@ module.exports = { x2: Math.ceil(a.x) + 3, z1: Math.floor(a.z), z2: Math.ceil(a.z) + 3, - y1: 220, + y1: 20, y2: 10 } // b.send("/fill ~5 0 ~5 ~-5 0 ~-5 command_block") From 4abdd321a9e77da0cd8fbc49e3f70ebe0628295f Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Wed, 17 Jul 2024 13:35:14 -0400 Subject: [PATCH 048/362] Change username format --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index adaef7d..b58556e 100755 --- a/index.js +++ b/index.js @@ -8,7 +8,7 @@ const fs=require("fs") module.exports.bot=[]; const generateUser = function generateUser(){ - return "@s["+crypto.randomBytes(2).toString("hex")+"_=\xa7c "+crypto.randomBytes(2).toString("hex") + return "@s["+crypto.randomBytes(2).toString("hex")+"_= \xa7"+crypto.randomBytes(2).toString("hex") } const loadplug = (botno) => { From 6b0c0433974177e14cdfd6df3137ea6bfe2cb900 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Wed, 17 Jul 2024 16:53:44 -0400 Subject: [PATCH 049/362] Add exit alias to stop command --- plugins/commands/stop.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/commands/stop.js b/plugins/commands/stop.js index e04608c..da85dd2 100644 --- a/plugins/commands/stop.js +++ b/plugins/commands/stop.js @@ -6,5 +6,5 @@ module.exports={ desc: "Restart bot", // Command description usage: ' [optional]', // Command usage hidden: true, - aliases: ["restart"] + aliases: ["restart", "exit"] } From 7877b7c4d8eb9a39098cd952f943edde12925288 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Wed, 17 Jul 2024 19:02:06 -0400 Subject: [PATCH 050/362] Add startFailed to SCTask --- plugins/sc.js | 8 ++++---- plugins/sc_cspy.js | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/sc.js b/plugins/sc.js index 9e495cc..3efcee6 100755 --- a/plugins/sc.js +++ b/plugins/sc.js @@ -1,11 +1,11 @@ class SCTask{ - constructor (failTask,chatCommand){ + constructor (failTask,chatCommand,startFailed=false){ /* * failed: Whether to run this task * failTask: Command to run when failed is true * chatCommand: Whether to run failTask in chat rather than in command block */ - this.failed=false; + this.failed=startFailed; this.failTask=failTask; this.chatCommand=chatCommand; } @@ -27,8 +27,8 @@ module.exports={ } } },1000) - b.add_sc_task=(name,failTask,chatCommand)=>{ - b.sc_tasks[name] = new SCTask(failTask,chatCommand); + b.add_sc_task=(name,failTask,chatCommand,startFailed)=>{ + b.sc_tasks[name] = new SCTask(failTask,chatCommand,startFailed); } } } diff --git a/plugins/sc_cspy.js b/plugins/sc_cspy.js index 7d28434..b0da66a 100755 --- a/plugins/sc_cspy.js +++ b/plugins/sc_cspy.js @@ -4,7 +4,7 @@ module.exports={ }, loadBot:(b)=>{ - b.add_sc_task("cspy","/cspy on", true) + b.add_sc_task("cspy","/cspy on", true, true) b.on('plainchat', (msg) => { if (msg == "Successfully disabled CommandSpy") { b.sc_tasks["cspy"].failed = 1 From c8e240ac36983d2630509a1ce1056347dd5e8fe6 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Thu, 18 Jul 2024 01:42:42 -0400 Subject: [PATCH 051/362] Add 24-bit color support --- util/chatparse.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/util/chatparse.js b/util/chatparse.js index d329886..84c4410 100644 --- a/util/chatparse.js +++ b/util/chatparse.js @@ -12,12 +12,22 @@ const consoleColors={ "light_purple":"\x1B[0m\x1B[38;2;255;85;255m", "dark_aqua":"\x1B[0m\x1B[38;2;0;170;170m", "aqua":"\x1B[0m\x1B[38;2;85;255;255m", - "black":"\x1B[0m\x1B[48;2;127;127;127m\x1B[38;2;0;0;0m", + "black":"\x1B[0m\x1B[48;2;200;200;200m\x1B[38;2;0;0;0m", "gray":"\x1B[0m\x1B[38;2;170;170;170m", "dark_gray":"\x1B[0m\x1B[38;2;85;85;85m", "white":"\x1B[0m\x1B[38;2;255;255;255m", "reset":"\x1B[0m\x1B[38;2;255;255;255m" } +const hexColorParser=(color)=>{ + let out="\x1B[0m";//\x1B[48;2;200;200;200m\x1B[38;2;0;0;0m + const redChannel=Number("0x"+color.slice(1,3)); + const greenChannel=Number("0x"+color.slice(3,5)); + const blueChannel=Number("0x"+color.slice(5,7)); + if(redChannel < 96 && greenChannel < 96 && blueChannel < 96){ + out+="\x1B[48;2;200;200;200m"; + } + return out+`\x1B[38;2;${redChannel};${greenChannel};${blueChannel}m` +} const parse=function(_data, l, resetColor){ let data; if(typeof _data == "string"){ @@ -49,7 +59,7 @@ const parse=function(_data, l, resetColor){ if(data.color=="reset"){ out[0]+=resetColor[0] } else if (data.color.startsWith("#")){ - out[0]+=""; + out[0]+=hexColorParser(data.color); } else { out[0]+=consoleColors[data.color]; } From ffc9583c64f3a727fbff6fe0351c3635ec952f94 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Thu, 18 Jul 2024 01:44:08 -0400 Subject: [PATCH 052/362] Add usernames to about command --- plugins/commands/about.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/commands/about.js b/plugins/commands/about.js index 2e83206..b685c77 100644 --- a/plugins/commands/about.js +++ b/plugins/commands/about.js @@ -3,7 +3,7 @@ const settings = require("../../settings.json") module.exports = { execute: function (c) { - c.reply('{"text":"UBot - a minecraft bot made by a \\"baby\\""}'); + c.reply('{"text":"UBot - a minecraft bot made by 77c8f4699b732c11 / a5a06d596f15c7db"}'); c.reply('{"text":""}'); c.reply('{"text":"Version '+settings.version+'"}'); c.reply('{"text":""}'); From 2992a3ba5d25f593e8ba03c0b38f45f224064cd0 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Thu, 18 Jul 2024 01:49:55 -0400 Subject: [PATCH 053/362] Move prefixes to settings --- plugins/command.js | 3 ++- settings.json | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/command.js b/plugins/command.js index 9d43976..2cae7c3 100755 --- a/plugins/command.js +++ b/plugins/command.js @@ -1,12 +1,13 @@ const fs=require("fs"); const Command=require("../util/Command.js"); +const settings = require("../settings.json"); let cmds={}; module.exports={ load:()=>{ module.exports.loadCMD(); }, loadBot:(b)=>{ - b.prefix=["\"", "ubot:"] + b.prefix=settings.prefix; b.lastCmd=0; b.runCommand=(name, uuid, text, prefix)=>{ if(uuid=="00000000-0000-0000-0000-000000000000") return; diff --git a/settings.json b/settings.json index 30d33e2..f582985 100755 --- a/settings.json +++ b/settings.json @@ -3,6 +3,10 @@ "name": "botvX alpha", "version": "10.0.0-alpha.6", "version_mc": "1.20.4", + "prefix":[ + "ubot:", + "\"" + ], "servers":[ { "host": "kaboom.pw", From bac639243adf44192dede2eadde393b9cbfdf122 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Thu, 18 Jul 2024 02:34:59 -0400 Subject: [PATCH 054/362] Add support for message types other than 4 to chat parser --- plugins/!chat.js | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/plugins/!chat.js b/plugins/!chat.js index 734fe2b..aeec7c2 100755 --- a/plugins/!chat.js +++ b/plugins/!chat.js @@ -1,6 +1,16 @@ const console2 = require("./console.js") const parse = require("../util/chatparse.js") const parse1204 = require("../util/chatparse_1204.js") +const messageTypes=[ + "", + "chat.type.emote", + "commands.message.display.incoming", + "", + "", + "chat.type.announcement", + "", + "" +] module.exports={ load:()=>{ //console.log("Loaded on global") @@ -15,6 +25,7 @@ module.exports={ } */ b._client.on("profileless_chat",(data)=>{ + console.log(data) if(data.type==4){ const json=parse1204(data.message); const parsed=parse(json)[1]; @@ -23,12 +34,43 @@ module.exports={ const username=b.findRealName(chatName); const uuid=b.findUUID(username) b.emit("chat",{json,type:"profileless",uuid,message: split.join(": "), username}) + } else { + b.emit("chat",{ + json: { + translate: messageTypes[data.type], + color:data.type==2?"gray":"reset", + with:[ + parse1204(data.name), + parse1204(data.message) + ] + }, + type:"profileless", + uuid:"00000000-0000-0000-0000-000000000000", + message: parse(parse1204(data.message))[1], + username:parse(parse1204(data.name))[1] + }) } }) b._client.on("player_chat",(data)=>{ + console.log(data) if(data.type==4){ b.emit("chat",{json:parse1204(data.unsignedChatContent),type:"player",uuid:data.senderUuid, message: data.plainMessage, username: parse(parse1204(data.networkName))[1]}) + } else { + b.emit("chat",{ + json: { + translate: messageTypes[data.type], + color:data.type==2?"gray":"reset", + with:[ + parse1204(data.networkName), + data.plainMessage + ] + }, + type:"player", + uuid:data.senderUuid, + message: parse(data.plainMessage)[1], + username:parse(parse1204(data.networkName))[1] + }) } }) b._client.on("system_chat",(data)=>{ From 5455c462e1d7717374a0240768ebf72cc8faa76d Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Thu, 18 Jul 2024 02:36:05 -0400 Subject: [PATCH 055/362] Remove a space --- plugins/!chat.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/!chat.js b/plugins/!chat.js index aeec7c2..0212450 100755 --- a/plugins/!chat.js +++ b/plugins/!chat.js @@ -47,7 +47,7 @@ module.exports={ type:"profileless", uuid:"00000000-0000-0000-0000-000000000000", message: parse(parse1204(data.message))[1], - username:parse(parse1204(data.name))[1] + username:parse(parse1204(data.name))[1] }) } }) From 3be3335c069e1c88f125c87f902aca11a1afa45e Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Thu, 18 Jul 2024 02:47:04 -0400 Subject: [PATCH 056/362] Remove packet logging to console --- plugins/!chat.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/plugins/!chat.js b/plugins/!chat.js index 0212450..4c29d63 100755 --- a/plugins/!chat.js +++ b/plugins/!chat.js @@ -25,7 +25,6 @@ module.exports={ } */ b._client.on("profileless_chat",(data)=>{ - console.log(data) if(data.type==4){ const json=parse1204(data.message); const parsed=parse(json)[1]; @@ -53,7 +52,6 @@ module.exports={ }) b._client.on("player_chat",(data)=>{ - console.log(data) if(data.type==4){ b.emit("chat",{json:parse1204(data.unsignedChatContent),type:"player",uuid:data.senderUuid, message: data.plainMessage, username: parse(parse1204(data.networkName))[1]}) } else { From 2090e9485c726f45c1eca0d2f9c3300f5cf1fb33 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Thu, 18 Jul 2024 02:50:56 -0400 Subject: [PATCH 057/362] Remove command block test code --- plugins/commandblock.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/plugins/commandblock.js b/plugins/commandblock.js index 407f6f1..36b3f5b 100755 --- a/plugins/commandblock.js +++ b/plugins/commandblock.js @@ -16,7 +16,7 @@ module.exports = { b.advanceccq = function () { if (b.ccq[0] && b.ccq[0].length != 0) { - /*b._client.write('update_command_block', { + b._client.write('update_command_block', { command: b.ccq[0], location: { x: b.commandPos.x1 + b.blocknoX, @@ -25,7 +25,7 @@ module.exports = { }, mode: 2, flags: 1 - })*/ + }) b._client.write('update_command_block', { command: b.ccq[0], location: { @@ -33,7 +33,7 @@ module.exports = { y: b.commandPos.y1 + b.blocknoY, z: b.commandPos.z1 + b.blocknoZ }, - mode: 1, + mode: 2, flags: 5 }) b.blocknoX++ @@ -48,8 +48,6 @@ module.exports = { } } } - console.log(b.blocknoX,b.blocknoY,b.blocknoZ) - // console.log(b.blocknoX,b.blocknoZ) } b.ccq.splice(0, 1) } From a9a5a29217202beba6026749abc4b1065d7c22c4 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Thu, 18 Jul 2024 14:47:58 -0400 Subject: [PATCH 058/362] Make black text highlight slightly brighter --- util/chatparse.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/util/chatparse.js b/util/chatparse.js index 84c4410..943e55e 100644 --- a/util/chatparse.js +++ b/util/chatparse.js @@ -12,19 +12,19 @@ const consoleColors={ "light_purple":"\x1B[0m\x1B[38;2;255;85;255m", "dark_aqua":"\x1B[0m\x1B[38;2;0;170;170m", "aqua":"\x1B[0m\x1B[38;2;85;255;255m", - "black":"\x1B[0m\x1B[48;2;200;200;200m\x1B[38;2;0;0;0m", + "black":"\x1B[0m\x1B[48;2;220;220;220m\x1B[38;2;0;0;0m", "gray":"\x1B[0m\x1B[38;2;170;170;170m", "dark_gray":"\x1B[0m\x1B[38;2;85;85;85m", "white":"\x1B[0m\x1B[38;2;255;255;255m", "reset":"\x1B[0m\x1B[38;2;255;255;255m" } const hexColorParser=(color)=>{ - let out="\x1B[0m";//\x1B[48;2;200;200;200m\x1B[38;2;0;0;0m + let out="\x1B[0m";//\x1B[48;2;220;220;220m\x1B[38;2;0;0;0m const redChannel=Number("0x"+color.slice(1,3)); const greenChannel=Number("0x"+color.slice(3,5)); const blueChannel=Number("0x"+color.slice(5,7)); if(redChannel < 96 && greenChannel < 96 && blueChannel < 96){ - out+="\x1B[48;2;200;200;200m"; + out+="\x1B[48;2;220;220;220m"; } return out+`\x1B[38;2;${redChannel};${greenChannel};${blueChannel}m` } From e6c79e68138530c39b423d45a8171b37f91ffc02 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Thu, 18 Jul 2024 14:50:56 -0400 Subject: [PATCH 059/362] Add more prefixes Yes, SundanceNanshan 10A23941a is an iPhone firmware. --- settings.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/settings.json b/settings.json index f582985..8e65d5a 100755 --- a/settings.json +++ b/settings.json @@ -5,7 +5,10 @@ "version_mc": "1.20.4", "prefix":[ "ubot:", - "\"" + "\"", + "''", + "``", + "SundanceNanshan 10A23941a" ], "servers":[ { From 26698ecf9be8ea3a8446272b7e35430c216c9aea Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Thu, 18 Jul 2024 15:40:16 -0400 Subject: [PATCH 060/362] Change iOS version --- settings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.json b/settings.json index 8e65d5a..0742113 100755 --- a/settings.json +++ b/settings.json @@ -8,7 +8,7 @@ "\"", "''", "``", - "SundanceNanshan 10A23941a" + "WhitetailAni 14A93012r" ], "servers":[ { From c6a2eaf29830080cf70a027ae2f8684786ae2e10 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Thu, 18 Jul 2024 16:18:27 -0400 Subject: [PATCH 061/362] Add automatic text formatter --- util/textformat.js | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 util/textformat.js diff --git a/util/textformat.js b/util/textformat.js new file mode 100644 index 0000000..8519949 --- /dev/null +++ b/util/textformat.js @@ -0,0 +1,6 @@ +module.exports = function (text) { + return JSON.stringify({ + text: text, + color: "light_purple" + }) +} From 8729e60fed6547a70e73358fdf22c0907f57dfa8 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Thu, 18 Jul 2024 16:55:23 -0400 Subject: [PATCH 062/362] Add eval command --- plugins/commands/eval.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 plugins/commands/eval.js diff --git a/plugins/commands/eval.js b/plugins/commands/eval.js new file mode 100644 index 0000000..10c9cb6 --- /dev/null +++ b/plugins/commands/eval.js @@ -0,0 +1,17 @@ +const textformat=require("../../util/textformat.js") +const index=require("../../index.js") //Not used in the code, but may be used by users of the command +module.exports={ + execute: (c)=>{ + if(c.type!="console"){ + c.reply(textformat("Eval command is currently not available to players in Minecraft")) + }; + try{ + console.log(eval(c.args.join(" "))); + }catch(e){ + console.error(e); + } + }, + desc: "Run JavaScript code", // Command description + usage: '', // Command usage + hidden: true +} From c02de94190c37a05cb57c22715e415b7b19804fd Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Fri, 19 Jul 2024 11:36:16 -0400 Subject: [PATCH 063/362] Change eval command message --- plugins/commands/eval.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/commands/eval.js b/plugins/commands/eval.js index 10c9cb6..b014bd3 100644 --- a/plugins/commands/eval.js +++ b/plugins/commands/eval.js @@ -3,7 +3,7 @@ const index=require("../../index.js") //Not used in the code, but may be used by module.exports={ execute: (c)=>{ if(c.type!="console"){ - c.reply(textformat("Eval command is currently not available to players in Minecraft")) + c.reply(textformat("Eval command is currently not available to players in Minecraft due to security issues.")) }; try{ console.log(eval(c.args.join(" "))); From 5f01efb646857eb1c209a02372f3c4d13887d802 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Fri, 19 Jul 2024 11:45:40 -0400 Subject: [PATCH 064/362] Change textformat.js formatting to be similar to /say --- util/textformat.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/util/textformat.js b/util/textformat.js index 8519949..3b06d37 100644 --- a/util/textformat.js +++ b/util/textformat.js @@ -1,6 +1,17 @@ +const settings=require("../settings.json"); module.exports = function (text) { return JSON.stringify({ - text: text, - color: "light_purple" + translate: "[%s] %s", + color: "#FFAAFF", + with:[ + { + text: settings.name, + color: "light_purple" + }, + { + text: text, + color: "white" + } + ] }) } From 3998b65bca7e367218eef27987deba2713b8039c Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Fri, 19 Jul 2024 11:47:43 -0400 Subject: [PATCH 065/362] Make about command use settings.name --- plugins/commands/about.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/commands/about.js b/plugins/commands/about.js index b685c77..913ca76 100644 --- a/plugins/commands/about.js +++ b/plugins/commands/about.js @@ -3,7 +3,7 @@ const settings = require("../../settings.json") module.exports = { execute: function (c) { - c.reply('{"text":"UBot - a minecraft bot made by 77c8f4699b732c11 / a5a06d596f15c7db"}'); + c.reply('{"text":"'+settings.name+' - a minecraft bot made by 77c8f4699b732c11 / a5a06d596f15c7db"}'); c.reply('{"text":""}'); c.reply('{"text":"Version '+settings.version+'"}'); c.reply('{"text":""}'); From 6eefe2d4b121398b64c569cc4e4eca85d7df0e97 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Fri, 19 Jul 2024 11:48:07 -0400 Subject: [PATCH 066/362] Add "info" alias to about command --- plugins/commands/about.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/commands/about.js b/plugins/commands/about.js index 913ca76..00ec642 100644 --- a/plugins/commands/about.js +++ b/plugins/commands/about.js @@ -10,5 +10,6 @@ module.exports = { c.reply('{"text":"To view system information, run the command \\"serverinfo\\"."}') }, desc: 'About the bot', - usage: '' + usage: '', + aliases: ["info"] } From 06305749001d7a4cf7ecc222f102a12e716fcc3a Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Fri, 19 Jul 2024 12:10:11 -0400 Subject: [PATCH 067/362] Add clear chat filter --- plugins/!chat.js | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/!chat.js b/plugins/!chat.js index 4c29d63..fb4a799 100755 --- a/plugins/!chat.js +++ b/plugins/!chat.js @@ -91,6 +91,7 @@ module.exports={ }) b.on("chat",(data)=>{ const msg=parse(data.json); + if(msg[1].endsWith("\n\n\n\n\nThe chat has been cleared")) return; b.emit("plainchat",msg[1]) console2.write(`[${b.id}] [${data.type}] `+msg[0]) let fullCommand = data.message; From 10793285b6abfd0a9d497e265f89bd451c09862b Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Fri, 19 Jul 2024 12:10:22 -0400 Subject: [PATCH 068/362] Fix crash exploit --- util/chatparse.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/util/chatparse.js b/util/chatparse.js index 943e55e..8b72fc0 100644 --- a/util/chatparse.js +++ b/util/chatparse.js @@ -1,4 +1,8 @@ -const lang = require("minecraft-data")("1.20.2").language; +const _lang = require("minecraft-data")("1.20.2").language; +let lang=Object.create(null); //Without constructor function +for(const i in _lang){ + lang[i]=_lang[i]; +} const consoleColors={ "dark_red":"\x1B[0m\x1B[38;2;170;0;0m", "red":"\x1B[0m\x1B[38;2;255;85;85m", From 525ef4ed5af137c9ca64d73b3dd6b2b39c3181e9 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Fri, 19 Jul 2024 14:12:40 -0400 Subject: [PATCH 069/362] Add error handler to chat parser --- util/chatparse.js | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/util/chatparse.js b/util/chatparse.js index 8b72fc0..dc4062a 100644 --- a/util/chatparse.js +++ b/util/chatparse.js @@ -32,7 +32,10 @@ const hexColorParser=(color)=>{ } return out+`\x1B[38;2;${redChannel};${greenChannel};${blueChannel}m` } -const parse=function(_data, l, resetColor){ +const parse=function(_data, l = 0, resetColor){ + if (l >= 12) { + return ['', '', ''] + } let data; if(typeof _data == "string"){ try { @@ -50,11 +53,6 @@ const parse=function(_data, l, resetColor){ resetColor=[consoleColors.reset]; } const out=["","",""]; //console plain minecraft - if (l === undefined) l = 0 - if (l >= 12) { - return ['', '', ''] - } - if(data[""]){ data.text=data[""]; nkt=true; @@ -136,4 +134,16 @@ const parse=function(_data, l, resetColor){ out[0]+=resetColor[0]; return out; } -module.exports = parse +const parse2=function(_data, l, resetColor){ + try{ + return parse(_data) + } catch(e){ + console.error(e) + return [ + "\x1B[0m\x1B[38;2;255;85;85mAn error occured while parsing a message. See console for more information.", + "An error occured while parsing a message. See console for more information.", + "§cAn error occured while parsing a message. See console for more information." + ] + } +} +module.exports = parse2 From 6e94db693dc8e99c5a4d4f64aeb11c8aee180912 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Fri, 19 Jul 2024 14:18:52 -0400 Subject: [PATCH 070/362] --- util/chatparse.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/util/chatparse.js b/util/chatparse.js index dc4062a..c7b493b 100644 --- a/util/chatparse.js +++ b/util/chatparse.js @@ -32,7 +32,7 @@ const hexColorParser=(color)=>{ } return out+`\x1B[38;2;${redChannel};${greenChannel};${blueChannel}m` } -const parse=function(_data, l = 0, resetColor){ +const parse=function(_data, l = 0, resetColor = consoleColors.reset){ if (l >= 12) { return ['', '', ''] } @@ -49,9 +49,6 @@ const parse=function(_data, l = 0, resetColor){ data=_data; } let nkt=false; - if(!resetColor){ - resetColor=[consoleColors.reset]; - } const out=["","",""]; //console plain minecraft if(data[""]){ data.text=data[""]; From bbdad083580e036438dc402ce0ceef4f1851ff86 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Fri, 19 Jul 2024 14:31:24 -0400 Subject: [PATCH 071/362] Please enter the commit message for your changes. Lines starting --- util/chatparse.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/chatparse.js b/util/chatparse.js index c7b493b..d13c8e6 100644 --- a/util/chatparse.js +++ b/util/chatparse.js @@ -32,7 +32,7 @@ const hexColorParser=(color)=>{ } return out+`\x1B[38;2;${redChannel};${greenChannel};${blueChannel}m` } -const parse=function(_data, l = 0, resetColor = consoleColors.reset){ +const parse=function(_data, l = 0, resetColor = [consoleColors.reset]){ if (l >= 12) { return ['', '', ''] } From dc770f115cfeea8a598fff97c59ee6b81a6cec13 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Fri, 19 Jul 2024 15:00:50 -0400 Subject: [PATCH 072/362] Add aliases to template command --- plugins/commands/template.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/commands/template.js b/plugins/commands/template.js index ff37388..60b155a 100644 --- a/plugins/commands/template.js +++ b/plugins/commands/template.js @@ -17,5 +17,6 @@ module.exports={ desc: "Does nothing", // Command description usage: ' [optional]', // Command usage hidden: true, // To show the command on the help command list, remove this line - consoleIndex: true // When run from console, the second argument will be a bot ID + consoleIndex: true, // When run from console, the second argument will be a bot ID + aliases: ["example", "testing"] // Other command names that will work the same } From f8b39037a125ea436653698548216a84d0242fcc Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Fri, 19 Jul 2024 15:12:54 -0400 Subject: [PATCH 073/362] Add refill core command --- plugins/commands/refill.js | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 plugins/commands/refill.js diff --git a/plugins/commands/refill.js b/plugins/commands/refill.js new file mode 100644 index 0000000..2cf163d --- /dev/null +++ b/plugins/commands/refill.js @@ -0,0 +1,10 @@ +module.exports={ + execute: (c)=>{ + c.bot.chat(`/fill ~ 20 ~ ~3 25 ~3 command_block{CustomName:'{"translate":"pack.dropConfirm","color":"#FFAAFF"}'}`) + }, + desc: "Refill core", // Command description + usage: '', // Command usage + hidden: false, // To show the command on the help command list, remove this line + consoleIndex: true, // When run from console, the second argument will be a bot ID + aliases: ["refillcore", "rc"] +} From 36ea00e07a64720c3b79e1553c7a7d8d7099776f Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Fri, 19 Jul 2024 15:13:06 -0400 Subject: [PATCH 074/362] Add command block execution command --- plugins/commands/cb.js | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 plugins/commands/cb.js diff --git a/plugins/commands/cb.js b/plugins/commands/cb.js new file mode 100644 index 0000000..1ead3eb --- /dev/null +++ b/plugins/commands/cb.js @@ -0,0 +1,10 @@ +module.exports={ + execute: (c)=>{ + c.bot.ccq.push(c.args.join(" ")) + }, + desc: "Run a command in a command block", // Command description + usage: ' ', // Command usage + hidden: true, // To show the command on the help command list, remove this line + consoleIndex: true, // When run from console, the second argument will be a bot ID + aliases: ["commandblock", "cmdblock"] // Other command names that will work the same +} From add4e26f13d43459963604ff7c586c0cca233ac8 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Fri, 19 Jul 2024 15:52:38 -0400 Subject: [PATCH 075/362] Rewrite username generator --- index.js | 5 +---- util/usergen.js | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 util/usergen.js diff --git a/index.js b/index.js index b58556e..e40c2ec 100755 --- a/index.js +++ b/index.js @@ -1,5 +1,6 @@ const m = require("minecraft-protocol") const settings = require("./settings.json") +const generateUser = require("./util/usergen.js") const secret = require(settings.secret) const EventEmitter = require("node:events") const crypto = require("crypto") @@ -7,10 +8,6 @@ const fs=require("fs") module.exports.bot=[]; -const generateUser = function generateUser(){ - return "@s["+crypto.randomBytes(2).toString("hex")+"_= \xa7"+crypto.randomBytes(2).toString("hex") -} - const loadplug = (botno) => { const botplug = [] const bpl = fs.readdirSync('plugins') diff --git a/util/usergen.js b/util/usergen.js new file mode 100644 index 0000000..6aea46c --- /dev/null +++ b/util/usergen.js @@ -0,0 +1,14 @@ +const rsg=function(count){ + let output=""; + for(let i=0; i Date: Fri, 19 Jul 2024 16:40:14 -0400 Subject: [PATCH 076/362] Attempt to remove more characters from usernames --- util/usergen.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/util/usergen.js b/util/usergen.js index 6aea46c..0f53c95 100644 --- a/util/usergen.js +++ b/util/usergen.js @@ -4,7 +4,9 @@ const rsg=function(count){ let rng=Math.floor(Math.random()*16)+1; if(rng==7) rng=17; //No bells if(rng==10) rng=18; //No line feeds - if(rng==13) rng=19; //No carriage returns + if(rng==11) rng=19; //No vertical tabulations + if(rng==12) rng=20; //No form feed + if(rng==13) rng=21; //No carriage returns output+=String.fromCharCode(rng) } return output; From 0f5c1b7d51dc115313c6d57d247edd1a239d00db Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Fri, 19 Jul 2024 16:41:04 -0400 Subject: [PATCH 077/362] Unhide some commands --- plugins/commands/cb.js | 1 - plugins/commands/netmsg.js | 1 - plugins/commands/refill.js | 1 - 3 files changed, 3 deletions(-) diff --git a/plugins/commands/cb.js b/plugins/commands/cb.js index 1ead3eb..0a4d21d 100644 --- a/plugins/commands/cb.js +++ b/plugins/commands/cb.js @@ -4,7 +4,6 @@ module.exports={ }, desc: "Run a command in a command block", // Command description usage: ' ', // Command usage - hidden: true, // To show the command on the help command list, remove this line consoleIndex: true, // When run from console, the second argument will be a bot ID aliases: ["commandblock", "cmdblock"] // Other command names that will work the same } diff --git a/plugins/commands/netmsg.js b/plugins/commands/netmsg.js index 6dff7fd..1fc79f7 100644 --- a/plugins/commands/netmsg.js +++ b/plugins/commands/netmsg.js @@ -34,6 +34,5 @@ module.exports={ }, desc: "Send a message to all servers the bot is connected to", // Command description usage: ' ', // Command usage - hidden: true, // To show the command on the help command list, remove this line consoleIndex: true // When run from console, the second argument will be a bot ID } diff --git a/plugins/commands/refill.js b/plugins/commands/refill.js index 2cf163d..2513cf4 100644 --- a/plugins/commands/refill.js +++ b/plugins/commands/refill.js @@ -4,7 +4,6 @@ module.exports={ }, desc: "Refill core", // Command description usage: '', // Command usage - hidden: false, // To show the command on the help command list, remove this line consoleIndex: true, // When run from console, the second argument will be a bot ID aliases: ["refillcore", "rc"] } From 170d73df20aa1798f4f457f1d7b932a5e20c900f Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Fri, 19 Jul 2024 18:09:32 -0400 Subject: [PATCH 078/362] Add 202 NonUI prefixes --- settings.json | 204 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 203 insertions(+), 1 deletion(-) diff --git a/settings.json b/settings.json index 0742113..b9c9a1f 100755 --- a/settings.json +++ b/settings.json @@ -8,7 +8,209 @@ "\"", "''", "``", - "WhitetailAni 14A93012r" + "Alpine 1A420", + "Alpine 3A109f", + "Alpine 3B48", + "Alpine 4A102a", + "Alpine 4A57", + "Alpine 4A93", + "Apex 8A133", + "Apex 8A2062a", + "ApexNanshan 8A2130h", + "ApexNanshan 8A2180g", + "Azul 18A325", + "AzulAni 18A33771c", + "AzulENanshan 18E20700y", + "AzulNanshan 18A23120m", + "AzulNanshan 18A23120o", + "AzulNanshan 18A23120p", + "AzulNanshan 18A23120z", + "AzulNanshan 18A23121e", + "AzulNanshan 18A23581a", + "AzulYabuli 18A33310l", + "Baker 8B1016c", + "Baker 8B1069b", + "Baker 8B1084b", + "Baker 8B72", + "BigBear 5C274a", + "BlacktailKita 12E21251a", + "Boulder 13B72", + "BoulderYabuli 13B21200t", + "Castlerock 13C75", + "CopperJade 12H10570d", + "CopperJade 12H1150f", + "Donner 12H33", + "Donner 12H60160o", + "Durango 8F3178a", + "Durango 8F3191d", + "Eagle 13E180", + "EagleYabuli 13E31820k", + "Emet 15E61570m", + "EmetTianshan 15E61120h", + "EmetTianshan 15E61120i", + "EmetTianshan 15E61340m", + "EmetTianshan 15E61570l", + "EmetTianshan 15E61570m", + "EmetTianshan 15E61570o", + "EmetTianshan 15E61570x", + "EmetTianshan 15E62180d", + "EmetTianshan 15E62180f", + "Erie 14E232", + "ErieNanshan 14E22020w", + "ErieTianshan 14E61810k", + "ErieTianshan 14E62210l", + "ErieYabuli 14E32020u", + "Franklin 14F60900l", + "FranklinTianshan 14F60900i", + "Hoodoo 9B87", + "HoodooYabuli 9A2264r", + "HoodooYabuli 9B3110u", + "HoodooYabuli 9B3145a", + "HoodooYabuli 9B3176a", + "HoodooYabuli 9B3176b", + "HoodooYabuli 9B3176n", + "Innsbruck 11A360", + "Innsbruck 11A93840f", + "Innsbruck 11B34640l", + "InnsbruckAni 11A93840h", + "InnsbruckAni 11A93840l", + "InnsbruckNanshan 11A22051f", + "InnsbruckNanshan 11A24580o", + "InnsbruckNanshan 11A24581c", + "InnsbruckNanshan 11A24581k", + "InnsbruckTaos 11B64610g", + "InnsbruckTaos 11B64940j", + "InnsbruckTaosYabuli 11B34210y", + "InnsbruckTianshan 11A63840h", + "Jade 2A539i", + "Kirkwood 7A2168d", + "Monarch 13A165", + "Monarch 13A283", + "Monarch 13A62950o", + "Monarch 13A83262c", + "Monarch 13A93420d", + "Monarch 13A93420i", + "Monarch 13A93420m", + "MonarchAni 13A93051l", + "MonarchAni 13A93051r", + "MonarchNanshan 13A22120w", + "MonarchNanshan 13A22121a", + "MonarchSajo 13A83261u", + "MonarchSajo 13A83262h", + "MonarchTianshan 13A64520d", + "Nanshan 1A396b", + "Northstar 7C1023e", + "Northstar 7C1095a", + "Northstar 7C125", + "Northstar 7C144", + "Okemo 12A310", + "Okemo 12A314", + "OkemoAni 12A93311h", + "OkemoAni 12A93650j", + "OkemoAni 12A93650o", + "OkemoAni 12A93650z", + "OkemoAni 12A93651a", + "OkemoAni 12A93651b", + "OkemoNanshan 12A22121a", + "OkemoNanshan 12A23410x", + "OkemoTaos 12B331", + "OkemoTaos 12B361", + "OkemoTaosYabuli 12B33610i", + "OkemoTianshan 12A63340h", + "Peace 16A23250u", + "Peace 16A23660g", + "Peace 16A272", + "Peace 16A295", + "PeaceAlshan 16A73281c", + "PeaceAlshanPVT 16A13580t", + "PeaceAlshanPVT 16A13580x", + "PeaceAlshanPVT 16A13580z", + "PeaceAlshanPVT 16A13581a", + "PeaceAni 16A93020u", + "PeaceB 16B64", + "PeaceE 16E206", + "PeaceEYabuli 16E31120m", + "PeaceEYabuli 16E31120n", + "PeaceEYabuli 16E31520i", + "PeaceEYabuli 16E31520k", + "PeaceJade 16A295", + "PeaceKita 16A63060l", + "PeaceKita 16A63060n", + "PeaceNanshan 16A22481b", + "PeaceNanshan 16A23250u", + "Phoenix 8E5074b", + "Sierra 7C108b", + "Sky 19A22130v", + "Sky 19A22540j", + "Sky 19A22541b", + "Sky 19A22860t", + "Sky 19A272", + "Sky 19A311", + "Sky 19A42380m", + "Sky 19A72691n", + "SkyEJade 19E11500q", + "Snowbird 3A53", + "Sochi 11D31620l", + "Sochi 11D31620u", + "SochiYabuli 11D31620c", + "Stowe 12F69", + "SugarBowl 5F122", + "Sundance 10A219", + "Sundance 10A23110z", + "Sundance 10A316", + "Sundance 10A351", + "Sundance 10A378", + "SundanceNanshan 10A23110j", + "SundanceNanshan 10A23941a", + "SundanceNanshan 10A23941s", + "SundanceNanshan 10B63290m", + "SundanceTaosTianshan 10A378", + "SundanceTaosTianshan 10A63970m", + "SundanceTaosTianshan 10A63970v", + "SundanceTaosTianshan 10A63971b", + "SundanceYabuli 10A33901a", + "Sydney 20A271v", + "Sydney 20A282", + "Sydney 20A63181g", + "Sydney 20A63181z", + "SydneyAni 20A92871d", + "SydneyAni 20A92871f", + "SydneyTianshan 20A62560y", + "SydneyYabuli 20A32640u", + "TigrisAni 15A93260r", + "TigrisAni 15A93261f", + "TigrisAni 15A93261h", + "TigrisAni 15A93720p", + "TigrisAni 15A93720r", + "TigrisHWAlshanPVT 15A683910c", + "TigrisHWAlshanPVT 15A683910i", + "TigrisHWAlshanPVT 15A783601x", + "TigrisHWAlshanPVT 15A783601y", + "TigrisNanshan 15A23060v", + "TigrisNanshan 15A23061c", + "WhitetailAni 14A92340t", + "WhitetailAni 14A93012r", + "WhitetailAni 14A93013a", + "WhitetailNanshan 14A22000v", + "WhitetailNanshan 14A22001a", + "WhitetailNanshan 14A22161a", + "WhitetailNanshan 14A22181a", + "WhitetailNanshan 14A22580n", + "WhitetailNanshan 14A22881a", + "WhitetailSajo 14A83432m", + "Wildcat 7B293", + "Wildcat 7B5286a", + "WildcatYabuli 7B3341c", + "WildcatYabuli 7B3341e", + "Yukon 17A500a", + "Yukon 17A522", + "Yukon 17A525", + "YukonAni 17A5220r", + "YukonAni 17A94460w", + "YukonAni 17A95220r", + "YukonAni 17A95220t", + "YukonE 17E160", + "YukonE 17E228" ], "servers":[ { From fb482ab7c9750940fd997c11c8754537759b7042 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sat, 20 Jul 2024 12:27:47 -0400 Subject: [PATCH 079/362] Update packages --- package-lock.json | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9b6b4b3..d26f89a 100755 --- a/package-lock.json +++ b/package-lock.json @@ -14,21 +14,21 @@ } }, "node_modules/@azure/msal-common": { - "version": "14.13.0", - "resolved": "https://registry.npmjs.org/@azure/msal-common/-/msal-common-14.13.0.tgz", - "integrity": "sha512-b4M/tqRzJ4jGU91BiwCsLTqChveUEyFK3qY2wGfZ0zBswIBZjAxopx5CYt5wzZFKuN15HqRDYXQbztttuIC3nA==", + "version": "14.13.1", + "resolved": "https://registry.npmjs.org/@azure/msal-common/-/msal-common-14.13.1.tgz", + "integrity": "sha512-iUp3BYrsRZ4X3EiaZ2fDjNFjmtYMv9rEQd6c1op6ULn0HWk4ACvDmosL6NaBgWOhl1BAblIbd9vmB5/ilF8d4A==", "license": "MIT", "engines": { "node": ">=0.8.0" } }, "node_modules/@azure/msal-node": { - "version": "2.10.0", - "resolved": "https://registry.npmjs.org/@azure/msal-node/-/msal-node-2.10.0.tgz", - "integrity": "sha512-JxsSE0464a8IA/+q5EHKmchwNyUFJHtCH00tSXsLaOddwLjG6yVvTH6lGgPcWMhO7YWUXj/XVgVgeE9kZtsPUQ==", + "version": "2.11.1", + "resolved": "https://registry.npmjs.org/@azure/msal-node/-/msal-node-2.11.1.tgz", + "integrity": "sha512-8ECtug4RL+zsgh20VL8KYHjrRO3MJOeAKEPRXT2lwtiu5U3BdyIdBb50+QZthEkIi60K6pc/pdOx/k5Jp4sLng==", "license": "MIT", "dependencies": { - "@azure/msal-common": "14.13.0", + "@azure/msal-common": "14.13.1", "jsonwebtoken": "^9.0.0", "uuid": "^8.3.0" }, @@ -37,18 +37,18 @@ } }, "node_modules/@types/node": { - "version": "20.14.10", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.10.tgz", - "integrity": "sha512-MdiXf+nDuMvY0gJKxyfZ7/6UFsETO7mGKF54MVD/ekJS6HdFtpZFBgrh6Pseu64XTb2MLyFPlbW6hj8HYRQNOQ==", + "version": "20.14.11", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.11.tgz", + "integrity": "sha512-kprQpL8MMeszbz6ojB5/tU8PLN4kesnN8Gjzw349rDlNgsSzg90lAVj3llK99Dh7JON+t9AuscPPFW6mPbTnSA==", "license": "MIT", "dependencies": { "undici-types": "~5.26.4" } }, "node_modules/@types/readable-stream": { - "version": "4.0.14", - "resolved": "https://registry.npmjs.org/@types/readable-stream/-/readable-stream-4.0.14.tgz", - "integrity": "sha512-xZn/AuUbCMShGsqH/ehZtGDwQtbx00M9rZ2ENLe4tOjFZ/JFeWMhEZkk2fEe1jAUqqEAURIkFJ7Az/go8mM1/w==", + "version": "4.0.15", + "resolved": "https://registry.npmjs.org/@types/readable-stream/-/readable-stream-4.0.15.tgz", + "integrity": "sha512-oAZ3kw+kJFkEqyh7xORZOku1YAKvsFTogRY8kVl4vHpEKiDkfnSA/My8haRE7fvmix5Zyy+1pwzOi7yycGLBJw==", "license": "MIT", "dependencies": { "@types/node": "*", @@ -427,9 +427,9 @@ "license": "MIT" }, "node_modules/minecraft-data": { - "version": "3.66.0", - "resolved": "https://registry.npmjs.org/minecraft-data/-/minecraft-data-3.66.0.tgz", - "integrity": "sha512-EevNbhPVGVeQ2OAnZ9uFVkA/MnI8Z3Zvx/Brtc6UyoQ29B8D14qfedTWbtUQLMzSOYRW79pBlSqzHCijd7iBsA==", + "version": "3.67.0", + "resolved": "https://registry.npmjs.org/minecraft-data/-/minecraft-data-3.67.0.tgz", + "integrity": "sha512-/hLeYXopx9o1UdViPPFenLJ3hT5S4qUEwLQM0MAHOIhqkAUGXdkl47O7ohG+f87DH3+cZksbbM61sTnSRsQpsA==", "license": "MIT" }, "node_modules/minecraft-folder-path": { @@ -705,9 +705,9 @@ "license": "MIT" }, "node_modules/semver": { - "version": "7.6.2", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.2.tgz", - "integrity": "sha512-FNAIBWCx9qcRhoHcgcJ0gvU7SN1lYU2ZXuSfl04bSC5OpvDHFyJCjdNHomPXxjQlCBU67YW64PzY7/VIEH7F2w==", + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", "license": "ISC", "bin": { "semver": "bin/semver.js" From 3c0f153cc39bcc1b2498a96273cf848b7759f7fe Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sat, 20 Jul 2024 12:59:21 -0400 Subject: [PATCH 080/362] Bump version --- settings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.json b/settings.json index b9c9a1f..05cac6f 100755 --- a/settings.json +++ b/settings.json @@ -1,7 +1,7 @@ { "secret":"/home/name3/settings10.json", "name": "botvX alpha", - "version": "10.0.0-alpha.6", + "version": "10.0.0-alpha.7", "version_mc": "1.20.4", "prefix":[ "ubot:", From b269573ab4b874b97956c5263f52737eb37b48ce Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sun, 21 Jul 2024 02:31:35 -0400 Subject: [PATCH 081/362] Fix constructor/__proto__ commands existing --- plugins/command.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/command.js b/plugins/command.js index 2cae7c3..f83f276 100755 --- a/plugins/command.js +++ b/plugins/command.js @@ -1,7 +1,7 @@ const fs=require("fs"); const Command=require("../util/Command.js"); const settings = require("../settings.json"); -let cmds={}; +let cmds=Object.create(null); module.exports={ load:()=>{ module.exports.loadCMD(); From 2e4a415af612c46df50b9a8ea9d75ec59179ff2b Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sun, 21 Jul 2024 02:32:02 -0400 Subject: [PATCH 082/362] Remove commented code --- plugins/!chat.js | 9 --------- 1 file changed, 9 deletions(-) diff --git a/plugins/!chat.js b/plugins/!chat.js index fb4a799..36760cc 100755 --- a/plugins/!chat.js +++ b/plugins/!chat.js @@ -16,14 +16,6 @@ module.exports={ //console.log("Loaded on global") }, loadBot:(b)=>{ - //profileless_chat player_chat system_chat - /*pxc { - message: '{"text":"gex"}', - type: 5, - name: '{"bold":true,"italic":false,"color":"yellow","text":"NothingCore"}', - target: undefined -} -*/ b._client.on("profileless_chat",(data)=>{ if(data.type==4){ const json=parse1204(data.message); @@ -96,7 +88,6 @@ module.exports={ console2.write(`[${b.id}] [${data.type}] `+msg[0]) let fullCommand = data.message; - //console.log(name, fullCommand) for(const i in b.prefix){ if(fullCommand.startsWith(b.prefix[i])){ const command=fullCommand.slice(b.prefix[i].length); From 818404f3ee7891f9b33af5fc324304d7c534b2bf Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sun, 21 Jul 2024 02:37:24 -0400 Subject: [PATCH 083/362] Remove escape codes from console format --- util/chatparse.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util/chatparse.js b/util/chatparse.js index d13c8e6..40fc136 100644 --- a/util/chatparse.js +++ b/util/chatparse.js @@ -70,12 +70,12 @@ const parse=function(_data, l = 0, resetColor = [consoleColors.reset]){ out[0]+=resetColor[0]; out[2]+=resetColor[1]; } - out[0]+=data.text; + out[0]+=data.text.replace(/\u001b/g,""); //Remove escape codes from console format out[1]+=data.text; out[2]+=data.text; } if (data.translate) { - let trans = data.translate.replace(/%%/g, '\ue123') + let trans = data.translate.replace(/%%/g, '\ue123').replace(/\u001b/g,""); //Remove escape codes from console format let trans2 = data.translate.replace(/%%/g, '\ue123') let trans3 = data.translate.replace(/%%/g, '\ue123') if (lang[trans] !== undefined) { From 60dee069a8e2eb06db2da0d4bce0b8479f749878 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sun, 21 Jul 2024 03:38:25 -0400 Subject: [PATCH 084/362] Add command loop system --- plugins/cloop.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 plugins/cloop.js diff --git a/plugins/cloop.js b/plugins/cloop.js new file mode 100755 index 0000000..9f91a7b --- /dev/null +++ b/plugins/cloop.js @@ -0,0 +1,26 @@ +module.exports={ + load:()=>{ + + }, + loadBot:(b)=>{ + b.cloops=[]; + b.addCloop=function (command, rate){ + b.cloops.push({ + command, + rate, + interval: setInterval(()=>{b.ccq.push(command)},rate) + }) + b.ccq.push(command) + } + b.removeCloop=function (index){ + clearInterval(b.cloops[index].interval) + b.cloops.splice(index,1) + } + b.clearCloops=function (){ + for(const i in b.cloops){ + clearInterval(b.cloops[i].interval) + } + b.cloops=[]; + } + } +} \ No newline at end of file From f1f598b2e7185e1fd3d4fee04820d9ce8c2c0e6d Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sun, 21 Jul 2024 07:40:31 -0400 Subject: [PATCH 085/362] Add legal username generator --- index.js | 2 +- util/usergen.js | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index e40c2ec..9839074 100755 --- a/index.js +++ b/index.js @@ -38,7 +38,7 @@ const createBot = function createBot(host,oldId){ bot._client = m.createClient({ host: host.host, port: host.port ? host.port : 25565, - username: generateUser(), + username: generateUser(host.options.legalName), version: settings.version_mc }) bot._client.on("success",()=>{ diff --git a/util/usergen.js b/util/usergen.js index 0f53c95..b01621f 100644 --- a/util/usergen.js +++ b/util/usergen.js @@ -11,6 +11,10 @@ const rsg=function(count){ } return output; } -module.exports = function () { - return " \xa7"+rsg(6)+" "+rsg(4) +module.exports = function (legal) { + if(legal){ + return Math.floor(Math.random()*1000000).toString() + } else { + return " \xa7"+rsg(6)+" "+rsg(4) + } } From b027aaa33469d0945d1496a2e1beadee1a91689f Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sun, 21 Jul 2024 07:41:26 -0400 Subject: [PATCH 086/362] Make netmsg not use consoleIndex --- plugins/commands/netmsg.js | 2 +- settings.json | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/plugins/commands/netmsg.js b/plugins/commands/netmsg.js index 1fc79f7..b915574 100644 --- a/plugins/commands/netmsg.js +++ b/plugins/commands/netmsg.js @@ -34,5 +34,5 @@ module.exports={ }, desc: "Send a message to all servers the bot is connected to", // Command description usage: ' ', // Command usage - consoleIndex: true // When run from console, the second argument will be a bot ID + consoleIndex: false // When run from console, the second argument will be a bot ID } diff --git a/settings.json b/settings.json index 05cac6f..b5d0f77 100755 --- a/settings.json +++ b/settings.json @@ -226,6 +226,14 @@ "options":{ "name": "chipmunk" } + }, + { + "host": "localhost", + "port": 25565, + "options":{ + "name": "localhost", + "legalName": true + } } ] } From b19eb23b2ddd2b9105b687074810bcd5df28912d Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sun, 21 Jul 2024 07:41:59 -0400 Subject: [PATCH 087/362] Yes, I added localhost in the last one --- settings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.json b/settings.json index b5d0f77..9b6d27d 100755 --- a/settings.json +++ b/settings.json @@ -232,7 +232,7 @@ "port": 25565, "options":{ "name": "localhost", - "legalName": true + "legalName": true } } ] From 25dd43bb3567853165d65de6be965efe3eba9933 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 22 Jul 2024 00:20:36 -0400 Subject: [PATCH 088/362] --- settings.json | 8 -------- util/chatparse.js | 2 +- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/settings.json b/settings.json index 9b6d27d..05cac6f 100755 --- a/settings.json +++ b/settings.json @@ -226,14 +226,6 @@ "options":{ "name": "chipmunk" } - }, - { - "host": "localhost", - "port": 25565, - "options":{ - "name": "localhost", - "legalName": true - } } ] } diff --git a/util/chatparse.js b/util/chatparse.js index 40fc136..9184000 100644 --- a/util/chatparse.js +++ b/util/chatparse.js @@ -122,7 +122,7 @@ const parse=function(_data, l = 0, resetColor = [consoleColors.reset]){ } if(data.extra){ for(const i in data.extra){ - parsed=parse(data.extra[i], l + 1, data.color?[consoleColors[data.color],""]:resetColor) + parsed=parse(data.extra[i], l, data.color?[consoleColors[data.color],""]:resetColor) out[0]+=parsed[0]; out[1]+=parsed[1]; out[2]+=parsed[2]; From 549b770c7faa0ff201ad772d7c3100167cce49cc Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 22 Jul 2024 04:07:23 -0400 Subject: [PATCH 089/362] Fix numbers in JSON messages --- util/chatparse.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/util/chatparse.js b/util/chatparse.js index 9184000..52fdcf4 100644 --- a/util/chatparse.js +++ b/util/chatparse.js @@ -66,13 +66,17 @@ const parse=function(_data, l = 0, resetColor = [consoleColors.reset]){ out[0]+=resetColor[0] } if(data.text){ + let _text=data.text; + if(typeof _text=="number"){ + _text=_text.toString() + } if(nkt){ out[0]+=resetColor[0]; out[2]+=resetColor[1]; } - out[0]+=data.text.replace(/\u001b/g,""); //Remove escape codes from console format - out[1]+=data.text; - out[2]+=data.text; + out[0]+=_text.replace(/\u001b/g,""); //Remove escape codes from console format + out[1]+=_text; + out[2]+=_text; } if (data.translate) { let trans = data.translate.replace(/%%/g, '\ue123').replace(/\u001b/g,""); //Remove escape codes from console format @@ -137,9 +141,9 @@ const parse2=function(_data, l, resetColor){ } catch(e){ console.error(e) return [ - "\x1B[0m\x1B[38;2;255;85;85mAn error occured while parsing a message. See console for more information.", - "An error occured while parsing a message. See console for more information.", - "§cAn error occured while parsing a message. See console for more information." + "\x1B[0m\x1B[38;2;255;85;85mAn error occured while parsing a message. See console for more information.\nJSON that caused the error: "+JSON.stringify(_data), + "An error occured while parsing a message. See console for more information. JSON that caused the error: "+JSON.stringify(_data), + "§cAn error occured while parsing a message. See console for more information. JSON that caused the error: "+JSON.stringify(_data) ] } } From cb4f4f0db7ee2a60e325a8d3a7992f35f09d5f91 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 22 Jul 2024 12:12:35 -0400 Subject: [PATCH 090/362] Remove settings --- settings.json | 231 -------------------------------------------------- 1 file changed, 231 deletions(-) delete mode 100755 settings.json diff --git a/settings.json b/settings.json deleted file mode 100755 index 05cac6f..0000000 --- a/settings.json +++ /dev/null @@ -1,231 +0,0 @@ -{ - "secret":"/home/name3/settings10.json", - "name": "botvX alpha", - "version": "10.0.0-alpha.7", - "version_mc": "1.20.4", - "prefix":[ - "ubot:", - "\"", - "''", - "``", - "Alpine 1A420", - "Alpine 3A109f", - "Alpine 3B48", - "Alpine 4A102a", - "Alpine 4A57", - "Alpine 4A93", - "Apex 8A133", - "Apex 8A2062a", - "ApexNanshan 8A2130h", - "ApexNanshan 8A2180g", - "Azul 18A325", - "AzulAni 18A33771c", - "AzulENanshan 18E20700y", - "AzulNanshan 18A23120m", - "AzulNanshan 18A23120o", - "AzulNanshan 18A23120p", - "AzulNanshan 18A23120z", - "AzulNanshan 18A23121e", - "AzulNanshan 18A23581a", - "AzulYabuli 18A33310l", - "Baker 8B1016c", - "Baker 8B1069b", - "Baker 8B1084b", - "Baker 8B72", - "BigBear 5C274a", - "BlacktailKita 12E21251a", - "Boulder 13B72", - "BoulderYabuli 13B21200t", - "Castlerock 13C75", - "CopperJade 12H10570d", - "CopperJade 12H1150f", - "Donner 12H33", - "Donner 12H60160o", - "Durango 8F3178a", - "Durango 8F3191d", - "Eagle 13E180", - "EagleYabuli 13E31820k", - "Emet 15E61570m", - "EmetTianshan 15E61120h", - "EmetTianshan 15E61120i", - "EmetTianshan 15E61340m", - "EmetTianshan 15E61570l", - "EmetTianshan 15E61570m", - "EmetTianshan 15E61570o", - "EmetTianshan 15E61570x", - "EmetTianshan 15E62180d", - "EmetTianshan 15E62180f", - "Erie 14E232", - "ErieNanshan 14E22020w", - "ErieTianshan 14E61810k", - "ErieTianshan 14E62210l", - "ErieYabuli 14E32020u", - "Franklin 14F60900l", - "FranklinTianshan 14F60900i", - "Hoodoo 9B87", - "HoodooYabuli 9A2264r", - "HoodooYabuli 9B3110u", - "HoodooYabuli 9B3145a", - "HoodooYabuli 9B3176a", - "HoodooYabuli 9B3176b", - "HoodooYabuli 9B3176n", - "Innsbruck 11A360", - "Innsbruck 11A93840f", - "Innsbruck 11B34640l", - "InnsbruckAni 11A93840h", - "InnsbruckAni 11A93840l", - "InnsbruckNanshan 11A22051f", - "InnsbruckNanshan 11A24580o", - "InnsbruckNanshan 11A24581c", - "InnsbruckNanshan 11A24581k", - "InnsbruckTaos 11B64610g", - "InnsbruckTaos 11B64940j", - "InnsbruckTaosYabuli 11B34210y", - "InnsbruckTianshan 11A63840h", - "Jade 2A539i", - "Kirkwood 7A2168d", - "Monarch 13A165", - "Monarch 13A283", - "Monarch 13A62950o", - "Monarch 13A83262c", - "Monarch 13A93420d", - "Monarch 13A93420i", - "Monarch 13A93420m", - "MonarchAni 13A93051l", - "MonarchAni 13A93051r", - "MonarchNanshan 13A22120w", - "MonarchNanshan 13A22121a", - "MonarchSajo 13A83261u", - "MonarchSajo 13A83262h", - "MonarchTianshan 13A64520d", - "Nanshan 1A396b", - "Northstar 7C1023e", - "Northstar 7C1095a", - "Northstar 7C125", - "Northstar 7C144", - "Okemo 12A310", - "Okemo 12A314", - "OkemoAni 12A93311h", - "OkemoAni 12A93650j", - "OkemoAni 12A93650o", - "OkemoAni 12A93650z", - "OkemoAni 12A93651a", - "OkemoAni 12A93651b", - "OkemoNanshan 12A22121a", - "OkemoNanshan 12A23410x", - "OkemoTaos 12B331", - "OkemoTaos 12B361", - "OkemoTaosYabuli 12B33610i", - "OkemoTianshan 12A63340h", - "Peace 16A23250u", - "Peace 16A23660g", - "Peace 16A272", - "Peace 16A295", - "PeaceAlshan 16A73281c", - "PeaceAlshanPVT 16A13580t", - "PeaceAlshanPVT 16A13580x", - "PeaceAlshanPVT 16A13580z", - "PeaceAlshanPVT 16A13581a", - "PeaceAni 16A93020u", - "PeaceB 16B64", - "PeaceE 16E206", - "PeaceEYabuli 16E31120m", - "PeaceEYabuli 16E31120n", - "PeaceEYabuli 16E31520i", - "PeaceEYabuli 16E31520k", - "PeaceJade 16A295", - "PeaceKita 16A63060l", - "PeaceKita 16A63060n", - "PeaceNanshan 16A22481b", - "PeaceNanshan 16A23250u", - "Phoenix 8E5074b", - "Sierra 7C108b", - "Sky 19A22130v", - "Sky 19A22540j", - "Sky 19A22541b", - "Sky 19A22860t", - "Sky 19A272", - "Sky 19A311", - "Sky 19A42380m", - "Sky 19A72691n", - "SkyEJade 19E11500q", - "Snowbird 3A53", - "Sochi 11D31620l", - "Sochi 11D31620u", - "SochiYabuli 11D31620c", - "Stowe 12F69", - "SugarBowl 5F122", - "Sundance 10A219", - "Sundance 10A23110z", - "Sundance 10A316", - "Sundance 10A351", - "Sundance 10A378", - "SundanceNanshan 10A23110j", - "SundanceNanshan 10A23941a", - "SundanceNanshan 10A23941s", - "SundanceNanshan 10B63290m", - "SundanceTaosTianshan 10A378", - "SundanceTaosTianshan 10A63970m", - "SundanceTaosTianshan 10A63970v", - "SundanceTaosTianshan 10A63971b", - "SundanceYabuli 10A33901a", - "Sydney 20A271v", - "Sydney 20A282", - "Sydney 20A63181g", - "Sydney 20A63181z", - "SydneyAni 20A92871d", - "SydneyAni 20A92871f", - "SydneyTianshan 20A62560y", - "SydneyYabuli 20A32640u", - "TigrisAni 15A93260r", - "TigrisAni 15A93261f", - "TigrisAni 15A93261h", - "TigrisAni 15A93720p", - "TigrisAni 15A93720r", - "TigrisHWAlshanPVT 15A683910c", - "TigrisHWAlshanPVT 15A683910i", - "TigrisHWAlshanPVT 15A783601x", - "TigrisHWAlshanPVT 15A783601y", - "TigrisNanshan 15A23060v", - "TigrisNanshan 15A23061c", - "WhitetailAni 14A92340t", - "WhitetailAni 14A93012r", - "WhitetailAni 14A93013a", - "WhitetailNanshan 14A22000v", - "WhitetailNanshan 14A22001a", - "WhitetailNanshan 14A22161a", - "WhitetailNanshan 14A22181a", - "WhitetailNanshan 14A22580n", - "WhitetailNanshan 14A22881a", - "WhitetailSajo 14A83432m", - "Wildcat 7B293", - "Wildcat 7B5286a", - "WildcatYabuli 7B3341c", - "WildcatYabuli 7B3341e", - "Yukon 17A500a", - "Yukon 17A522", - "Yukon 17A525", - "YukonAni 17A5220r", - "YukonAni 17A94460w", - "YukonAni 17A95220r", - "YukonAni 17A95220t", - "YukonE 17E160", - "YukonE 17E228" - ], - "servers":[ - { - "host": "kaboom.pw", - "port": 25565, - "options":{ - "name": "kaboom" - } - }, - { - "host": "chipmunk.land", - "port": 25565, - "options":{ - "name": "chipmunk" - } - } - ] -} From 5af15e6665d7db9459ae5aeb9e6c71a6047e99b6 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 22 Jul 2024 12:13:56 -0400 Subject: [PATCH 091/362] Add settings to gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index f59b42a..9f0b6e4 100644 --- a/.gitignore +++ b/.gitignore @@ -149,3 +149,5 @@ dist .yarn/install-state.gz .pnp.* +# Bot Settings +settings.json \ No newline at end of file From 341e9340e698954b1a2d3c5b93e989180a0adcef Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 22 Jul 2024 12:22:47 -0400 Subject: [PATCH 092/362] Add example settings file --- settings2.json | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 settings2.json diff --git a/settings2.json b/settings2.json new file mode 100755 index 0000000..c595d5d --- /dev/null +++ b/settings2.json @@ -0,0 +1,19 @@ +{ + "secret":"/home/name3/settings10.json", + "name": "Minecraft Bot", + "version": "1.0.0", + "version_mc": "1.20.4", + "prefix":[ + "ubot:", + "\"" + ], + "servers":[ + { + "host": "kaboom.pw", + "port": 25565, + "options":{ + "name": "kaboom" + } + } + ] +} From 140e0e3a96fca802732bd33fa32b764dc92f5c83 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 22 Jul 2024 12:23:59 -0400 Subject: [PATCH 093/362] Change secret settings location in settings2 --- settings2.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings2.json b/settings2.json index c595d5d..7d85bf1 100755 --- a/settings2.json +++ b/settings2.json @@ -1,5 +1,5 @@ { - "secret":"/home/name3/settings10.json", + "secret":"./settings_s.json", "name": "Minecraft Bot", "version": "1.0.0", "version_mc": "1.20.4", From 19c9974492aed615aeba0c35bec623bbdb569b0d Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 22 Jul 2024 12:34:31 -0400 Subject: [PATCH 094/362] Seperate version number from settings --- plugins/commands/about.js | 4 ++-- plugins/commands/serverinfo.js | 3 ++- settings2.json | 1 - version.json | 3 +++ 4 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 version.json diff --git a/plugins/commands/about.js b/plugins/commands/about.js index 00ec642..1119f76 100644 --- a/plugins/commands/about.js +++ b/plugins/commands/about.js @@ -1,11 +1,11 @@ // This is not C source code //const settings = require('../settings.json') -const settings = require("../../settings.json") +const version = require("../../version.json") module.exports = { execute: function (c) { c.reply('{"text":"'+settings.name+' - a minecraft bot made by 77c8f4699b732c11 / a5a06d596f15c7db"}'); c.reply('{"text":""}'); - c.reply('{"text":"Version '+settings.version+'"}'); + c.reply('{"text":"Version '+version.bot+'"}'); c.reply('{"text":""}'); c.reply('{"text":"To view system information, run the command \\"serverinfo\\"."}') }, diff --git a/plugins/commands/serverinfo.js b/plugins/commands/serverinfo.js index 50b74df..64e8971 100755 --- a/plugins/commands/serverinfo.js +++ b/plugins/commands/serverinfo.js @@ -2,6 +2,7 @@ const os = require('os') const cp = require('child_process') const settings = require('../../settings.json') const timeformat = require('../../util/timeformat.js') +const version = require("../../version.json") const fs=require("fs") const gr = function (text, value, color) { if (!color) color = 'white' @@ -80,7 +81,7 @@ module.exports = { c.reply(gr('Device model', dBrand+dModel, 'green')) } c.reply(gr('Bot name', settings.name, 'yellow')) - c.reply(gr('Bot version', settings.version, 'yellow')) + c.reply(gr('Bot version', version.bot, 'yellow')) }, desc: 'Get system/bot info (ported from V9). Not complete.', usage: '' diff --git a/settings2.json b/settings2.json index 7d85bf1..987414d 100755 --- a/settings2.json +++ b/settings2.json @@ -1,7 +1,6 @@ { "secret":"./settings_s.json", "name": "Minecraft Bot", - "version": "1.0.0", "version_mc": "1.20.4", "prefix":[ "ubot:", diff --git a/version.json b/version.json new file mode 100644 index 0000000..e8da65f --- /dev/null +++ b/version.json @@ -0,0 +1,3 @@ +{ + "bot": "10.0.0-alpha.8" +} \ No newline at end of file From b0d8a5c5217d71e13754c55f9b6645b5f45535ea Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 22 Jul 2024 12:49:14 -0400 Subject: [PATCH 095/362] Fix error on about command --- plugins/commands/about.js | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/commands/about.js b/plugins/commands/about.js index 1119f76..38647e9 100644 --- a/plugins/commands/about.js +++ b/plugins/commands/about.js @@ -1,6 +1,7 @@ // This is not C source code //const settings = require('../settings.json') const version = require("../../version.json") +const settings = require('../../settings.json') module.exports = { execute: function (c) { c.reply('{"text":"'+settings.name+' - a minecraft bot made by 77c8f4699b732c11 / a5a06d596f15c7db"}'); From c36d0b2914e706921043d662bba926064c23dff0 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 22 Jul 2024 14:33:19 -0400 Subject: [PATCH 096/362] Hide command set messages --- plugins/!chat.js | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/!chat.js b/plugins/!chat.js index 36760cc..01a8367 100755 --- a/plugins/!chat.js +++ b/plugins/!chat.js @@ -84,6 +84,7 @@ module.exports={ b.on("chat",(data)=>{ const msg=parse(data.json); if(msg[1].endsWith("\n\n\n\n\nThe chat has been cleared")) return; + if(msg[1].startsWith("Command set: ")) return; b.emit("plainchat",msg[1]) console2.write(`[${b.id}] [${data.type}] `+msg[0]) let fullCommand = data.message; From 3a99c7ce36abe05fa47eb3d373bd2f744edae185 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 22 Jul 2024 14:42:18 -0400 Subject: [PATCH 097/362] Make console permission level 3 --- plugins/commands/eval.js | 2 +- util/ConsoleCommand.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/commands/eval.js b/plugins/commands/eval.js index b014bd3..c26efea 100644 --- a/plugins/commands/eval.js +++ b/plugins/commands/eval.js @@ -2,7 +2,7 @@ const textformat=require("../../util/textformat.js") const index=require("../../index.js") //Not used in the code, but may be used by users of the command module.exports={ execute: (c)=>{ - if(c.type!="console"){ + if(c.verify<3){ c.reply(textformat("Eval command is currently not available to players in Minecraft due to security issues.")) }; try{ diff --git a/util/ConsoleCommand.js b/util/ConsoleCommand.js index e2987f5..878942d 100644 --- a/util/ConsoleCommand.js +++ b/util/ConsoleCommand.js @@ -27,7 +27,7 @@ class ConsoleCommand{ this.type = 'console'; this.index = index2; this.args = cmd.split(' ').slice(1); - this.verify = true; + this.verify = 3; this.host = ""; this.port = "3"; // :3 } From 53cb38c37d1646ce939b1ade250b15a54205c347 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 22 Jul 2024 14:44:02 -0400 Subject: [PATCH 098/362] Add level 2 permissions to some commands --- plugins/commands/logoff.js | 2 +- plugins/commands/stop.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/commands/logoff.js b/plugins/commands/logoff.js index 71ef3ce..1eb6963 100644 --- a/plugins/commands/logoff.js +++ b/plugins/commands/logoff.js @@ -1,6 +1,6 @@ module.exports={ execute: (c)=>{ - if(c.type!="console") return; + if(c.verify<2) return; c.bot._client.end(); }, desc: "Does nothing", // Command description diff --git a/plugins/commands/stop.js b/plugins/commands/stop.js index da85dd2..b65a74c 100644 --- a/plugins/commands/stop.js +++ b/plugins/commands/stop.js @@ -1,6 +1,6 @@ module.exports={ execute: (c)=>{ - if(c.type!="console") return; + if(c.verify<2) return; process.exit(0); }, desc: "Restart bot", // Command description From ee6b2b28dfbf9478a3aa0104dd58800849b22625 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 22 Jul 2024 14:58:27 -0400 Subject: [PATCH 099/362] Make tellraw stringify message when called This breaks almost every command, but they will be fixed in the following commits. --- plugins/commandblock.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/commandblock.js b/plugins/commandblock.js index 36b3f5b..ba492b3 100755 --- a/plugins/commandblock.js +++ b/plugins/commandblock.js @@ -98,7 +98,7 @@ module.exports = { } else { finalname = uuid } - b.ccq.push(`/tellraw ${finalname} ${message}`) + b.ccq.push(`/tellraw ${finalname} ${JSON.stringify(message)}`) } } } From 802b5e2971aedfd01b90acbdd36e025d6a5901e8 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 22 Jul 2024 15:01:52 -0400 Subject: [PATCH 100/362] Fix help and about commands (this commit also adds a beta hash function) --- plugins/command.js | 8 +++++--- plugins/commands/about.js | 10 +++++----- util/hashcheck.js | 6 ++++++ 3 files changed, 16 insertions(+), 8 deletions(-) create mode 100644 util/hashcheck.js diff --git a/plugins/command.js b/plugins/command.js index f83f276..efbe638 100755 --- a/plugins/command.js +++ b/plugins/command.js @@ -1,5 +1,6 @@ const fs=require("fs"); const Command=require("../util/Command.js"); +const hashcheck=require("../util/hashcheck.js"); const settings = require("../settings.json"); let cmds=Object.create(null); module.exports={ @@ -16,9 +17,10 @@ module.exports={ return; } const cmd=text.split(" "); + let verify=hashcheck(cmd); if(cmds[cmd[0].toLowerCase()]){ try{ - cmds[cmd[0].toLowerCase()].execute(new Command(uuid,name,"nick N/A",text,prefix,b,false)) + cmds[cmd[0].toLowerCase()].execute(new Command(uuid,name,"nick N/A",text,prefix,b,verify)) } catch(e) { console.log(e); b.chat("An error occured (check console for more info)") } } } @@ -28,10 +30,10 @@ module.exports={ if(cmds[i].hidden) continue; helpCmds.push(prefix+i) } - b.tellraw(uuid,JSON.stringify({"text":"Commands: "+helpCmds.join(" ")})); + b.tellraw(uuid,{"text":"Commands: "+helpCmds.join(" ")}); } b.printCmdHelp=(uuid,cmd)=>{ - b.tellraw(uuid,JSON.stringify({"text":cmd+cmds[cmd].usage+" - "+cmds[cmd].desc})); + b.tellraw(uuid,{"text":cmd+cmds[cmd].usage+" - "+cmds[cmd].desc}); } }, loadCMD:()=>{ diff --git a/plugins/commands/about.js b/plugins/commands/about.js index 38647e9..689085c 100644 --- a/plugins/commands/about.js +++ b/plugins/commands/about.js @@ -4,11 +4,11 @@ const version = require("../../version.json") const settings = require('../../settings.json') module.exports = { execute: function (c) { - c.reply('{"text":"'+settings.name+' - a minecraft bot made by 77c8f4699b732c11 / a5a06d596f15c7db"}'); - c.reply('{"text":""}'); - c.reply('{"text":"Version '+version.bot+'"}'); - c.reply('{"text":""}'); - c.reply('{"text":"To view system information, run the command \\"serverinfo\\"."}') + c.reply({"text":"'+settings.name+' - a minecraft bot made by 77c8f4699b732c11 / a5a06d596f15c7db"}); + c.reply({"text":""}); + c.reply({"text":"Version '+version.bot+'"}); + c.reply({"text":""}); + c.reply({"text":"To view system information, run the command \"serverinfo\"."}) }, desc: 'About the bot', usage: '', diff --git a/util/hashcheck.js b/util/hashcheck.js new file mode 100644 index 0000000..278ed52 --- /dev/null +++ b/util/hashcheck.js @@ -0,0 +1,6 @@ +module.exports = function (cmd) { + if(true){ + return 1; + } + return 0; +} From 1b86f2b0459943ee7b43af033f243cf5a3c125a3 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 22 Jul 2024 18:08:49 -0400 Subject: [PATCH 101/362] Fix large security hole --- plugins/commands/eval.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/commands/eval.js b/plugins/commands/eval.js index c26efea..f6243d1 100644 --- a/plugins/commands/eval.js +++ b/plugins/commands/eval.js @@ -3,7 +3,8 @@ const index=require("../../index.js") //Not used in the code, but may be used by module.exports={ execute: (c)=>{ if(c.verify<3){ - c.reply(textformat("Eval command is currently not available to players in Minecraft due to security issues.")) + c.reply(textformat("Eval command is currently not available to players in Minecraft due to security issues.")); + return; }; try{ console.log(eval(c.args.join(" "))); From 85ef6b3d404f00d7a762b04f7bf8f66675ede860 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 22 Jul 2024 18:10:35 -0400 Subject: [PATCH 102/362] Fix chat parser bug --- util/chatparse.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/util/chatparse.js b/util/chatparse.js index 52fdcf4..09f5756 100644 --- a/util/chatparse.js +++ b/util/chatparse.js @@ -38,11 +38,7 @@ const parse=function(_data, l = 0, resetColor = [consoleColors.reset]){ } let data; if(typeof _data == "string"){ - try { - data=JSON.parse(_data); - } catch(e){ - data={text:_data, color: "reset"} - } + data={text:_data, color: "reset"} } else if(typeof _data == "number"){ data={text:_data+"", color: "reset"} } else { From 520e2a8abd5daa07e6dde76badcf0976fbc76d0c Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 22 Jul 2024 18:11:27 -0400 Subject: [PATCH 103/362] Finish hashing system --- plugins/command.js | 20 +++++++++++++++++++- plugins/commands/verify.js | 14 ++++++++++++++ util/hashcheck.js | 15 ++++++++++++++- 3 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 plugins/commands/verify.js diff --git a/plugins/command.js b/plugins/command.js index efbe638..4f1abf5 100755 --- a/plugins/command.js +++ b/plugins/command.js @@ -18,10 +18,28 @@ module.exports={ } const cmd=text.split(" "); let verify=hashcheck(cmd); + if(verify>0){ + text=cmd.slice(0,cmd.length-1).join(" "); + } if(cmds[cmd[0].toLowerCase()]){ + const command = cmds[cmd[0].toLowerCase()]; + if(command.level!==undefined && command.level>verify){ + b.tellraw(uuid,{ + text:"You do not have permission to run this command. If you have permission, please make sure you put the command hash at the end, or ran the command through your client's hashing system." + }); + b.tellraw(uuid,{ + text:"Your permission level: "+verify + }); + b.tellraw(uuid,{ + text:"Command requires: "+command.level + }); + return; + } try{ cmds[cmd[0].toLowerCase()].execute(new Command(uuid,name,"nick N/A",text,prefix,b,verify)) - } catch(e) { console.log(e); b.chat("An error occured (check console for more info)") } + } catch(e) { + console.log(e); b.chat("An error occured (check console for more info)") + } } } b.printHelp=(uuid,prefix)=>{ diff --git a/plugins/commands/verify.js b/plugins/commands/verify.js new file mode 100644 index 0000000..107c88f --- /dev/null +++ b/plugins/commands/verify.js @@ -0,0 +1,14 @@ +module.exports={ + execute: (c)=>{ + c.reply({ + text: c.verify+"" + }) + c.reply({ + text: c.command + }) + }, + desc: "Does nothing", // Command description + usage: ' [optional]', // Command usage + hidden: false, // To show the command on the help command list, remove this line + level: 1 +} diff --git a/util/hashcheck.js b/util/hashcheck.js index 278ed52..b63fc0c 100644 --- a/util/hashcheck.js +++ b/util/hashcheck.js @@ -1,6 +1,19 @@ +const crypto=require("crypto"); +const settings = require("../settings.json"); +const secret = require(settings.secret); module.exports = function (cmd) { - if(true){ + const cmdWithoutHash=cmd.slice(0,cmd.length-1).join(" "); + const _dateString=Date.now().toString(); + const dateString=_dateString.slice(0,_dateString.length-4); + const hashTrusted="babyboom:"+secret.keyTrusted+":"+cmdWithoutHash+":"+dateString + const hashOwner="babyboom:"+secret.keyOwner+":"+cmdWithoutHash+":"+dateString + const validhashT=crypto.createHash("sha256").update(hashTrusted).digest("hex"); + const validhashO=crypto.createHash("sha256").update(hashOwner).digest("hex"); + if(cmd[cmd.length-1]==validhashT){ return 1; } + if(cmd[cmd.length-1]==validhashO){ + return 2; + } return 0; } From 3e779e459b15a42abc21307820375f61d3156d88 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 22 Jul 2024 18:13:45 -0400 Subject: [PATCH 104/362] Fix the rest of the commands --- plugins/commands/about.js | 10 +++++----- plugins/commands/eval.js | 3 ++- plugins/commands/netmsg.js | 2 +- plugins/commands/serverinfo.js | 4 ++-- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/plugins/commands/about.js b/plugins/commands/about.js index 689085c..7475817 100644 --- a/plugins/commands/about.js +++ b/plugins/commands/about.js @@ -4,11 +4,11 @@ const version = require("../../version.json") const settings = require('../../settings.json') module.exports = { execute: function (c) { - c.reply({"text":"'+settings.name+' - a minecraft bot made by 77c8f4699b732c11 / a5a06d596f15c7db"}); - c.reply({"text":""}); - c.reply({"text":"Version '+version.bot+'"}); - c.reply({"text":""}); - c.reply({"text":"To view system information, run the command \"serverinfo\"."}) + c.reply({text:`${settings.name} - a minecraft bot made by 77c8f4699b732c11 / a5a06d596f15c7db`}); + c.reply({text:""}); + c.reply({text:`Version ${version.bot}`}); + c.reply({text:""}); + c.reply({text:"To view system information, run the command \"serverinfo\"."}) }, desc: 'About the bot', usage: '', diff --git a/plugins/commands/eval.js b/plugins/commands/eval.js index f6243d1..4f79f7e 100644 --- a/plugins/commands/eval.js +++ b/plugins/commands/eval.js @@ -14,5 +14,6 @@ module.exports={ }, desc: "Run JavaScript code", // Command description usage: '', // Command usage - hidden: true + hidden: true, + level: 3 } diff --git a/plugins/commands/netmsg.js b/plugins/commands/netmsg.js index b915574..d2a9fe8 100644 --- a/plugins/commands/netmsg.js +++ b/plugins/commands/netmsg.js @@ -29,7 +29,7 @@ module.exports={ color: "white" } for(const i in bot){ - bot[i].tellraw("@a",JSON.stringify(json)) + bot[i].tellraw("@a",json) } }, desc: "Send a message to all servers the bot is connected to", // Command description diff --git a/plugins/commands/serverinfo.js b/plugins/commands/serverinfo.js index 64e8971..b61ad49 100755 --- a/plugins/commands/serverinfo.js +++ b/plugins/commands/serverinfo.js @@ -6,7 +6,7 @@ const version = require("../../version.json") const fs=require("fs") const gr = function (text, value, color) { if (!color) color = 'white' - return JSON.stringify({ + return { translate: '%s: %s', with: [ { @@ -28,7 +28,7 @@ const gr = function (text, value, color) { action: 'copy_to_clipboard', value } - }) + } } const os2 = function (o2) { From f44220b0e64385e12c4d7dbee1cefb8f63a57711 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 22 Jul 2024 18:20:38 -0400 Subject: [PATCH 105/362] Add level to template command --- plugins/commands/template.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/commands/template.js b/plugins/commands/template.js index 60b155a..f1f9d15 100644 --- a/plugins/commands/template.js +++ b/plugins/commands/template.js @@ -16,7 +16,8 @@ module.exports={ }, desc: "Does nothing", // Command description usage: ' [optional]', // Command usage - hidden: true, // To show the command on the help command list, remove this line - consoleIndex: true, // When run from console, the second argument will be a bot ID - aliases: ["example", "testing"] // Other command names that will work the same + hidden: true, // To show the command on the help command list, remove this line (optional) + consoleIndex: true, // When run from console, the second argument will be a bot ID (optional) + aliases: ["example", "testing"], // Other command names that will work the same (optional) + level: 0 // Permission level required to run this command (optional) } From caee20aec8b4023b89c98552b00ea3a79ff8eca0 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 22 Jul 2024 18:23:07 -0400 Subject: [PATCH 106/362] Remove extraneous comments --- plugins/commands/about.js | 2 -- plugins/commands/cb.js | 8 ++++---- plugins/commands/eval.js | 6 +++--- plugins/commands/logoff.js | 4 ++-- plugins/commands/netmsg.js | 5 ++--- plugins/commands/refill.js | 6 +++--- plugins/commands/say.js | 19 +++---------------- plugins/commands/serverinfo.js | 1 - plugins/commands/stop.js | 4 ++-- plugins/commands/verify.js | 6 +++--- 10 files changed, 22 insertions(+), 39 deletions(-) diff --git a/plugins/commands/about.js b/plugins/commands/about.js index 7475817..d94744f 100644 --- a/plugins/commands/about.js +++ b/plugins/commands/about.js @@ -1,5 +1,3 @@ -// This is not C source code -//const settings = require('../settings.json') const version = require("../../version.json") const settings = require('../../settings.json') module.exports = { diff --git a/plugins/commands/cb.js b/plugins/commands/cb.js index 0a4d21d..508287f 100644 --- a/plugins/commands/cb.js +++ b/plugins/commands/cb.js @@ -2,8 +2,8 @@ module.exports={ execute: (c)=>{ c.bot.ccq.push(c.args.join(" ")) }, - desc: "Run a command in a command block", // Command description - usage: ' ', // Command usage - consoleIndex: true, // When run from console, the second argument will be a bot ID - aliases: ["commandblock", "cmdblock"] // Other command names that will work the same + desc: "Run a command in a command block", + usage: ' ', + consoleIndex: true, + aliases: ["commandblock", "cmdblock"] } diff --git a/plugins/commands/eval.js b/plugins/commands/eval.js index 4f79f7e..a698f45 100644 --- a/plugins/commands/eval.js +++ b/plugins/commands/eval.js @@ -1,5 +1,5 @@ const textformat=require("../../util/textformat.js") -const index=require("../../index.js") //Not used in the code, but may be used by users of the command +const index=require("../../index.js") // Not used in the code, but may be used by users of the command module.exports={ execute: (c)=>{ if(c.verify<3){ @@ -12,8 +12,8 @@ module.exports={ console.error(e); } }, - desc: "Run JavaScript code", // Command description - usage: '', // Command usage + desc: "Run JavaScript code", + usage: '', hidden: true, level: 3 } diff --git a/plugins/commands/logoff.js b/plugins/commands/logoff.js index 1eb6963..6c73cd2 100644 --- a/plugins/commands/logoff.js +++ b/plugins/commands/logoff.js @@ -3,8 +3,8 @@ module.exports={ if(c.verify<2) return; c.bot._client.end(); }, - desc: "Does nothing", // Command description - usage: ' [optional]', // Command usage + desc: "Does nothing", + usage: ' [optional]', hidden: true, consoleIndex: true } diff --git a/plugins/commands/netmsg.js b/plugins/commands/netmsg.js index d2a9fe8..81b4d25 100644 --- a/plugins/commands/netmsg.js +++ b/plugins/commands/netmsg.js @@ -32,7 +32,6 @@ module.exports={ bot[i].tellraw("@a",json) } }, - desc: "Send a message to all servers the bot is connected to", // Command description - usage: ' ', // Command usage - consoleIndex: false // When run from console, the second argument will be a bot ID + desc: "Send a message to all servers the bot is connected to", + usage: ' ' } diff --git a/plugins/commands/refill.js b/plugins/commands/refill.js index 2513cf4..518f04b 100644 --- a/plugins/commands/refill.js +++ b/plugins/commands/refill.js @@ -2,8 +2,8 @@ module.exports={ execute: (c)=>{ c.bot.chat(`/fill ~ 20 ~ ~3 25 ~3 command_block{CustomName:'{"translate":"pack.dropConfirm","color":"#FFAAFF"}'}`) }, - desc: "Refill core", // Command description - usage: '', // Command usage - consoleIndex: true, // When run from console, the second argument will be a bot ID + desc: "Refill core", + usage: '', + consoleIndex: true, aliases: ["refillcore", "rc"] } diff --git a/plugins/commands/say.js b/plugins/commands/say.js index ddde9a7..dbc5895 100644 --- a/plugins/commands/say.js +++ b/plugins/commands/say.js @@ -1,23 +1,10 @@ module.exports={ execute: (c)=>{ - //Blank template - /* - c.send(text, user?): Send text to all ("/tellraw @a") - c.reply(text): Send text to command sender - c.uuid: Unique identifier (UUID for Minecraft, Discord ID for Discord) - c.username: Username of sender - c.nickname: Nickname of sender when applicable - c.command: Command string - c.args: Arguments of command (above without the first section, and split at every space) - c.prefix: Prefix being used to send the command (when applicable) - c.bot: Bot that received the command. Will be different type based on where it was received - c.type: Type of bot receiving the command ("minecraft", "console", "discord") - */ if(c.args[0].startsWith("/") && !c.type=="console") return; c.bot.chat(c.args.join(" ")) }, - desc: "Sends a message to chat", // Command description - usage: ' ', // Command usage + desc: "Sends a message to chat", + usage: ' ', hidden: true, - consoleIndex: true //To show the command on the help command list, remove this line + consoleIndex: true } diff --git a/plugins/commands/serverinfo.js b/plugins/commands/serverinfo.js index b61ad49..2825910 100755 --- a/plugins/commands/serverinfo.js +++ b/plugins/commands/serverinfo.js @@ -46,7 +46,6 @@ const os2 = function (o2) { return o2 } } -// b.tellraw(sender,gr("Example",example)) module.exports = { execute: function (c) { c.reply(gr('Operating system', os2(process.platform))) diff --git a/plugins/commands/stop.js b/plugins/commands/stop.js index b65a74c..3017b53 100644 --- a/plugins/commands/stop.js +++ b/plugins/commands/stop.js @@ -3,8 +3,8 @@ module.exports={ if(c.verify<2) return; process.exit(0); }, - desc: "Restart bot", // Command description - usage: ' [optional]', // Command usage + desc: "Restart bot", + usage: ' [optional]', hidden: true, aliases: ["restart", "exit"] } diff --git a/plugins/commands/verify.js b/plugins/commands/verify.js index 107c88f..196c0da 100644 --- a/plugins/commands/verify.js +++ b/plugins/commands/verify.js @@ -7,8 +7,8 @@ module.exports={ text: c.command }) }, - desc: "Does nothing", // Command description - usage: ' [optional]', // Command usage - hidden: false, // To show the command on the help command list, remove this line + desc: "Does nothing", + usage: ' [optional]', + hidden: false, level: 1 } From e1fa67f1bfb0e56456c6b10d9f823a4d5ba1856f Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 22 Jul 2024 18:26:14 -0400 Subject: [PATCH 107/362] Convert high permission commands to use permission levels --- plugins/commands/logoff.js | 4 ++-- plugins/commands/say.js | 2 +- plugins/commands/stop.js | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/commands/logoff.js b/plugins/commands/logoff.js index 6c73cd2..d2f9c60 100644 --- a/plugins/commands/logoff.js +++ b/plugins/commands/logoff.js @@ -1,10 +1,10 @@ module.exports={ execute: (c)=>{ - if(c.verify<2) return; c.bot._client.end(); }, desc: "Does nothing", usage: ' [optional]', hidden: true, - consoleIndex: true + consoleIndex: true, + level: 2 } diff --git a/plugins/commands/say.js b/plugins/commands/say.js index dbc5895..d940f0c 100644 --- a/plugins/commands/say.js +++ b/plugins/commands/say.js @@ -1,6 +1,6 @@ module.exports={ execute: (c)=>{ - if(c.args[0].startsWith("/") && !c.type=="console") return; + if(c.args[0].startsWith("/") && !c.verify<1) return; c.bot.chat(c.args.join(" ")) }, desc: "Sends a message to chat", diff --git a/plugins/commands/stop.js b/plugins/commands/stop.js index 3017b53..0de6909 100644 --- a/plugins/commands/stop.js +++ b/plugins/commands/stop.js @@ -1,10 +1,10 @@ module.exports={ execute: (c)=>{ - if(c.verify<2) return; process.exit(0); }, desc: "Restart bot", usage: ' [optional]', hidden: true, - aliases: ["restart", "exit"] + aliases: ["restart", "exit"], + level: 2 } From cd8522504a180c1bd5b867fe043cf060d35076a2 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 22 Jul 2024 19:04:28 -0400 Subject: [PATCH 108/362] Allow for higher %n$s than %4$s --- util/chatparse.js | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) diff --git a/util/chatparse.js b/util/chatparse.js index 09f5756..d9adf80 100644 --- a/util/chatparse.js +++ b/util/chatparse.js @@ -88,33 +88,9 @@ const parse=function(_data, l = 0, resetColor = [consoleColors.reset]){ trans = trans.replace(/%s/, j2[0].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) trans2 = trans2.replace(/%s/, j2[1].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) trans3 = trans3.replace(/%s/, j2[2].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) - } - // %n$s only goes up to 4 normally - if (data.with) { - if (data.with[0]) { - const j2_1 = parse(data.with[0], l + 1, data.color?[consoleColors[data.color],""]:resetColor) - trans = trans.replace(/%1\$s/g, j2_1[0].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) - trans2 = trans2.replace(/%1\$s/g, j2_1[1].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) - trans3 = trans3.replace(/%1\$s/g, j2_1[2].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) - } - if (data.with[1]) { - const j2_2 = parse(data.with[1], l + 1, data.color?[consoleColors[data.color],""]:resetColor) - trans = trans.replace(/%2\$s/g, j2_2[0].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) - trans2 = trans2.replace(/%2\$s/g, j2_2[1].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) - trans3 = trans3.replace(/%2\$s/g, j2_2[2].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) - } - if (data.with[2]) { - const j2_3 = parse(data.with[2], l + 1, data.color?[consoleColors[data.color],""]:resetColor) - trans = trans.replace(/%3\$s/g, j2_3[0].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) - trans2 = trans2.replace(/%3\$s/g, j2_3[1].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) - trans3 = trans3.replace(/%3\$s/g, j2_3[2].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) - } - if (data.with[3]) { - const j2_4 = parse(data.with[3], l + 1, data.color?[consoleColors[data.color],""]:resetColor) - trans = trans.replace(/%4\$s/g, j2_4[0].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) - trans2 = trans2.replace(/%4\$s/g, j2_4[1].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) - trans3 = trans3.replace(/%4\$s/g, j2_4[2].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) - } + trans = trans.replaceAll(`%${+i+1}$s`, j2[0].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + trans2 = trans2.replaceAll(`%${+i+1}$s`, j2[1].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + trans3 = trans3.replaceAll(`%${+i+1}$s`, j2[2].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) } out[0] += trans.replace(/%([0-9]*\$){0,1}s/g, '').replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s') out[1] += trans2.replace(/%([0-9]*\$){0,1}s/g, '').replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s') From 658d6b1a6e05712eee1b9a6e1fbfea23efeb5f18 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 22 Jul 2024 19:10:13 -0400 Subject: [PATCH 109/362] Remove %n$s hider --- util/chatparse.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/util/chatparse.js b/util/chatparse.js index d9adf80..b27d656 100644 --- a/util/chatparse.js +++ b/util/chatparse.js @@ -92,9 +92,9 @@ const parse=function(_data, l = 0, resetColor = [consoleColors.reset]){ trans2 = trans2.replaceAll(`%${+i+1}$s`, j2[1].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) trans3 = trans3.replaceAll(`%${+i+1}$s`, j2[2].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) } - out[0] += trans.replace(/%([0-9]*\$){0,1}s/g, '').replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s') - out[1] += trans2.replace(/%([0-9]*\$){0,1}s/g, '').replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s') - out[2] += trans3.replace(/%([0-9]*\$){0,1}s/g, '').replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s') + out[0] += trans.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s') + out[1] += trans2.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s') + out[2] += trans3.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s') } if(data.extra){ for(const i in data.extra){ From 29e59ed0d020b02f09bdfdc24b1cb628d2b2fa49 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 22 Jul 2024 20:33:16 -0400 Subject: [PATCH 110/362] Add translation support Also converts some things to use it. --- plugins/command.js | 18 ++++++++++-------- plugins/commands/about.js | 7 ++++--- settings2.json | 1 + util/Command.js | 6 ++++-- util/ConsoleCommand.js | 4 +++- util/lang.js | 27 +++++++++++++++++++++++++++ util/lang/en-US.json | 11 +++++++++++ util/lang/he-IL.json | 5 +++++ 8 files changed, 65 insertions(+), 14 deletions(-) create mode 100644 util/lang.js create mode 100644 util/lang/en-US.json create mode 100644 util/lang/he-IL.json diff --git a/plugins/command.js b/plugins/command.js index 4f1abf5..4e92c51 100755 --- a/plugins/command.js +++ b/plugins/command.js @@ -2,6 +2,7 @@ const fs=require("fs"); const Command=require("../util/Command.js"); const hashcheck=require("../util/hashcheck.js"); const settings = require("../settings.json"); +const getMessage = require('../util/lang.js'); let cmds=Object.create(null); module.exports={ load:()=>{ @@ -17,6 +18,7 @@ module.exports={ return; } const cmd=text.split(" "); + let lang=settings.defaultLang; let verify=hashcheck(cmd); if(verify>0){ text=cmd.slice(0,cmd.length-1).join(" "); @@ -25,33 +27,33 @@ module.exports={ const command = cmds[cmd[0].toLowerCase()]; if(command.level!==undefined && command.level>verify){ b.tellraw(uuid,{ - text:"You do not have permission to run this command. If you have permission, please make sure you put the command hash at the end, or ran the command through your client's hashing system." + text:getMessage(lang,"command.disallowed.perms") }); b.tellraw(uuid,{ - text:"Your permission level: "+verify + text:getMessage(lang,"command.disallowed.perms.yourLevel",[verify+""]) }); b.tellraw(uuid,{ - text:"Command requires: "+command.level + text:getMessage(lang,"command.disallowed.perms.cmdLevel",[command.level+""]) }); return; } try{ cmds[cmd[0].toLowerCase()].execute(new Command(uuid,name,"nick N/A",text,prefix,b,verify)) } catch(e) { - console.log(e); b.chat("An error occured (check console for more info)") + console.log(e); b.chat(getMessage(lang,"command.error")) } } } - b.printHelp=(uuid,prefix)=>{ + b.printHelp=(uuid,prefix,lang)=>{ let helpCmds=[]; for(const i in cmds){ if(cmds[i].hidden) continue; helpCmds.push(prefix+i) } - b.tellraw(uuid,{"text":"Commands: "+helpCmds.join(" ")}); + b.tellraw(uuid,{"text":getMessage(lang,"command.help.cmdList",[helpCmds.join(" ")])}); } - b.printCmdHelp=(uuid,cmd)=>{ - b.tellraw(uuid,{"text":cmd+cmds[cmd].usage+" - "+cmds[cmd].desc}); + b.printCmdHelp=(uuid,cmd,lang)=>{ + b.tellraw(uuid,{"text":getMessage(lang,"command.help.commandInfo",[cmd,getMessage(lang,`command.${cmd}.usage`),getMessage(lang,"command.${cmd}.desc")])}); } }, loadCMD:()=>{ diff --git a/plugins/commands/about.js b/plugins/commands/about.js index d94744f..dd70aa1 100644 --- a/plugins/commands/about.js +++ b/plugins/commands/about.js @@ -1,12 +1,13 @@ const version = require("../../version.json") const settings = require('../../settings.json') +const getMessage = require('../../util/lang.js') module.exports = { execute: function (c) { - c.reply({text:`${settings.name} - a minecraft bot made by 77c8f4699b732c11 / a5a06d596f15c7db`}); + c.reply({text:getMessage(c.lang,"command.about.author",[settings.name])}); c.reply({text:""}); - c.reply({text:`Version ${version.bot}`}); + c.reply({text:getMessage(c.lang,"command.about.version",[version.bot])}); c.reply({text:""}); - c.reply({text:"To view system information, run the command \"serverinfo\"."}) + c.reply({text:getMessage(c.lang,"command.about.serverinfo")}) }, desc: 'About the bot', usage: '', diff --git a/settings2.json b/settings2.json index 987414d..69c594a 100755 --- a/settings2.json +++ b/settings2.json @@ -2,6 +2,7 @@ "secret":"./settings_s.json", "name": "Minecraft Bot", "version_mc": "1.20.4", + "defaultLang": "en-US", "prefix":[ "ubot:", "\"" diff --git a/util/Command.js b/util/Command.js index 9539630..4406157 100644 --- a/util/Command.js +++ b/util/Command.js @@ -1,7 +1,8 @@ //HOW TO WRITE CLASS JS -const parse = require("../util/chatparse.js") +const parse = require("../util/chatparse.js"); +const settings = require("../settings.json"); class Command{ - constructor (uuid,user,nick,cmd,prefix,bot,verify){ + constructor (uuid,user,nick,cmd,prefix,bot,verify,lang = settings.defaultLang){ this.send = (text,uuid)=>{bot.tellraw(uuid?uuid:"@a",text)}; this.reply = text => bot.tellraw(uuid,text); this.uuid = uuid; @@ -16,6 +17,7 @@ class Command{ this.verify = verify; this.host = bot.host.host; this.port = bot.host.port; + this.lang = lang; } } diff --git a/util/ConsoleCommand.js b/util/ConsoleCommand.js index 878942d..4f068b3 100644 --- a/util/ConsoleCommand.js +++ b/util/ConsoleCommand.js @@ -1,7 +1,8 @@ //HOW TO WRITE CLASS JS const index = require('../index.js') const { cmds } = require('../plugins/command.js'); -const parse = require("../util/chatparse.js") +const parse = require("../util/chatparse.js"); +const settings = require("../settings.json"); class ConsoleCommand{ constructor (cmd,index2){ this.send = ()=>{}; //not needed for console @@ -30,6 +31,7 @@ class ConsoleCommand{ this.verify = 3; this.host = ""; this.port = "3"; // :3 + this.lang = settings.defaultLang; } } diff --git a/util/lang.js b/util/lang.js new file mode 100644 index 0000000..75b7aad --- /dev/null +++ b/util/lang.js @@ -0,0 +1,27 @@ +const fs=require("fs") +let languages={}; +const loadplug = (botno) => { + const bpl = fs.readdirSync('util/lang') + for (const i in bpl) { + if (!bpl[i].endsWith('.json')) { + continue + } + try { + languages[bpl[i].split(".")[0]]=require(`./lang/${bpl[i]}`) + } catch (e) { console.log(e) } + } +} +loadplug() +module.exports = function (l, msg, with2) { + let message=msg.replace(/%%/g, '\ue123'); + if (languages[l][message] !== undefined) { + message = languages[l][message].replace(/%%/g, '\ue123') + } else if (languages["en-US"][message] !== undefined) { + message = languages["en-US"][message].replace(/%%/g, '\ue123') + } + for(i in with2){ + message = message.replace(/%s/, with2[i].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + message = message.replaceAll(`%${+i+1}$s`, with2[i].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + } + return message.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s') +} diff --git a/util/lang/en-US.json b/util/lang/en-US.json new file mode 100644 index 0000000..2e7813b --- /dev/null +++ b/util/lang/en-US.json @@ -0,0 +1,11 @@ +{ + "command.about.author": "%s - a Minecraft bot made by 77c8f4699b732c11 / a5a06d596f15c7db", + "command.about.version": "Version %s", + "command.about.serverinfo": "To view system information, run the command \"serverinfo\".", + "command.help.cmdList": "Commands: %s", + "command.help.commandInfo": "%s%s - %s", + "command.error": "An error occured (check console for more info)", + "command.disallowed.perms": "You do not have permission to run this command. If you have permission, please make sure you put the command hash at the end, or ran the command through your client's hashing system.", + "command.disallowed.perms.yourLevel": "Your permission level: %s", + "command.disallowed.perms.cmdLevel": "Command requires: %s" +} \ No newline at end of file diff --git a/util/lang/he-IL.json b/util/lang/he-IL.json new file mode 100644 index 0000000..2897985 --- /dev/null +++ b/util/lang/he-IL.json @@ -0,0 +1,5 @@ +{ + "command.about.author": "%s - a Minecwaft bot made by 77c8f4699b732c11 / a5a06d596f15c7db", + "command.about.version": "Vewsion %s", + "command.about.serverinfo": "To view system infowmation, wun the command \"serverinfo\"." +} \ No newline at end of file From 95258820b43a0ceb6fda94701d90b2ef1ea590ad Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 22 Jul 2024 20:35:45 -0400 Subject: [PATCH 111/362] Added more messages to Hebrew (Israel) --- util/lang/en-US.json | 2 +- util/lang/he-IL.json | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/util/lang/en-US.json b/util/lang/en-US.json index 2e7813b..0b5d5dc 100644 --- a/util/lang/en-US.json +++ b/util/lang/en-US.json @@ -5,7 +5,7 @@ "command.help.cmdList": "Commands: %s", "command.help.commandInfo": "%s%s - %s", "command.error": "An error occured (check console for more info)", - "command.disallowed.perms": "You do not have permission to run this command. If you have permission, please make sure you put the command hash at the end, or ran the command through your client's hashing system.", + "command.disallowed.perms": "You do not have permission to run this command. If you do have permission, please make sure you put the command hash at the end, or ran the command through your client's hashing system.", "command.disallowed.perms.yourLevel": "Your permission level: %s", "command.disallowed.perms.cmdLevel": "Command requires: %s" } \ No newline at end of file diff --git a/util/lang/he-IL.json b/util/lang/he-IL.json index 2897985..9e90b0e 100644 --- a/util/lang/he-IL.json +++ b/util/lang/he-IL.json @@ -1,5 +1,11 @@ { "command.about.author": "%s - a Minecwaft bot made by 77c8f4699b732c11 / a5a06d596f15c7db", "command.about.version": "Vewsion %s", - "command.about.serverinfo": "To view system infowmation, wun the command \"serverinfo\"." + "command.about.serverinfo": "To view system infowmation, wun the command \"serverinfo\".", + "command.help.cmdList": "Commands: %s", + "command.help.commandInfo": "%s%s - %s", + "command.error": "An ewwow occuwed (check consowe fow mowe info)", + "command.disallowed.perms": "You do nyot have pewmission to wun this command. If you do have pewmission, pwease make suwe you put the command hash at the end, ow wan the command thwough youw cwient's hashing system.", + "command.disallowed.perms.yourLevel": "Youw pewmission wevew: %s", + "command.disallowed.perms.cmdLevel": "Command wequiwes: %s" } \ No newline at end of file From b67be7f2e963b45ec09daf7e843f8308c1ebaae2 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 22 Jul 2024 21:32:04 -0400 Subject: [PATCH 112/362] Make the rest of commands use translation --- plugins/command.js | 10 +++++++- plugins/commands/about.js | 2 -- plugins/commands/cb.js | 2 -- plugins/commands/eval.js | 6 ----- plugins/commands/help.js | 8 +++--- plugins/commands/logoff.js | 2 -- plugins/commands/netmsg.js | 4 +-- plugins/commands/refill.js | 2 -- plugins/commands/say.js | 2 -- plugins/commands/serverinfo.js | 41 +++++++++++++++---------------- plugins/commands/stop.js | 2 -- plugins/commands/template.js | 22 +++++++++++++++-- plugins/commands/verify.js | 2 -- util/lang/en-US.json | 45 +++++++++++++++++++++++++++++++++- 14 files changed, 97 insertions(+), 53 deletions(-) diff --git a/plugins/command.js b/plugins/command.js index 4e92c51..84a6200 100755 --- a/plugins/command.js +++ b/plugins/command.js @@ -53,7 +53,15 @@ module.exports={ b.tellraw(uuid,{"text":getMessage(lang,"command.help.cmdList",[helpCmds.join(" ")])}); } b.printCmdHelp=(uuid,cmd,lang)=>{ - b.tellraw(uuid,{"text":getMessage(lang,"command.help.commandInfo",[cmd,getMessage(lang,`command.${cmd}.usage`),getMessage(lang,"command.${cmd}.desc")])}); + let usage=getMessage(lang,`command.${cmd}.usage`); + let desc=getMessage(lang,`command.${cmd}.desc`); + if(cmds[cmd].usage){ + usage=cmds[cmd].usage; + } + if(cmds[cmd].desc){ + desc=cmds[cmd].desc; + } + b.tellraw(uuid,{"text":getMessage(lang,"command.help.commandInfo",[cmd,usage,desc])}); } }, loadCMD:()=>{ diff --git a/plugins/commands/about.js b/plugins/commands/about.js index dd70aa1..d46ad87 100644 --- a/plugins/commands/about.js +++ b/plugins/commands/about.js @@ -9,7 +9,5 @@ module.exports = { c.reply({text:""}); c.reply({text:getMessage(c.lang,"command.about.serverinfo")}) }, - desc: 'About the bot', - usage: '', aliases: ["info"] } diff --git a/plugins/commands/cb.js b/plugins/commands/cb.js index 508287f..f22f4ed 100644 --- a/plugins/commands/cb.js +++ b/plugins/commands/cb.js @@ -2,8 +2,6 @@ module.exports={ execute: (c)=>{ c.bot.ccq.push(c.args.join(" ")) }, - desc: "Run a command in a command block", - usage: ' ', consoleIndex: true, aliases: ["commandblock", "cmdblock"] } diff --git a/plugins/commands/eval.js b/plugins/commands/eval.js index a698f45..431da17 100644 --- a/plugins/commands/eval.js +++ b/plugins/commands/eval.js @@ -2,18 +2,12 @@ const textformat=require("../../util/textformat.js") const index=require("../../index.js") // Not used in the code, but may be used by users of the command module.exports={ execute: (c)=>{ - if(c.verify<3){ - c.reply(textformat("Eval command is currently not available to players in Minecraft due to security issues.")); - return; - }; try{ console.log(eval(c.args.join(" "))); }catch(e){ console.error(e); } }, - desc: "Run JavaScript code", - usage: '', hidden: true, level: 3 } diff --git a/plugins/commands/help.js b/plugins/commands/help.js index 7787210..c19c9fe 100644 --- a/plugins/commands/help.js +++ b/plugins/commands/help.js @@ -1,11 +1,9 @@ module.exports={ execute: (c)=>{ if(c.args.length>0){ - c.bot.printCmdHelp(c.uuid,c.args[0]); + c.bot.printCmdHelp(c.uuid,c.args[0],c.lang); } else { - c.bot.printHelp(c.uuid,c.prefix); + c.bot.printHelp(c.uuid,c.prefix,c.lang); } - }, - desc: "Shows command help", - usage: ' [cmd]' + } } diff --git a/plugins/commands/logoff.js b/plugins/commands/logoff.js index d2f9c60..dbc0a22 100644 --- a/plugins/commands/logoff.js +++ b/plugins/commands/logoff.js @@ -2,8 +2,6 @@ module.exports={ execute: (c)=>{ c.bot._client.end(); }, - desc: "Does nothing", - usage: ' [optional]', hidden: true, consoleIndex: true, level: 2 diff --git a/plugins/commands/netmsg.js b/plugins/commands/netmsg.js index 81b4d25..72c8d78 100644 --- a/plugins/commands/netmsg.js +++ b/plugins/commands/netmsg.js @@ -31,7 +31,5 @@ module.exports={ for(const i in bot){ bot[i].tellraw("@a",json) } - }, - desc: "Send a message to all servers the bot is connected to", - usage: ' ' + } } diff --git a/plugins/commands/refill.js b/plugins/commands/refill.js index 518f04b..e8fbb29 100644 --- a/plugins/commands/refill.js +++ b/plugins/commands/refill.js @@ -2,8 +2,6 @@ module.exports={ execute: (c)=>{ c.bot.chat(`/fill ~ 20 ~ ~3 25 ~3 command_block{CustomName:'{"translate":"pack.dropConfirm","color":"#FFAAFF"}'}`) }, - desc: "Refill core", - usage: '', consoleIndex: true, aliases: ["refillcore", "rc"] } diff --git a/plugins/commands/say.js b/plugins/commands/say.js index d940f0c..44644ca 100644 --- a/plugins/commands/say.js +++ b/plugins/commands/say.js @@ -3,8 +3,6 @@ module.exports={ if(c.args[0].startsWith("/") && !c.verify<1) return; c.bot.chat(c.args.join(" ")) }, - desc: "Sends a message to chat", - usage: ' ', hidden: true, consoleIndex: true } diff --git a/plugins/commands/serverinfo.js b/plugins/commands/serverinfo.js index 2825910..7c73f97 100755 --- a/plugins/commands/serverinfo.js +++ b/plugins/commands/serverinfo.js @@ -3,8 +3,9 @@ const cp = require('child_process') const settings = require('../../settings.json') const timeformat = require('../../util/timeformat.js') const version = require("../../version.json") +const getMessage = require('../../util/lang.js') const fs=require("fs") -const gr = function (text, value, color) { +const gr = function (l, text, value, color) { if (!color) color = 'white' return { translate: '%s: %s', @@ -21,7 +22,7 @@ const gr = function (text, value, color) { hoverEvent: { action: 'show_text', contents: { - text: 'Click to copy!' + text: getMessage(l,"copyText") } }, clickEvent: { @@ -31,16 +32,16 @@ const gr = function (text, value, color) { } } -const os2 = function (o2) { +const os2 = function (o2,l) { switch (o2) { case 'win32': return os.version() break case 'android': - return 'Android' + return getMessage(l,"command.serverinfo.os.android") break case 'linux': - return 'Linux' + ' ' + os.release() + return getMessage(l,"command.serverinfo.os.linux",[os.release()]) break default: return o2 @@ -48,13 +49,13 @@ const os2 = function (o2) { } module.exports = { execute: function (c) { - c.reply(gr('Operating system', os2(process.platform))) - c.reply(gr('CPU', os.cpus()[0].model)) - c.reply(gr('Architecture', os.machine())) - c.reply(gr('Username', os.userInfo().username)) - c.reply(gr('Bot uptime', timeformat(process.uptime() * 1000))) - c.reply(gr('System uptime', timeformat(os.uptime() * 1000))) - c.reply(gr('Node.js version', process.version)) + c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.os"), os2(process.platform,c.lang))) + c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.processor"), os.cpus()[0].model)) + c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.arch"), os.machine())) + c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.osUsername"), os.userInfo().username)) + c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.runTime"), timeformat(process.uptime() * 1000))) + c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.upTime"), timeformat(os.uptime() * 1000))) + c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.nodeVersion"), process.version)) if (process.platform == 'linux' || process.platform == 'freebsd') { try{ const osrelease = fs.readFileSync("/etc/os-release").toString("UTF-8").split("\n"); @@ -67,21 +68,19 @@ module.exports = { } if(osrelease2.PRETTY_NAME){ - c.reply(gr('Linux release', osrelease2.PRETTY_NAME, 'dark_green')) + c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.osRelease"), osrelease2.PRETTY_NAME, 'dark_green')) } } catch(e){ - c.reply('{"text":"/etc/os-release does not exist. Information may be limited."}') + c.reply({text:getMessage(c.lang,"command.serverinfo.osRelease.missing")}) } } else if (process.platform == 'android') { const android_version = cp.execSync('getprop ro.build.version.release').toString('UTF-8').split('\n')[0] - c.reply(gr('Android version', android_version, 'green')) + c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.os.android.version"), android_version, 'green')) const dModel=cp.execSync('getprop ro.product.model').toString('UTF-8').split('\n')[0]; const dBrand=cp.execSync('getprop ro.product.brand').toString('UTF-8').split('\n')[0]; - c.reply(gr('Device model', dBrand+dModel, 'green')) + c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.os.android.model"), dBrand+dModel, 'green')) } - c.reply(gr('Bot name', settings.name, 'yellow')) - c.reply(gr('Bot version', version.bot, 'yellow')) - }, - desc: 'Get system/bot info (ported from V9). Not complete.', - usage: '' + c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.botName"), settings.name, 'yellow')) + c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.botVer"), version.bot, 'yellow')) + } } diff --git a/plugins/commands/stop.js b/plugins/commands/stop.js index 0de6909..80e7341 100644 --- a/plugins/commands/stop.js +++ b/plugins/commands/stop.js @@ -2,8 +2,6 @@ module.exports={ execute: (c)=>{ process.exit(0); }, - desc: "Restart bot", - usage: ' [optional]', hidden: true, aliases: ["restart", "exit"], level: 2 diff --git a/plugins/commands/template.js b/plugins/commands/template.js index f1f9d15..0df9f4c 100644 --- a/plugins/commands/template.js +++ b/plugins/commands/template.js @@ -12,10 +12,28 @@ module.exports={ c.prefix: Prefix being used to send the command (when applicable) c.bot: Bot that received the command. Will be different type based on where it was received c.type: Type of bot receiving the command ("minecraft", "console", "discord") + c.lang: The language the player has selected, or en-US if none */ }, - desc: "Does nothing", // Command description - usage: ' [optional]', // Command usage + /* + Command description and usage have been moved to the message files. The format for a basic command is: + "command.(name).usage": " [optional]", + "command.(name).desc": "Insert description here...", + replacing (name) with the name of the new command. + Some more complex commands may have messages of their own, which should be placed there too. + First, insert the following line near the top of the command's file (not in the execute function): + const getMessage = require('../../util/lang.js') + Then, to get a specific message: + getMessage(c.lang,"(message key)",[(arguments, in an array (optional))]) + For example, this will show the "about" command's redirection to "serverinfo": + getMessage(c.lang,"command.about.serverinfo") + The with array can be used to add information to a message. For example: + getMessage(lang,"command.help.commandInfo",["cmd","usage","desc"]) + shows the "help" command's formatting for command information, with some strings as items. + That message would render as (in en-US): + cmdusage - desc + Extra information is inserted wherever there is a "%s" or a "%n$s", with n being the index of the item in the array. + */ hidden: true, // To show the command on the help command list, remove this line (optional) consoleIndex: true, // When run from console, the second argument will be a bot ID (optional) aliases: ["example", "testing"], // Other command names that will work the same (optional) diff --git a/plugins/commands/verify.js b/plugins/commands/verify.js index 196c0da..c7b4078 100644 --- a/plugins/commands/verify.js +++ b/plugins/commands/verify.js @@ -7,8 +7,6 @@ module.exports={ text: c.command }) }, - desc: "Does nothing", - usage: ' [optional]', hidden: false, level: 1 } diff --git a/util/lang/en-US.json b/util/lang/en-US.json index 0b5d5dc..9327394 100644 --- a/util/lang/en-US.json +++ b/util/lang/en-US.json @@ -1,11 +1,54 @@ { + "command.about.usage": "", + "command.about.desc": "About the bot", + "command.cb.usage": " ", + "command.cb.desc": "Run a command in a command block", + "command.eval.usage": " ", + "command.eval.desc": "Run JavaScript code", + "command.help.usage": " [cmd]", + "command.help.desc": "Shows command help", + "command.logoff.usage": "", + "command.logoff.desc": "Disconnect and reconnect the bot from a server", + "command.netmsg.usage": " ", + "command.netmsg.desc": "Send a message to all servers the bot is connected to", + "command.refill.usage": "", + "command.refill.desc": "Refill core", + "command.say.usage": " ", + "command.say.desc": "Sends a message to chat", + "command.serverinfo.usage": "", + "command.serverinfo.desc": "Get system/bot info", + "command.stop.usage": "", + "command.stop.desc": "Restart bot", + "command.template.usage": " [optional]", + "command.template.desc": "Does nothing", + "command.verify.usage": " [args...]", + "command.verify.desc": "Check the hashing system", "command.about.author": "%s - a Minecraft bot made by 77c8f4699b732c11 / a5a06d596f15c7db", "command.about.version": "Version %s", "command.about.serverinfo": "To view system information, run the command \"serverinfo\".", "command.help.cmdList": "Commands: %s", "command.help.commandInfo": "%s%s - %s", + "command.serverinfo.os.android": "Android", + "command.serverinfo.os.freebsd": "FreeBSD", + "command.serverinfo.os.linux": "Linux", + "command.serverinfo.os.macos": "macOS", + "command.serverinfo.os.macos_old": "OS X", + "command.serverinfo.os": "Operating system", + "command.serverinfo.processor": "CPU", + "command.serverinfo.arch": "Architecture", + "command.serverinfo.osUsername": "Username", + "command.serverinfo.runTime": "Bot uptime", + "command.serverinfo.upTime": "System uptime", + "command.serverinfo.nodeVersion": "Node.js version", + "command.serverinfo.osRelease": "Linux release", + "command.serverinfo.osRelease.missing": "/etc/os-release does not exist. Information may be limited.", + "command.serverinfo.os.android.version": "Android version", + "command.serverinfo.os.android.model": "Device model", + "command.serverinfo.botName": "Bot name", + "command.serverinfo.botVer": "Bot version", "command.error": "An error occured (check console for more info)", "command.disallowed.perms": "You do not have permission to run this command. If you do have permission, please make sure you put the command hash at the end, or ran the command through your client's hashing system.", "command.disallowed.perms.yourLevel": "Your permission level: %s", - "command.disallowed.perms.cmdLevel": "Command requires: %s" + "command.disallowed.perms.cmdLevel": "Command requires: %s", + "copyText": "Click to copy!" } \ No newline at end of file From c3a2fee22ce1b318874c189145eb1107638c0786 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 22 Jul 2024 21:39:24 -0400 Subject: [PATCH 113/362] Added more messages to Hebrew (Israel) --- util/lang/he-IL.json | 45 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/util/lang/he-IL.json b/util/lang/he-IL.json index 9e90b0e..7295ba7 100644 --- a/util/lang/he-IL.json +++ b/util/lang/he-IL.json @@ -1,11 +1,54 @@ { + "command.about.usage": "", + "command.about.desc": "About the bot", + "command.cb.usage": " ", + "command.cb.desc": "Wun a command in a command bwock", + "command.eval.usage": " ", + "command.eval.desc": "Wun JavaScwipt code", + "command.help.usage": " [cmd]", + "command.help.desc": "Shows command hewp", + "command.logoff.usage": "", + "command.logoff.desc": "Disconnect and weconnect the bot fwom a sewvew", + "command.netmsg.usage": " ", + "command.netmsg.desc": "Send a message to aww sewvews the bot is connected to", + "command.refill.usage": "", + "command.refill.desc": "Wefiww cowe", + "command.say.usage": " ", + "command.say.desc": "Sends a message to chat", + "command.serverinfo.usage": "", + "command.serverinfo.desc": "Get system/bot info", + "command.stop.usage": "", + "command.stop.desc": "Westawt bot", + "command.template.usage": " [optionaw]", + "command.template.desc": "Does nyothing", + "command.verify.usage": " [args...]", + "command.verify.desc": "Check the hashing system", "command.about.author": "%s - a Minecwaft bot made by 77c8f4699b732c11 / a5a06d596f15c7db", "command.about.version": "Vewsion %s", "command.about.serverinfo": "To view system infowmation, wun the command \"serverinfo\".", "command.help.cmdList": "Commands: %s", "command.help.commandInfo": "%s%s - %s", + "command.serverinfo.os.android": "Andwoid", + "command.serverinfo.os.freebsd": "FweeBSD", + "command.serverinfo.os.linux": "Winux", + "command.serverinfo.os.macos": "macOS", + "command.serverinfo.os.macos_old": "OS X", + "command.serverinfo.os": "Opewating system", + "command.serverinfo.processor": "CPU", + "command.serverinfo.arch": "Awchitectuwe", + "command.serverinfo.osUsername": "Usewname", + "command.serverinfo.runTime": "Bot uptime", + "command.serverinfo.upTime": "System uptime", + "command.serverinfo.nodeVersion": "Node.js vewsion", + "command.serverinfo.osRelease": "Winux wewease", + "command.serverinfo.osRelease.missing": "/etc/os-release does nyot exist. Infowmation may be wimited.", + "command.serverinfo.os.android.version": "Andwoid vewsion", + "command.serverinfo.os.android.model": "Device modew", + "command.serverinfo.botName": "Bot nyame", + "command.serverinfo.botVer": "Bot vewsion", "command.error": "An ewwow occuwed (check consowe fow mowe info)", "command.disallowed.perms": "You do nyot have pewmission to wun this command. If you do have pewmission, pwease make suwe you put the command hash at the end, ow wan the command thwough youw cwient's hashing system.", "command.disallowed.perms.yourLevel": "Youw pewmission wevew: %s", - "command.disallowed.perms.cmdLevel": "Command wequiwes: %s" + "command.disallowed.perms.cmdLevel": "Command wequiwes: %s", + "copyText": "Cwick to copy!" } \ No newline at end of file From 1da0188303e182a7932a83b5a1e56f153782c4d6 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 22 Jul 2024 21:52:18 -0400 Subject: [PATCH 114/362] Fix console command bugs --- util/ConsoleCommand.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/util/ConsoleCommand.js b/util/ConsoleCommand.js index 4f068b3..3436a48 100644 --- a/util/ConsoleCommand.js +++ b/util/ConsoleCommand.js @@ -3,10 +3,11 @@ const index = require('../index.js') const { cmds } = require('../plugins/command.js'); const parse = require("../util/chatparse.js"); const settings = require("../settings.json"); +const lang=settings.defaultLang; class ConsoleCommand{ constructor (cmd,index2){ this.send = ()=>{}; //not needed for console - this.reply = text => process.stdout.write(parse(JSON.parse(text))[0]+'\n'); + this.reply = text => process.stdout.write(parse(text)[0]+'\n'); this.uuid = 'dde5a2a6-ebdd-4bbb-8eac-f75b10c10446_console'; //hard-coded because uuid does not exist at console this.username = 'Owner'; this.nickname = 'Console'; @@ -19,10 +20,18 @@ class ConsoleCommand{ //if(cmds[i].hidden) continue; helpCmds.push(i) } - console.log("Commands: "+helpCmds.join(" ")) + console.log(getMessage(lang,"command.help.cmdList",[helpCmds.join(" ")])) }, printCmdHelp:(uuid,cmd)=>{ - console.log(cmd+cmds[cmd].usage+" - "+cmds[cmd].desc); + let usage=getMessage(lang,`command.${cmd}.usage`); + let desc=getMessage(lang,`command.${cmd}.desc`); + if(cmds[cmd].usage){ + usage=cmds[cmd].usage; + } + if(cmds[cmd].desc){ + desc=cmds[cmd].desc; + } + console.log(getMessage(lang,"command.help.commandInfo",[cmd,usage,desc])); } }; //bot does not exist at console this.type = 'console'; From b75466a31c6b6d7aef0202d46f9aa854ad90979a Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 23 Jul 2024 11:32:15 -0400 Subject: [PATCH 115/362] Update Hebrew (Israel) :3 --- util/lang/he-IL.json | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/util/lang/he-IL.json b/util/lang/he-IL.json index 7295ba7..b7b330e 100644 --- a/util/lang/he-IL.json +++ b/util/lang/he-IL.json @@ -8,9 +8,9 @@ "command.help.usage": " [cmd]", "command.help.desc": "Shows command hewp", "command.logoff.usage": "", - "command.logoff.desc": "Disconnect and weconnect the bot fwom a sewvew", - "command.netmsg.usage": " ", - "command.netmsg.desc": "Send a message to aww sewvews the bot is connected to", + "command.logoff.desc": "Disconnyect and weconnyect the bot fwom a sewvew", + "command.nyetmsg.usage": " ", + "command.nyetmsg.desc": "Send a message to aww sewvews the bot is connyected to", "command.refill.usage": "", "command.refill.desc": "Wefiww cowe", "command.say.usage": " ", @@ -19,32 +19,32 @@ "command.serverinfo.desc": "Get system/bot info", "command.stop.usage": "", "command.stop.desc": "Westawt bot", - "command.template.usage": " [optionaw]", + "command.template.usage": " [optionyaw]", "command.template.desc": "Does nyothing", "command.verify.usage": " [args...]", "command.verify.desc": "Check the hashing system", - "command.about.author": "%s - a Minecwaft bot made by 77c8f4699b732c11 / a5a06d596f15c7db", + "command.about.author": "%s - a Minyecwaft bot made by 77c8f4699b732c11 / a5a06d596f15c7db", "command.about.version": "Vewsion %s", "command.about.serverinfo": "To view system infowmation, wun the command \"serverinfo\".", "command.help.cmdList": "Commands: %s", "command.help.commandInfo": "%s%s - %s", "command.serverinfo.os.android": "Andwoid", "command.serverinfo.os.freebsd": "FweeBSD", - "command.serverinfo.os.linux": "Winux", + "command.serverinfo.os.linyux": "Winyux", "command.serverinfo.os.macos": "macOS", "command.serverinfo.os.macos_old": "OS X", "command.serverinfo.os": "Opewating system", "command.serverinfo.processor": "CPU", "command.serverinfo.arch": "Awchitectuwe", - "command.serverinfo.osUsername": "Usewname", + "command.serverinfo.osUsernyame": "Usewnyame", "command.serverinfo.runTime": "Bot uptime", "command.serverinfo.upTime": "System uptime", - "command.serverinfo.nodeVersion": "Node.js vewsion", - "command.serverinfo.osRelease": "Winux wewease", + "command.serverinfo.nyodeVersion": "nyode.js vewsion", + "command.serverinfo.osRelease": "Winyux wewease", "command.serverinfo.osRelease.missing": "/etc/os-release does nyot exist. Infowmation may be wimited.", "command.serverinfo.os.android.version": "Andwoid vewsion", "command.serverinfo.os.android.model": "Device modew", - "command.serverinfo.botName": "Bot nyame", + "command.serverinfo.botnyame": "Bot nyame", "command.serverinfo.botVer": "Bot vewsion", "command.error": "An ewwow occuwed (check consowe fow mowe info)", "command.disallowed.perms": "You do nyot have pewmission to wun this command. If you do have pewmission, pwease make suwe you put the command hash at the end, ow wan the command thwough youw cwient's hashing system.", From 5a6b8924ab1598a9c655110a2ea8d25bae74dea5 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 23 Jul 2024 12:11:51 -0400 Subject: [PATCH 116/362] Fixed Hebrew (Israel) --- util/lang/he-IL.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/util/lang/he-IL.json b/util/lang/he-IL.json index b7b330e..a4b149d 100644 --- a/util/lang/he-IL.json +++ b/util/lang/he-IL.json @@ -9,8 +9,8 @@ "command.help.desc": "Shows command hewp", "command.logoff.usage": "", "command.logoff.desc": "Disconnyect and weconnyect the bot fwom a sewvew", - "command.nyetmsg.usage": " ", - "command.nyetmsg.desc": "Send a message to aww sewvews the bot is connyected to", + "command.netmsg.usage": " ", + "command.netmsg.desc": "Send a message to aww sewvews the bot is connyected to", "command.refill.usage": "", "command.refill.desc": "Wefiww cowe", "command.say.usage": " ", @@ -21,7 +21,7 @@ "command.stop.desc": "Westawt bot", "command.template.usage": " [optionyaw]", "command.template.desc": "Does nyothing", - "command.verify.usage": " [args...]", + "command.verify.usage": " [awgs...]", "command.verify.desc": "Check the hashing system", "command.about.author": "%s - a Minyecwaft bot made by 77c8f4699b732c11 / a5a06d596f15c7db", "command.about.version": "Vewsion %s", @@ -30,21 +30,21 @@ "command.help.commandInfo": "%s%s - %s", "command.serverinfo.os.android": "Andwoid", "command.serverinfo.os.freebsd": "FweeBSD", - "command.serverinfo.os.linyux": "Winyux", + "command.serverinfo.os.linux": "Winyux", "command.serverinfo.os.macos": "macOS", "command.serverinfo.os.macos_old": "OS X", "command.serverinfo.os": "Opewating system", "command.serverinfo.processor": "CPU", "command.serverinfo.arch": "Awchitectuwe", - "command.serverinfo.osUsernyame": "Usewnyame", + "command.serverinfo.osUsername": "Usewnyame", "command.serverinfo.runTime": "Bot uptime", "command.serverinfo.upTime": "System uptime", - "command.serverinfo.nyodeVersion": "nyode.js vewsion", + "command.serverinfo.nodeVersion": "Nyode.js vewsion", "command.serverinfo.osRelease": "Winyux wewease", "command.serverinfo.osRelease.missing": "/etc/os-release does nyot exist. Infowmation may be wimited.", "command.serverinfo.os.android.version": "Andwoid vewsion", "command.serverinfo.os.android.model": "Device modew", - "command.serverinfo.botnyame": "Bot nyame", + "command.serverinfo.botName": "Bot nyame", "command.serverinfo.botVer": "Bot vewsion", "command.error": "An ewwow occuwed (check consowe fow mowe info)", "command.disallowed.perms": "You do nyot have pewmission to wun this command. If you do have pewmission, pwease make suwe you put the command hash at the end, ow wan the command thwough youw cwient's hashing system.", From 03b57d398553a914ea75db9925dcdeb5edd30aec Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 23 Jul 2024 12:15:55 -0400 Subject: [PATCH 117/362] Fix help command at console --- util/ConsoleCommand.js | 1 + 1 file changed, 1 insertion(+) diff --git a/util/ConsoleCommand.js b/util/ConsoleCommand.js index 3436a48..8b96593 100644 --- a/util/ConsoleCommand.js +++ b/util/ConsoleCommand.js @@ -3,6 +3,7 @@ const index = require('../index.js') const { cmds } = require('../plugins/command.js'); const parse = require("../util/chatparse.js"); const settings = require("../settings.json"); +const getMessage = require('../../util/lang.js'); const lang=settings.defaultLang; class ConsoleCommand{ constructor (cmd,index2){ From 67a4a917baad1b3ba1711442d36b2863ee85cebf Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 23 Jul 2024 12:16:19 -0400 Subject: [PATCH 118/362] omagad sumung --- util/ConsoleCommand.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/ConsoleCommand.js b/util/ConsoleCommand.js index 8b96593..dbbc83f 100644 --- a/util/ConsoleCommand.js +++ b/util/ConsoleCommand.js @@ -3,7 +3,7 @@ const index = require('../index.js') const { cmds } = require('../plugins/command.js'); const parse = require("../util/chatparse.js"); const settings = require("../settings.json"); -const getMessage = require('../../util/lang.js'); +const getMessage = require('../util/lang.js'); const lang=settings.defaultLang; class ConsoleCommand{ constructor (cmd,index2){ From 9317491ebb4e45abc949eb0821615e094f852429 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 23 Jul 2024 13:15:31 -0400 Subject: [PATCH 119/362] Adding disabling of server If someone runs a spam bot or spam commandloop, this can be used to prevent the bot from logging in there --- index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/index.js b/index.js index 9839074..8e09996 100755 --- a/index.js +++ b/index.js @@ -34,6 +34,10 @@ const loadplug = (botno) => { loadplug() const createBot = function createBot(host,oldId){ + if(host.options.disabled){ + console.log(`Skipping server ${host.host}:${host.port}`) + return; + } const bot = new EventEmitter(); bot._client = m.createClient({ host: host.host, From feb07f1544a426a660810df7a99d48dd50970e02 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 23 Jul 2024 13:19:22 -0400 Subject: [PATCH 120/362] Improve the Read Me --- README.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 11e840c..724c3a8 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,20 @@ # botvX -The X is Roman Numeral for "10" because this is the 10th version, although it uses code from older versions down to version 6. +## Что это такое? + +botvX or UBot is a Minecraft bot for [Kaboom](https://kaboom.pw/) and its clones. It has many of the features that you would expect in a modern Kaboom bot: + +- commands (obviously) +- a self care system +- a command core, to run commands quickly + +## What does "botvX" mean? + +"botvX" means "bot version 10". The v is used to signify that whatever after it is a version, as was done with previous versions (botv4, botv6, botv8, botv9), and the X is the Roman numeral for 10, since this is the 10th major version. + +## What does "UBot" mean? + +"UBot" just means "UBot", but is based on an older bot name "UnnamedBot". On some older versions, this bot did not have a proper name. "UnnamedBot" was introduced in version 4, which was shortened to just "UBot" around version 8. + +## Command list + From e5fdff4724f78bc000a321452cc8ccf61dc52de6 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 23 Jul 2024 13:31:26 -0400 Subject: [PATCH 121/362] Update README.md --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index 724c3a8..0b01a71 100644 --- a/README.md +++ b/README.md @@ -18,3 +18,17 @@ botvX or UBot is a Minecraft bot for [Kaboom](https://kaboom.pw/) and its clones ## Command list +| Name | Usage | Description | +|-|-|-| +| about | | About the bot | +| cb | \ | Run a command in a command block | +| eval | \ | Run JavaScript code (must run through console)| +| help | [cmd] | Shows command help | +| logoff | | Disconnect and reconnect the bot from a server | +| netmsg | \ | Send a message to all servers the bot is connected to | +| refill | | Refill core | +| say | \ | Sends a message to chat | +| serverinfo | | Get system/bot info, similar to Kaboom's serverinfo command | +| stop | | Restart bot | +| template | | Used in development, does nothing | +| verify | | Check the hashing system | \ No newline at end of file From 0acd785a5cfc799a88f60e03f68e138b76d8a7ff Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 23 Jul 2024 15:15:15 -0400 Subject: [PATCH 122/362] Make "help command better --- plugins/command.js | 10 +++++++++- util/lang/en-US.json | 7 +++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/plugins/command.js b/plugins/command.js index 84a6200..44e9a33 100755 --- a/plugins/command.js +++ b/plugins/command.js @@ -61,7 +61,15 @@ module.exports={ if(cmds[cmd].desc){ desc=cmds[cmd].desc; } - b.tellraw(uuid,{"text":getMessage(lang,"command.help.commandInfo",[cmd,usage,desc])}); + //b.tellraw(uuid,{"text":getMessage(lang,"command.help.commandInfo",[cmd,usage,desc])}); + b.tellraw(uuid,{"text":getMessage(lang,"command.help.commandUsage",[cmd,usage,desc])}); + b.tellraw(uuid,{"text":getMessage(lang,"command.help.commandDesc",[desc])}); + const permsN=getMessage(lang,"command.help.permsNormal"); + const permsT=getMessage(lang,"command.help.permsTrusted"); + const permsO=getMessage(lang,"command.help.permsOwner"); + const permsC=getMessage(lang,"command.help.permsConsole"); + const rPerms=cmds[cmd].level?cmds[cmd].level:0; + b.tellraw(uuid,{"text":getMessage(lang,"command.help.commandPerms",[[permsN,permsT,permsO,permsC][rPerms]])}); } }, loadCMD:()=>{ diff --git a/util/lang/en-US.json b/util/lang/en-US.json index 9327394..926490c 100644 --- a/util/lang/en-US.json +++ b/util/lang/en-US.json @@ -28,6 +28,13 @@ "command.about.serverinfo": "To view system information, run the command \"serverinfo\".", "command.help.cmdList": "Commands: %s", "command.help.commandInfo": "%s%s - %s", + "command.help.commandUsage": "Usage - %s%s", + "command.help.commandDesc": "Description - %s", + "command.help.commandPerms": "Required permissions - %s", + "command.help.permsNormal": "Normal", + "command.help.permsTrusted": "Trusted", + "command.help.permsOwner": "Owner", + "command.help.permsConsole": "Console", "command.serverinfo.os.android": "Android", "command.serverinfo.os.freebsd": "FreeBSD", "command.serverinfo.os.linux": "Linux", From 9d9ed14d3021626cef59f51aec5d67f53218c35f Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 23 Jul 2024 15:18:38 -0400 Subject: [PATCH 123/362] Fix security issue --- plugins/command.js | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/command.js b/plugins/command.js index 44e9a33..b7b0f4a 100755 --- a/plugins/command.js +++ b/plugins/command.js @@ -89,6 +89,7 @@ module.exports={ execute:cmds[commandName].execute, desc:"Alias to "+commandName, usage:cmds[commandName].usage, + level:cmds[commandName].level, hidden:true, consoleIndex:cmds[commandName].consoleIndex }; From 437228729710100fd76fe522642efe6ec035eaf1 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 23 Jul 2024 15:19:41 -0400 Subject: [PATCH 124/362] Make console help better --- util/ConsoleCommand.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/util/ConsoleCommand.js b/util/ConsoleCommand.js index dbbc83f..6ab86f6 100644 --- a/util/ConsoleCommand.js +++ b/util/ConsoleCommand.js @@ -32,7 +32,14 @@ class ConsoleCommand{ if(cmds[cmd].desc){ desc=cmds[cmd].desc; } - console.log(getMessage(lang,"command.help.commandInfo",[cmd,usage,desc])); + console.log({"text":getMessage(lang,"command.help.commandUsage",[cmd,usage,desc])}); + console.log({"text":getMessage(lang,"command.help.commandDesc",[desc])}); + const permsN=getMessage(lang,"command.help.permsNormal"); + const permsT=getMessage(lang,"command.help.permsTrusted"); + const permsO=getMessage(lang,"command.help.permsOwner"); + const permsC=getMessage(lang,"command.help.permsConsole"); + const rPerms=cmds[cmd].level?cmds[cmd].level:0; + console.log({"text":getMessage(lang,"command.help.commandPerms",[[permsN,permsT,permsO,permsC][rPerms]])}); } }; //bot does not exist at console this.type = 'console'; From 205893aeefd2f9506246f56a2c78fe1fb3441c86 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 23 Jul 2024 15:21:48 -0400 Subject: [PATCH 125/362] Hebrew (Israel) --- util/lang/he-IL.json | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/util/lang/he-IL.json b/util/lang/he-IL.json index a4b149d..2fb908e 100644 --- a/util/lang/he-IL.json +++ b/util/lang/he-IL.json @@ -28,6 +28,13 @@ "command.about.serverinfo": "To view system infowmation, wun the command \"serverinfo\".", "command.help.cmdList": "Commands: %s", "command.help.commandInfo": "%s%s - %s", + "command.help.commandUsage": "Usage - %s%s", + "command.help.commandDesc": "Descwiption - %s", + "command.help.commandPerms": "Wequiwed pewmissions - %s", + "command.help.permsNormal": "Nyowmaw", + "command.help.permsTrusted": "Twusted", + "command.help.permsOwner": "Ownyew", + "command.help.permsConsole": "Consowe", "command.serverinfo.os.android": "Andwoid", "command.serverinfo.os.freebsd": "FweeBSD", "command.serverinfo.os.linux": "Winyux", From 60adce489195a4b6c8b9700c7a4a4cfba3f1dc60 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 23 Jul 2024 15:50:55 -0400 Subject: [PATCH 126/362] Fix tellraw --- plugins/commandblock.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/commandblock.js b/plugins/commandblock.js index ba492b3..36f4d8a 100755 --- a/plugins/commandblock.js +++ b/plugins/commandblock.js @@ -98,7 +98,7 @@ module.exports = { } else { finalname = uuid } - b.ccq.push(`/tellraw ${finalname} ${JSON.stringify(message)}`) + b.ccq.push(`/minecraft:tellraw ${finalname} ${JSON.stringify(message)}`) } } } From 9817191d27619e23d30ea3a754259ed29c5d2497 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 23 Jul 2024 16:38:57 -0400 Subject: [PATCH 127/362] Fix command rate limit --- plugins/command.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/plugins/command.js b/plugins/command.js index b7b0f4a..bd2c950 100755 --- a/plugins/command.js +++ b/plugins/command.js @@ -13,10 +13,8 @@ module.exports={ b.lastCmd=0; b.runCommand=(name, uuid, text, prefix)=>{ if(uuid=="00000000-0000-0000-0000-000000000000") return; - if(Date.now-b.lastCmd<=1000){ - console.log("Executed too early, "+(Date.now-b.lastCmd)+"ms left"); - return; - } + if(Date.now()-b.lastCmd<=1000) return; + b.lastCmd=Date.now(); const cmd=text.split(" "); let lang=settings.defaultLang; let verify=hashcheck(cmd); From 551e77e7df1a4a89db3684162fe3bffffa23c771 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 23 Jul 2024 16:57:47 -0400 Subject: [PATCH 128/362] Allow multiple usages for e.g. subcommands --- plugins/command.js | 6 ++++-- util/ConsoleCommand.js | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/plugins/command.js b/plugins/command.js index bd2c950..5550b50 100755 --- a/plugins/command.js +++ b/plugins/command.js @@ -54,13 +54,15 @@ module.exports={ let usage=getMessage(lang,`command.${cmd}.usage`); let desc=getMessage(lang,`command.${cmd}.desc`); if(cmds[cmd].usage){ - usage=cmds[cmd].usage; + usage=cmds[cmd].usage.split("||"); } if(cmds[cmd].desc){ desc=cmds[cmd].desc; } //b.tellraw(uuid,{"text":getMessage(lang,"command.help.commandInfo",[cmd,usage,desc])}); - b.tellraw(uuid,{"text":getMessage(lang,"command.help.commandUsage",[cmd,usage,desc])}); + for(const i in usage){ + b.tellraw(uuid,{"text":getMessage(lang,"command.help.commandUsage",[cmd,usage[i]])}); + } b.tellraw(uuid,{"text":getMessage(lang,"command.help.commandDesc",[desc])}); const permsN=getMessage(lang,"command.help.permsNormal"); const permsT=getMessage(lang,"command.help.permsTrusted"); diff --git a/util/ConsoleCommand.js b/util/ConsoleCommand.js index 6ab86f6..fcd3db8 100644 --- a/util/ConsoleCommand.js +++ b/util/ConsoleCommand.js @@ -27,12 +27,14 @@ class ConsoleCommand{ let usage=getMessage(lang,`command.${cmd}.usage`); let desc=getMessage(lang,`command.${cmd}.desc`); if(cmds[cmd].usage){ - usage=cmds[cmd].usage; + usage=cmds[cmd].usage.split("||"); } if(cmds[cmd].desc){ desc=cmds[cmd].desc; } - console.log({"text":getMessage(lang,"command.help.commandUsage",[cmd,usage,desc])}); + for(const i in usage){ + console.log({"text":getMessage(lang,"command.help.commandUsage",[cmd,usage[i]])}); + } console.log({"text":getMessage(lang,"command.help.commandDesc",[desc])}); const permsN=getMessage(lang,"command.help.permsNormal"); const permsT=getMessage(lang,"command.help.permsTrusted"); From 6e28176bda23201d534d4677a06f9a02c60f9078 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 23 Jul 2024 17:18:48 -0400 Subject: [PATCH 129/362] Fix help command --- plugins/command.js | 2 +- util/ConsoleCommand.js | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/command.js b/plugins/command.js index 5550b50..c9e13ea 100755 --- a/plugins/command.js +++ b/plugins/command.js @@ -51,7 +51,7 @@ module.exports={ b.tellraw(uuid,{"text":getMessage(lang,"command.help.cmdList",[helpCmds.join(" ")])}); } b.printCmdHelp=(uuid,cmd,lang)=>{ - let usage=getMessage(lang,`command.${cmd}.usage`); + let usage=getMessage(lang,`command.${cmd}.usage`).split("||"); let desc=getMessage(lang,`command.${cmd}.desc`); if(cmds[cmd].usage){ usage=cmds[cmd].usage.split("||"); diff --git a/util/ConsoleCommand.js b/util/ConsoleCommand.js index fcd3db8..aa35b84 100644 --- a/util/ConsoleCommand.js +++ b/util/ConsoleCommand.js @@ -24,7 +24,7 @@ class ConsoleCommand{ console.log(getMessage(lang,"command.help.cmdList",[helpCmds.join(" ")])) }, printCmdHelp:(uuid,cmd)=>{ - let usage=getMessage(lang,`command.${cmd}.usage`); + let usage=getMessage(lang,`command.${cmd}.usage`).split("||"); let desc=getMessage(lang,`command.${cmd}.desc`); if(cmds[cmd].usage){ usage=cmds[cmd].usage.split("||"); @@ -33,15 +33,15 @@ class ConsoleCommand{ desc=cmds[cmd].desc; } for(const i in usage){ - console.log({"text":getMessage(lang,"command.help.commandUsage",[cmd,usage[i]])}); + console.log(getMessage(lang,"command.help.commandUsage",[cmd,usage[i]])); } - console.log({"text":getMessage(lang,"command.help.commandDesc",[desc])}); + console.log(getMessage(lang,"command.help.commandDesc",[desc])); const permsN=getMessage(lang,"command.help.permsNormal"); const permsT=getMessage(lang,"command.help.permsTrusted"); const permsO=getMessage(lang,"command.help.permsOwner"); const permsC=getMessage(lang,"command.help.permsConsole"); const rPerms=cmds[cmd].level?cmds[cmd].level:0; - console.log({"text":getMessage(lang,"command.help.commandPerms",[[permsN,permsT,permsO,permsC][rPerms]])}); + console.log(getMessage(lang,"command.help.commandPerms",[[permsN,permsT,permsO,permsC][rPerms]])); } }; //bot does not exist at console this.type = 'console'; From b49427cab79b82fc2b5a714532e750d1ba6255bf Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 23 Jul 2024 17:18:55 -0400 Subject: [PATCH 130/362] Add cloop command --- README.md | 1 + plugins/commands/cloop.js | 36 ++++++++++++++++++++++++++++++++++++ util/lang/en-US.json | 7 +++++++ util/lang/he-IL.json | 7 +++++++ 4 files changed, 51 insertions(+) create mode 100644 plugins/commands/cloop.js diff --git a/README.md b/README.md index 0b01a71..31c30e6 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ botvX or UBot is a Minecraft bot for [Kaboom](https://kaboom.pw/) and its clones |-|-|-| | about | | About the bot | | cb | \ | Run a command in a command block | +| cb | add , remove , list, clear | Run a command in a command block | | eval | \ | Run JavaScript code (must run through console)| | help | [cmd] | Shows command help | | logoff | | Disconnect and reconnect the bot from a server | diff --git a/plugins/commands/cloop.js b/plugins/commands/cloop.js new file mode 100644 index 0000000..c087c55 --- /dev/null +++ b/plugins/commands/cloop.js @@ -0,0 +1,36 @@ +const getMessage = require('../../util/lang.js') +module.exports={ + execute: (c)=>{ + const subcmd=c.args.splice(0,1)[0]; + switch(subcmd){ + case "add": + const rate=+(c.args.splice(0,1)[0]); + const command=c.args.join(" "); + if(rate<20){ + c.reply({text:getMessage(c.lang,"command.cloop.error.tooShort")}) + } + c.bot.addCloop(command,rate) + c.reply({text:getMessage(c.lang,"command.cloop.success.add",[command,rate+""])}) + break + case "remove": + const index=+c.args[0]; + c.bot.removeCloop(c.args[0]); + c.reply({text:getMessage(c.lang,"command.cloop.success.remove",[index+""])}) + break + case "list": + for(const i in c.bot.cloops){ + c.reply({text:getMessage(c.lang,"command.cloop.list",[i,c.bot.cloops[i].command,c.bot.cloops[i].rate+""])}) + } + break + case "clear": + c.bot.clearCloops(); + c.reply({text:getMessage(c.lang,"command.cloop.success.clear")}) + break + default: + c.reply(`Unknown subcommand, please do ${c.prefix}help cloop`) + } + }, + hidden: true, + consoleIndex: true, + level: 1 +} diff --git a/util/lang/en-US.json b/util/lang/en-US.json index 926490c..fa5dae3 100644 --- a/util/lang/en-US.json +++ b/util/lang/en-US.json @@ -3,6 +3,8 @@ "command.about.desc": "About the bot", "command.cb.usage": " ", "command.cb.desc": "Run a command in a command block", + "command.cloop.usage": " add || remove || list|| clear", + "command.cloop.desc": "Manage command loops", "command.eval.usage": " ", "command.eval.desc": "Run JavaScript code", "command.help.usage": " [cmd]", @@ -26,6 +28,11 @@ "command.about.author": "%s - a Minecraft bot made by 77c8f4699b732c11 / a5a06d596f15c7db", "command.about.version": "Version %s", "command.about.serverinfo": "To view system information, run the command \"serverinfo\".", + "command.cloop.error.tooShort": "Command loops must have a rate above 20ms.", + "command.cloop.success.add": "Added command loop with command %s and rate %s", + "command.cloop.success.remove": "Removed command loop %s", + "command.cloop.success.clear": "Cleared all command loops", + "command.cloop.list": "%s: Command: %s Rate: %s", "command.help.cmdList": "Commands: %s", "command.help.commandInfo": "%s%s - %s", "command.help.commandUsage": "Usage - %s%s", diff --git a/util/lang/he-IL.json b/util/lang/he-IL.json index 2fb908e..8dbeb00 100644 --- a/util/lang/he-IL.json +++ b/util/lang/he-IL.json @@ -3,6 +3,8 @@ "command.about.desc": "About the bot", "command.cb.usage": " ", "command.cb.desc": "Wun a command in a command bwock", + "command.cloop.usage": " add || remove || list|| clear", + "command.cloop.desc": "Manage command woops", "command.eval.usage": " ", "command.eval.desc": "Wun JavaScwipt code", "command.help.usage": " [cmd]", @@ -26,6 +28,11 @@ "command.about.author": "%s - a Minyecwaft bot made by 77c8f4699b732c11 / a5a06d596f15c7db", "command.about.version": "Vewsion %s", "command.about.serverinfo": "To view system infowmation, wun the command \"serverinfo\".", + "command.cloop.error.tooShort": "Command woops must have a wate above 20ms.", + "command.cloop.success.add": "Added command woop with command %s and wate %s", + "command.cloop.success.remove": "Wemoved command woop %s", + "command.cloop.success.clear": "Cweawed aww command woops", + "command.cloop.list": "%s: Command: %s Rate: %s", "command.help.cmdList": "Commands: %s", "command.help.commandInfo": "%s%s - %s", "command.help.commandUsage": "Usage - %s%s", From f418b7ddf7ff6dc3c7a83688d8c7bd820b3517ff Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 23 Jul 2024 18:26:00 -0400 Subject: [PATCH 131/362] Fix serverinfo CPU on some Android devices --- plugins/commands/serverinfo.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/commands/serverinfo.js b/plugins/commands/serverinfo.js index 7c73f97..8fa484d 100755 --- a/plugins/commands/serverinfo.js +++ b/plugins/commands/serverinfo.js @@ -50,7 +50,7 @@ const os2 = function (o2,l) { module.exports = { execute: function (c) { c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.os"), os2(process.platform,c.lang))) - c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.processor"), os.cpus()[0].model)) + if(os.cpus()[0]) c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.processor"), os.cpus()[0].model)) c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.arch"), os.machine())) c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.osUsername"), os.userInfo().username)) c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.runTime"), timeformat(process.uptime() * 1000))) From 4462b116539462b1316793e43ce10970539c70ec Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 23 Jul 2024 18:31:26 -0400 Subject: [PATCH 132/362] Fix serverinfo on Android --- plugins/commands/serverinfo.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/commands/serverinfo.js b/plugins/commands/serverinfo.js index 8fa484d..1af159c 100755 --- a/plugins/commands/serverinfo.js +++ b/plugins/commands/serverinfo.js @@ -78,7 +78,7 @@ module.exports = { c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.os.android.version"), android_version, 'green')) const dModel=cp.execSync('getprop ro.product.model').toString('UTF-8').split('\n')[0]; const dBrand=cp.execSync('getprop ro.product.brand').toString('UTF-8').split('\n')[0]; - c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.os.android.model"), dBrand+dModel, 'green')) + c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.os.android.model"), dBrand+" "+dModel, 'green')) } c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.botName"), settings.name, 'yellow')) c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.botVer"), version.bot, 'yellow')) From 8ce1068babf60b1152ede56c14badb9cf282cb3c Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 23 Jul 2024 18:56:52 -0400 Subject: [PATCH 133/362] Update packages --- package-lock.json | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index d26f89a..7646b65 100755 --- a/package-lock.json +++ b/package-lock.json @@ -14,21 +14,21 @@ } }, "node_modules/@azure/msal-common": { - "version": "14.13.1", - "resolved": "https://registry.npmjs.org/@azure/msal-common/-/msal-common-14.13.1.tgz", - "integrity": "sha512-iUp3BYrsRZ4X3EiaZ2fDjNFjmtYMv9rEQd6c1op6ULn0HWk4ACvDmosL6NaBgWOhl1BAblIbd9vmB5/ilF8d4A==", + "version": "14.14.0", + "resolved": "https://registry.npmjs.org/@azure/msal-common/-/msal-common-14.14.0.tgz", + "integrity": "sha512-OxcOk9H1/1fktHh6//VCORgSNJc2dCQObTm6JNmL824Z6iZSO6eFo/Bttxe0hETn9B+cr7gDouTQtsRq3YPuSQ==", "license": "MIT", "engines": { "node": ">=0.8.0" } }, "node_modules/@azure/msal-node": { - "version": "2.11.1", - "resolved": "https://registry.npmjs.org/@azure/msal-node/-/msal-node-2.11.1.tgz", - "integrity": "sha512-8ECtug4RL+zsgh20VL8KYHjrRO3MJOeAKEPRXT2lwtiu5U3BdyIdBb50+QZthEkIi60K6pc/pdOx/k5Jp4sLng==", + "version": "2.12.0", + "resolved": "https://registry.npmjs.org/@azure/msal-node/-/msal-node-2.12.0.tgz", + "integrity": "sha512-jmk5Im5KujRA2AcyCb0awA3buV8niSrwXZs+NBJWIvxOz76RvNlusGIqi43A0h45BPUy93Qb+CPdpJn82NFTIg==", "license": "MIT", "dependencies": { - "@azure/msal-common": "14.13.1", + "@azure/msal-common": "14.14.0", "jsonwebtoken": "^9.0.0", "uuid": "^8.3.0" }, @@ -37,9 +37,9 @@ } }, "node_modules/@types/node": { - "version": "20.14.11", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.11.tgz", - "integrity": "sha512-kprQpL8MMeszbz6ojB5/tU8PLN4kesnN8Gjzw349rDlNgsSzg90lAVj3llK99Dh7JON+t9AuscPPFW6mPbTnSA==", + "version": "20.14.12", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.12.tgz", + "integrity": "sha512-r7wNXakLeSsGT0H1AU863vS2wa5wBOK4bWMjZz2wj+8nBx+m5PeIn0k8AloSLpRuiwdRQZwarZqHE4FNArPuJQ==", "license": "MIT", "dependencies": { "undici-types": "~5.26.4" From 78815ee72a86548647e224049a26d9da59617905 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Wed, 24 Jul 2024 01:13:24 -0400 Subject: [PATCH 134/362] Add no command message to "help (command) --- plugins/command.js | 12 ++++++++---- util/lang/en-US.json | 1 + util/lang/he-IL.json | 1 + 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/plugins/command.js b/plugins/command.js index c9e13ea..db96eb6 100755 --- a/plugins/command.js +++ b/plugins/command.js @@ -48,9 +48,13 @@ module.exports={ if(cmds[i].hidden) continue; helpCmds.push(prefix+i) } - b.tellraw(uuid,{"text":getMessage(lang,"command.help.cmdList",[helpCmds.join(" ")])}); + b.tellraw(uuid,{text:getMessage(lang,"command.help.cmdList",[helpCmds.join(" ")])}); } b.printCmdHelp=(uuid,cmd,lang)=>{ + if(!cmds[cmd]){ + b.tellraw(uuid,{text:getMessage(lang,"command.help.noCommand")}); + return; + } let usage=getMessage(lang,`command.${cmd}.usage`).split("||"); let desc=getMessage(lang,`command.${cmd}.desc`); if(cmds[cmd].usage){ @@ -61,15 +65,15 @@ module.exports={ } //b.tellraw(uuid,{"text":getMessage(lang,"command.help.commandInfo",[cmd,usage,desc])}); for(const i in usage){ - b.tellraw(uuid,{"text":getMessage(lang,"command.help.commandUsage",[cmd,usage[i]])}); + b.tellraw(uuid,{text:getMessage(lang,"command.help.commandUsage",[cmd,usage[i]])}); } - b.tellraw(uuid,{"text":getMessage(lang,"command.help.commandDesc",[desc])}); + b.tellraw(uuid,{text:getMessage(lang,"command.help.commandDesc",[desc])}); const permsN=getMessage(lang,"command.help.permsNormal"); const permsT=getMessage(lang,"command.help.permsTrusted"); const permsO=getMessage(lang,"command.help.permsOwner"); const permsC=getMessage(lang,"command.help.permsConsole"); const rPerms=cmds[cmd].level?cmds[cmd].level:0; - b.tellraw(uuid,{"text":getMessage(lang,"command.help.commandPerms",[[permsN,permsT,permsO,permsC][rPerms]])}); + b.tellraw(uuid,{text:getMessage(lang,"command.help.commandPerms",[[permsN,permsT,permsO,permsC][rPerms]])}); } }, loadCMD:()=>{ diff --git a/util/lang/en-US.json b/util/lang/en-US.json index fa5dae3..cc7a5bb 100644 --- a/util/lang/en-US.json +++ b/util/lang/en-US.json @@ -42,6 +42,7 @@ "command.help.permsTrusted": "Trusted", "command.help.permsOwner": "Owner", "command.help.permsConsole": "Console", + "command.help.noCommand": "Command does not exist", "command.serverinfo.os.android": "Android", "command.serverinfo.os.freebsd": "FreeBSD", "command.serverinfo.os.linux": "Linux", diff --git a/util/lang/he-IL.json b/util/lang/he-IL.json index 8dbeb00..bb97c10 100644 --- a/util/lang/he-IL.json +++ b/util/lang/he-IL.json @@ -42,6 +42,7 @@ "command.help.permsTrusted": "Twusted", "command.help.permsOwner": "Ownyew", "command.help.permsConsole": "Consowe", + "command.help.noCommand": "Command does nyot exist", "command.serverinfo.os.android": "Andwoid", "command.serverinfo.os.freebsd": "FweeBSD", "command.serverinfo.os.linux": "Winyux", From d9a04f0e330a8d85ac727e9a05627503d34fd965 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Wed, 24 Jul 2024 01:14:04 -0400 Subject: [PATCH 135/362] Add hostname to server info --- plugins/commands/serverinfo.js | 1 + util/lang/en-US.json | 1 + util/lang/he-IL.json | 1 + 3 files changed, 3 insertions(+) diff --git a/plugins/commands/serverinfo.js b/plugins/commands/serverinfo.js index 1af159c..e06e74d 100755 --- a/plugins/commands/serverinfo.js +++ b/plugins/commands/serverinfo.js @@ -53,6 +53,7 @@ module.exports = { if(os.cpus()[0]) c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.processor"), os.cpus()[0].model)) c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.arch"), os.machine())) c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.osUsername"), os.userInfo().username)) + c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.hostName"), os.hostname())) c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.runTime"), timeformat(process.uptime() * 1000))) c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.upTime"), timeformat(os.uptime() * 1000))) c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.nodeVersion"), process.version)) diff --git a/util/lang/en-US.json b/util/lang/en-US.json index cc7a5bb..88c854b 100644 --- a/util/lang/en-US.json +++ b/util/lang/en-US.json @@ -52,6 +52,7 @@ "command.serverinfo.processor": "CPU", "command.serverinfo.arch": "Architecture", "command.serverinfo.osUsername": "Username", + "command.serverinfo.hostName": "Hostname", "command.serverinfo.runTime": "Bot uptime", "command.serverinfo.upTime": "System uptime", "command.serverinfo.nodeVersion": "Node.js version", diff --git a/util/lang/he-IL.json b/util/lang/he-IL.json index bb97c10..c087dac 100644 --- a/util/lang/he-IL.json +++ b/util/lang/he-IL.json @@ -52,6 +52,7 @@ "command.serverinfo.processor": "CPU", "command.serverinfo.arch": "Awchitectuwe", "command.serverinfo.osUsername": "Usewnyame", + "command.serverinfo.hostName": "Hostnyame", "command.serverinfo.runTime": "Bot uptime", "command.serverinfo.upTime": "System uptime", "command.serverinfo.nodeVersion": "Nyode.js vewsion", From a323d257fe199e85a157c8fd4cad070768e0fe75 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Wed, 24 Jul 2024 01:25:25 -0400 Subject: [PATCH 136/362] Add Working directory to Server Info --- plugins/commands/serverinfo.js | 1 + util/lang/en-US.json | 1 + util/lang/he-IL.json | 1 + 3 files changed, 3 insertions(+) diff --git a/plugins/commands/serverinfo.js b/plugins/commands/serverinfo.js index e06e74d..a3f6272 100755 --- a/plugins/commands/serverinfo.js +++ b/plugins/commands/serverinfo.js @@ -54,6 +54,7 @@ module.exports = { c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.arch"), os.machine())) c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.osUsername"), os.userInfo().username)) c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.hostName"), os.hostname())) + c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.workingDir"), process.cwd())) c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.runTime"), timeformat(process.uptime() * 1000))) c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.upTime"), timeformat(os.uptime() * 1000))) c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.nodeVersion"), process.version)) diff --git a/util/lang/en-US.json b/util/lang/en-US.json index 88c854b..f3fc87a 100644 --- a/util/lang/en-US.json +++ b/util/lang/en-US.json @@ -53,6 +53,7 @@ "command.serverinfo.arch": "Architecture", "command.serverinfo.osUsername": "Username", "command.serverinfo.hostName": "Hostname", + "command.serverinfo.workingDir": "Working directory", "command.serverinfo.runTime": "Bot uptime", "command.serverinfo.upTime": "System uptime", "command.serverinfo.nodeVersion": "Node.js version", diff --git a/util/lang/he-IL.json b/util/lang/he-IL.json index c087dac..5b251be 100644 --- a/util/lang/he-IL.json +++ b/util/lang/he-IL.json @@ -53,6 +53,7 @@ "command.serverinfo.arch": "Awchitectuwe", "command.serverinfo.osUsername": "Usewnyame", "command.serverinfo.hostName": "Hostnyame", + "command.serverinfo.workingDir": "Wowking diwectowy", "command.serverinfo.runTime": "Bot uptime", "command.serverinfo.upTime": "System uptime", "command.serverinfo.nodeVersion": "Nyode.js vewsion", From fe5226537f1f4178b89a6affdec600a432ce5e3b Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Wed, 24 Jul 2024 01:59:19 -0400 Subject: [PATCH 137/362] Remove code from testing plugin --- plugins/testing.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/testing.js b/plugins/testing.js index 8c4c82d..6248ffa 100755 --- a/plugins/testing.js +++ b/plugins/testing.js @@ -1,8 +1,8 @@ module.exports={ load:()=>{ - console.log("Loaded on global") + }, loadBot:(b)=>{ - console.log(`Loaded on bot ${b.id}`) + } } \ No newline at end of file From df229dd04a5bfdbe570e2bf78b93d2386fa01a94 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Wed, 24 Jul 2024 02:07:48 -0400 Subject: [PATCH 138/362] Fixed readme error --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 31c30e6..b4143dd 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ botvX or UBot is a Minecraft bot for [Kaboom](https://kaboom.pw/) and its clones |-|-|-| | about | | About the bot | | cb | \ | Run a command in a command block | -| cb | add , remove , list, clear | Run a command in a command block | +| cloop | add , remove , list, clear | Run a command in a command block | | eval | \ | Run JavaScript code (must run through console)| | help | [cmd] | Shows command help | | logoff | | Disconnect and reconnect the bot from a server | From 7dc08ff81a319880959330f4b3d035db3ed515fb Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Wed, 24 Jul 2024 02:08:45 -0400 Subject: [PATCH 139/362] Fixing the readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b4143dd..33ad40c 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ botvX or UBot is a Minecraft bot for [Kaboom](https://kaboom.pw/) and its clones |-|-|-| | about | | About the bot | | cb | \ | Run a command in a command block | -| cloop | add , remove , list, clear | Run a command in a command block | +| cloop | add , remove , list, clear | Manage command loops | | eval | \ | Run JavaScript code (must run through console)| | help | [cmd] | Shows command help | | logoff | | Disconnect and reconnect the bot from a server | From 13cfdc834c9eedd244d98d6e2509a4d5d0864ed4 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Wed, 24 Jul 2024 02:40:20 -0400 Subject: [PATCH 140/362] Beta! --- version.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.json b/version.json index e8da65f..3e28bfe 100644 --- a/version.json +++ b/version.json @@ -1,3 +1,3 @@ { - "bot": "10.0.0-alpha.8" + "bot": "10.0.0-beta.1 (development version)" } \ No newline at end of file From a971d88ed401b9992e21986dbb4fb0a0e85903af Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Wed, 24 Jul 2024 02:55:10 -0400 Subject: [PATCH 141/362] Make about and serverinfo show Git commit --- plugins/commands/about.js | 12 +++++++++++- plugins/commands/serverinfo.js | 12 +++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/plugins/commands/about.js b/plugins/commands/about.js index d46ad87..7a23ea1 100644 --- a/plugins/commands/about.js +++ b/plugins/commands/about.js @@ -5,7 +5,17 @@ module.exports = { execute: function (c) { c.reply({text:getMessage(c.lang,"command.about.author",[settings.name])}); c.reply({text:""}); - c.reply({text:getMessage(c.lang,"command.about.version",[version.bot])}); + let botVersion=version.bot; + let gitCommit; + try { + gitCommit = cp.execSync('git rev-parse --short HEAD').toString('UTF-8').split('\n')[0]; + } catch(e){ + gitCommit = false + } + if(gitCommit){ + botVersion+=` (${gitCommit})` + } + c.reply({text:getMessage(c.lang,"command.about.version",[botVersion])}); c.reply({text:""}); c.reply({text:getMessage(c.lang,"command.about.serverinfo")}) }, diff --git a/plugins/commands/serverinfo.js b/plugins/commands/serverinfo.js index a3f6272..91a2b23 100755 --- a/plugins/commands/serverinfo.js +++ b/plugins/commands/serverinfo.js @@ -83,6 +83,16 @@ module.exports = { c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.os.android.model"), dBrand+" "+dModel, 'green')) } c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.botName"), settings.name, 'yellow')) - c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.botVer"), version.bot, 'yellow')) + let botVersion=version.bot; + let gitCommit; + try { + gitCommit = cp.execSync('git rev-parse --short HEAD').toString('UTF-8').split('\n')[0]; + } catch(e){ + gitCommit = false + } + if(gitCommit){ + botVersion+=` (${gitCommit})` + } + c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.botVer"), botVersion, 'yellow')) } } From 1c3b9c0643ebe0b4bb8d8427f2d56f4b59cfc755 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Wed, 24 Jul 2024 02:55:34 -0400 Subject: [PATCH 142/362] Change version number --- version.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.json b/version.json index 3e28bfe..68cdaa4 100644 --- a/version.json +++ b/version.json @@ -1,3 +1,3 @@ { - "bot": "10.0.0-beta.1 (development version)" + "bot": "10.0.0-beta.1" } \ No newline at end of file From 7995122660e676334f5f43a68e60c2795c74af48 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Wed, 24 Jul 2024 02:57:33 -0400 Subject: [PATCH 143/362] Fix about command --- plugins/commands/about.js | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/commands/about.js b/plugins/commands/about.js index 7a23ea1..23cc88d 100644 --- a/plugins/commands/about.js +++ b/plugins/commands/about.js @@ -1,6 +1,7 @@ const version = require("../../version.json") const settings = require('../../settings.json') const getMessage = require('../../util/lang.js') +const cp = require('child_process') module.exports = { execute: function (c) { c.reply({text:getMessage(c.lang,"command.about.author",[settings.name])}); From 87ed9ba01ecc75d8411a8b017510ba9295608a07 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Wed, 24 Jul 2024 04:07:33 -0400 Subject: [PATCH 144/362] Say command bugfix --- plugins/commands/say.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/commands/say.js b/plugins/commands/say.js index 44644ca..1a030c7 100644 --- a/plugins/commands/say.js +++ b/plugins/commands/say.js @@ -1,6 +1,6 @@ module.exports={ execute: (c)=>{ - if(c.args[0].startsWith("/") && !c.verify<1) return; + if(c.args[0].startsWith("/") && c.verify<1) return; c.bot.chat(c.args.join(" ")) }, hidden: true, From 679b24f1a9ad864c545df2bdf099b165e70dc48c Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Wed, 24 Jul 2024 04:08:46 -0400 Subject: [PATCH 145/362] Say command bugfix --- plugins/commands/say.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/commands/say.js b/plugins/commands/say.js index 44644ca..1a030c7 100644 --- a/plugins/commands/say.js +++ b/plugins/commands/say.js @@ -1,6 +1,6 @@ module.exports={ execute: (c)=>{ - if(c.args[0].startsWith("/") && !c.verify<1) return; + if(c.args[0].startsWith("/") && c.verify<1) return; c.bot.chat(c.args.join(" ")) }, hidden: true, From 3f5002934917da87ff241b779cb03d15abd1e00a Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Wed, 24 Jul 2024 06:06:54 -0400 Subject: [PATCH 146/362] Change core name --- plugins/commandblock.js | 6 +++--- plugins/commands/refill.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/commandblock.js b/plugins/commandblock.js index 36f4d8a..ea049fd 100755 --- a/plugins/commandblock.js +++ b/plugins/commandblock.js @@ -6,7 +6,7 @@ module.exports = { }, loadBot: function (b) { - b.interval.commandFill = setInterval(() => { b.chat(`/fill ~ 20 ~ ~3 25 ~3 command_block{CustomName:'{"translate":"pack.dropConfirm","color":"#FFAAFF"}'}`) }, 60000) + b.interval.commandFill = setInterval(() => { b.chat(`/fill ~ 20 ~ ~3 25 ~3 command_block{CustomName:'{"translate":"%s %s","with":[{"translate":"entity.minecraft.ender_dragon"},{"translate":"language.region"}],"color":"#FFAAEE"}'}`) }, 60000) b.ccq = [] b.blocknoX = 0 b.blocknoZ = 0 @@ -52,7 +52,7 @@ module.exports = { b.ccq.splice(0, 1) } b._client.on("login",()=>{ - b.chat(`/fill ~ 20 ~ ~3 25 ~3 command_block{CustomName:'{"translate":"pack.dropConfirm","color":"#FFAAFF"}'}`) + b.chat(`/fill ~ 20 ~ ~3 25 ~3 command_block{CustomName:'{"translate":"%s %s","with":[{"translate":"entity.minecraft.ender_dragon"},{"translate":"language.region"}],"color":"#FFAAEE"}'}`) }) b.on('ccstart', () => { setTimeout(() => { b.interval.ccqi = setInterval(b.advanceccq, 3) }, 1000) // 1 Second and 3 Milliseconds @@ -73,7 +73,7 @@ module.exports = { if (a.x != b.original_pos.x || a.z != b.original_pos.z) { b.original_pos = { x: a.x, y: a.y, z: a.z } b.pos.correct = 0 - b.chat(`/fill ~ 20 ~ ~3 25 ~3 command_block{CustomName:'{"translate":"pack.dropConfirm","color":"#FFAAFF"}'}`) + b.chat(`/fill ~ 20 ~ ~3 25 ~3 command_block{CustomName:'{"translate":"%s %s","with":[{"translate":"entity.minecraft.ender_dragon"},{"translate":"language.region"}],"color":"#FFAAEE"}'}`) } } diff --git a/plugins/commands/refill.js b/plugins/commands/refill.js index e8fbb29..d80ad1b 100644 --- a/plugins/commands/refill.js +++ b/plugins/commands/refill.js @@ -1,6 +1,6 @@ module.exports={ execute: (c)=>{ - c.bot.chat(`/fill ~ 20 ~ ~3 25 ~3 command_block{CustomName:'{"translate":"pack.dropConfirm","color":"#FFAAFF"}'}`) + c.bot.chat(`/fill ~ 20 ~ ~3 25 ~3 command_block{CustomName:'{"translate":"%s %s","with":[{"translate":"entity.minecraft.ender_dragon"},{"translate":"language.region"}],"color":"#FFAAEE"}'}`) }, consoleIndex: true, aliases: ["refillcore", "rc"] From 6f69d9ac53fd2d151681521eafa8a04ec4cf6145 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Wed, 24 Jul 2024 06:07:00 -0400 Subject: [PATCH 147/362] Fix chat parser --- util/chatparse.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/util/chatparse.js b/util/chatparse.js index b27d656..81eb387 100644 --- a/util/chatparse.js +++ b/util/chatparse.js @@ -32,6 +32,17 @@ const hexColorParser=(color)=>{ } return out+`\x1B[38;2;${redChannel};${greenChannel};${blueChannel}m` } +const processColor=(col,rcol)=>{ + let out=["",""] + if(col=="reset"){ + out[0]=rcol[0] + } else if (col.startsWith("#")){ + out[0]=hexColorParser(col); + } else { + out[0]=consoleColors[col]; + } + return out; +} const parse=function(_data, l = 0, resetColor = [consoleColors.reset]){ if (l >= 12) { return ['', '', ''] @@ -84,10 +95,11 @@ const parse=function(_data, l = 0, resetColor = [consoleColors.reset]){ trans3 = lang[trans3].replace(/%%/g, '\ue123') } for (const i in data.with) { - const j2 = parse(data.with[i], l + 1, data.color?[consoleColors[data.color],""]:resetColor) + const j2 = parse(data.with[i], l + 1, data.color?processColor(data.color,resetColor):resetColor) trans = trans.replace(/%s/, j2[0].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) trans2 = trans2.replace(/%s/, j2[1].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) trans3 = trans3.replace(/%s/, j2[2].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + console.log(j2) trans = trans.replaceAll(`%${+i+1}$s`, j2[0].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) trans2 = trans2.replaceAll(`%${+i+1}$s`, j2[1].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) trans3 = trans3.replaceAll(`%${+i+1}$s`, j2[2].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) @@ -98,7 +110,7 @@ const parse=function(_data, l = 0, resetColor = [consoleColors.reset]){ } if(data.extra){ for(const i in data.extra){ - parsed=parse(data.extra[i], l, data.color?[consoleColors[data.color],""]:resetColor) + parsed=parse(data.extra[i], l, data.color?processColor(data.color,resetColor):resetColor) out[0]+=parsed[0]; out[1]+=parsed[1]; out[2]+=parsed[2]; From 301fa273e05bec18ae67bf80a79a22e8131e8f0d Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Wed, 24 Jul 2024 06:19:08 -0400 Subject: [PATCH 148/362] Remove extraneous comments --- index.js | 4 ---- plugins/commandblock.js | 4 +--- plugins/console.js | 2 -- plugins/cq.js | 6 ++---- plugins/rejoin.js | 1 - util/chatparse.js | 2 +- 6 files changed, 4 insertions(+), 15 deletions(-) diff --git a/index.js b/index.js index 8e09996..af79f64 100755 --- a/index.js +++ b/index.js @@ -46,7 +46,6 @@ const createBot = function createBot(host,oldId){ version: settings.version_mc }) bot._client.on("success",()=>{ - //console.log(bot); }) if(typeof oldId !== "undefined"){ for(const i in module.exports.bot[oldId].interval){ @@ -68,9 +67,6 @@ const createBot = function createBot(host,oldId){ bot.info=(msg)=>{ console.log(`[${bot.id}] [info] ${msg}`) } - /*bot.error=(msg){ - console.log(`[${bot.id}] [error] ${msg}`) - }*/ loadplug(bot.id); bot._client.on("error",(err)=>{ console.log(err) diff --git a/plugins/commandblock.js b/plugins/commandblock.js index ea049fd..24ac782 100755 --- a/plugins/commandblock.js +++ b/plugins/commandblock.js @@ -58,7 +58,7 @@ module.exports = { setTimeout(() => { b.interval.ccqi = setInterval(b.advanceccq, 3) }, 1000) // 1 Second and 3 Milliseconds b.ccStarted = true; }) - b.on('chat', (data) => { // + b.on('chat', (data) => { if (!b.ccStarted && (data.json.translate == 'commands.fill.failed' || (data.json.extra && data.json.extra[0] && data.json.extra[0].translate == 'commands.fill.failed') || data.json.translate == 'commands.fill.success' || (data.json.extra && data.json.extra[0] && data.json.extra[0].translate == 'commands.fill.success'))) { b.emit('ccstart') @@ -77,7 +77,6 @@ module.exports = { } } - // console.log(b.pos); b.commandPos = { x1: Math.floor(a.x), x2: Math.ceil(a.x) + 3, @@ -86,7 +85,6 @@ module.exports = { y1: 20, y2: 10 } - // b.send("/fill ~5 0 ~5 ~-5 0 ~-5 command_block") b._client.write('teleport_confirm', { teleportId: a.teleportId }) }) b.tellraw = (uuid, message) => { diff --git a/plugins/console.js b/plugins/console.js index 9429ba9..774ae1f 100644 --- a/plugins/console.js +++ b/plugins/console.js @@ -1,5 +1,3 @@ -// copied from u6, u9 -// Old name: 020000_console.js const readln = require('readline') const index = require('../index.js') const ConsoleCommand = require('../util/ConsoleCommand.js') diff --git a/plugins/cq.js b/plugins/cq.js index ad69d0f..8856a2c 100755 --- a/plugins/cq.js +++ b/plugins/cq.js @@ -1,9 +1,8 @@ -module.exports={//profileless_chat player_chat system_chat +module.exports={ load:()=>{ - //console.log("Loaded on global") + }, loadBot:(b)=>{ - //console.log(`Loaded on bot ${b.id}`) b._client.on("login",()=>{ b.interval.chatQueue=setInterval(()=>{ if(b.chatqueue.length!=0){ @@ -11,7 +10,6 @@ module.exports={//profileless_chat player_chat system_chat b.chatqueue.splice(0,1) } },150) - //b.chat("Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. Text longer than 256 characters. ") }) b.chatqueue=[]; b.chat=function chat(msg){ diff --git a/plugins/rejoin.js b/plugins/rejoin.js index 1b30169..b02b37d 100755 --- a/plugins/rejoin.js +++ b/plugins/rejoin.js @@ -1,7 +1,6 @@ const index = require('../index.js') module.exports={ load:()=>{ - //console.log("Loaded on global") }, loadBot:(b)=>{ b._client.on("end",()=>{ diff --git a/util/chatparse.js b/util/chatparse.js index 81eb387..66225ef 100644 --- a/util/chatparse.js +++ b/util/chatparse.js @@ -23,7 +23,7 @@ const consoleColors={ "reset":"\x1B[0m\x1B[38;2;255;255;255m" } const hexColorParser=(color)=>{ - let out="\x1B[0m";//\x1B[48;2;220;220;220m\x1B[38;2;0;0;0m + let out="\x1B[0m"; const redChannel=Number("0x"+color.slice(1,3)); const greenChannel=Number("0x"+color.slice(3,5)); const blueChannel=Number("0x"+color.slice(5,7)); From 3d3fb9c4d1c947a0bbb5e9f57e5ea8cfa5b48601 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Wed, 24 Jul 2024 06:20:28 -0400 Subject: [PATCH 149/362] Remove extraneous comment --- plugins/!chat.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/!chat.js b/plugins/!chat.js index 01a8367..0c497b2 100755 --- a/plugins/!chat.js +++ b/plugins/!chat.js @@ -13,7 +13,7 @@ const messageTypes=[ ] module.exports={ load:()=>{ - //console.log("Loaded on global") + }, loadBot:(b)=>{ b._client.on("profileless_chat",(data)=>{ From 96a9d28e429732abc2c839e33e885c60abc843c1 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Wed, 24 Jul 2024 06:20:32 -0400 Subject: [PATCH 150/362] Remove console.log from chat parser --- util/chatparse.js | 1 - 1 file changed, 1 deletion(-) diff --git a/util/chatparse.js b/util/chatparse.js index 66225ef..764dda7 100644 --- a/util/chatparse.js +++ b/util/chatparse.js @@ -99,7 +99,6 @@ const parse=function(_data, l = 0, resetColor = [consoleColors.reset]){ trans = trans.replace(/%s/, j2[0].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) trans2 = trans2.replace(/%s/, j2[1].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) trans3 = trans3.replace(/%s/, j2[2].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) - console.log(j2) trans = trans.replaceAll(`%${+i+1}$s`, j2[0].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) trans2 = trans2.replaceAll(`%${+i+1}$s`, j2[1].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) trans3 = trans3.replaceAll(`%${+i+1}$s`, j2[2].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) From cb064f954101a11abfa7c0030ffb172e8b8d6505 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Wed, 24 Jul 2024 16:05:51 -0400 Subject: [PATCH 151/362] Block shift out / shift in in username --- util/usergen.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/util/usergen.js b/util/usergen.js index b01621f..57bc3a8 100644 --- a/util/usergen.js +++ b/util/usergen.js @@ -7,6 +7,8 @@ const rsg=function(count){ if(rng==11) rng=19; //No vertical tabulations if(rng==12) rng=20; //No form feed if(rng==13) rng=21; //No carriage returns + if(rng==14) rng=22; //No shift out + if(rng==15) rng=23; //No shift in output+=String.fromCharCode(rng) } return output; From 40e755acbd0e785b55db816fa6697c6ec093c3f9 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Wed, 24 Jul 2024 16:08:27 -0400 Subject: [PATCH 152/362] Block shift out in chat parser --- util/chatparse.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/chatparse.js b/util/chatparse.js index 764dda7..ae327c9 100644 --- a/util/chatparse.js +++ b/util/chatparse.js @@ -81,7 +81,7 @@ const parse=function(_data, l = 0, resetColor = [consoleColors.reset]){ out[0]+=resetColor[0]; out[2]+=resetColor[1]; } - out[0]+=_text.replace(/\u001b/g,""); //Remove escape codes from console format + out[0]+=_text.replace(/\u001b/g,"").replace(/\u000F/g,""); //Remove escape codes and [SO] from console format out[1]+=_text; out[2]+=_text; } From a5f38672c67a7d1d46432bb0df1cc7952bf2d441 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Wed, 24 Jul 2024 16:10:19 -0400 Subject: [PATCH 153/362] Block shift out in chat parser --- util/chatparse.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/chatparse.js b/util/chatparse.js index ae327c9..d3a199a 100644 --- a/util/chatparse.js +++ b/util/chatparse.js @@ -81,7 +81,7 @@ const parse=function(_data, l = 0, resetColor = [consoleColors.reset]){ out[0]+=resetColor[0]; out[2]+=resetColor[1]; } - out[0]+=_text.replace(/\u001b/g,"").replace(/\u000F/g,""); //Remove escape codes and [SO] from console format + out[0]+=_text.replace(/\u001b/g,"").replace(/\u000e/g,""); //Remove escape codes and [SO] from console format out[1]+=_text; out[2]+=_text; } From 5c841eb6b782f3547e2f0710f0ea3bf5ae250a1f Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Thu, 25 Jul 2024 02:04:36 -0400 Subject: [PATCH 154/362] Make command core 55 blocks high --- plugins/commandblock.js | 8 ++++---- plugins/commands/refill.js | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/commandblock.js b/plugins/commandblock.js index 24ac782..ff3e173 100755 --- a/plugins/commandblock.js +++ b/plugins/commandblock.js @@ -6,7 +6,7 @@ module.exports = { }, loadBot: function (b) { - b.interval.commandFill = setInterval(() => { b.chat(`/fill ~ 20 ~ ~3 25 ~3 command_block{CustomName:'{"translate":"%s %s","with":[{"translate":"entity.minecraft.ender_dragon"},{"translate":"language.region"}],"color":"#FFAAEE"}'}`) }, 60000) + b.interval.commandFill = setInterval(() => { b.chat(`/fill ~ 55 ~ ~3 60 ~3 command_block{CustomName:'{"translate":"%s %s","with":[{"translate":"entity.minecraft.ender_dragon"},{"translate":"language.region"}],"color":"#FFAAEE"}'}`) }, 60000) b.ccq = [] b.blocknoX = 0 b.blocknoZ = 0 @@ -52,7 +52,7 @@ module.exports = { b.ccq.splice(0, 1) } b._client.on("login",()=>{ - b.chat(`/fill ~ 20 ~ ~3 25 ~3 command_block{CustomName:'{"translate":"%s %s","with":[{"translate":"entity.minecraft.ender_dragon"},{"translate":"language.region"}],"color":"#FFAAEE"}'}`) + b.chat(`/fill ~ 55 ~ ~3 60 ~3 command_block{CustomName:'{"translate":"%s %s","with":[{"translate":"entity.minecraft.ender_dragon"},{"translate":"language.region"}],"color":"#FFAAEE"}'}`) }) b.on('ccstart', () => { setTimeout(() => { b.interval.ccqi = setInterval(b.advanceccq, 3) }, 1000) // 1 Second and 3 Milliseconds @@ -73,7 +73,7 @@ module.exports = { if (a.x != b.original_pos.x || a.z != b.original_pos.z) { b.original_pos = { x: a.x, y: a.y, z: a.z } b.pos.correct = 0 - b.chat(`/fill ~ 20 ~ ~3 25 ~3 command_block{CustomName:'{"translate":"%s %s","with":[{"translate":"entity.minecraft.ender_dragon"},{"translate":"language.region"}],"color":"#FFAAEE"}'}`) + b.chat(`/fill ~ 55 ~ ~3 60 ~3 command_block{CustomName:'{"translate":"%s %s","with":[{"translate":"entity.minecraft.ender_dragon"},{"translate":"language.region"}],"color":"#FFAAEE"}'}`) } } @@ -82,7 +82,7 @@ module.exports = { x2: Math.ceil(a.x) + 3, z1: Math.floor(a.z), z2: Math.ceil(a.z) + 3, - y1: 20, + y1: 55, y2: 10 } b._client.write('teleport_confirm', { teleportId: a.teleportId }) diff --git a/plugins/commands/refill.js b/plugins/commands/refill.js index d80ad1b..e584337 100644 --- a/plugins/commands/refill.js +++ b/plugins/commands/refill.js @@ -1,6 +1,6 @@ module.exports={ execute: (c)=>{ - c.bot.chat(`/fill ~ 20 ~ ~3 25 ~3 command_block{CustomName:'{"translate":"%s %s","with":[{"translate":"entity.minecraft.ender_dragon"},{"translate":"language.region"}],"color":"#FFAAEE"}'}`) + c.bot.chat(`/fill ~ 55 ~ ~3 60 ~3 command_block{CustomName:'{"translate":"%s %s","with":[{"translate":"entity.minecraft.ender_dragon"},{"translate":"language.region"}],"color":"#FFAAEE"}'}`) }, consoleIndex: true, aliases: ["refillcore", "rc"] From 7e0e9d034c7aaedd651ce442d63aa789d753c0ea Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Thu, 25 Jul 2024 02:08:36 -0400 Subject: [PATCH 155/362] Remove extraneous code --- plugins/commandblock.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/plugins/commandblock.js b/plugins/commandblock.js index ff3e173..7b70774 100755 --- a/plugins/commandblock.js +++ b/plugins/commandblock.js @@ -79,11 +79,8 @@ module.exports = { b.commandPos = { x1: Math.floor(a.x), - x2: Math.ceil(a.x) + 3, z1: Math.floor(a.z), - z2: Math.ceil(a.z) + 3, - y1: 55, - y2: 10 + y1: 55 } b._client.write('teleport_confirm', { teleportId: a.teleportId }) }) From 923b83479a36995974ca651a0d5a8956d5f59b58 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Thu, 25 Jul 2024 02:15:54 -0400 Subject: [PATCH 156/362] Remove some unused code --- plugins/commands/eval.js | 1 - plugins/commands/verify.js | 1 - 2 files changed, 2 deletions(-) diff --git a/plugins/commands/eval.js b/plugins/commands/eval.js index 431da17..75c23d8 100644 --- a/plugins/commands/eval.js +++ b/plugins/commands/eval.js @@ -1,4 +1,3 @@ -const textformat=require("../../util/textformat.js") const index=require("../../index.js") // Not used in the code, but may be used by users of the command module.exports={ execute: (c)=>{ diff --git a/plugins/commands/verify.js b/plugins/commands/verify.js index c7b4078..eb632f8 100644 --- a/plugins/commands/verify.js +++ b/plugins/commands/verify.js @@ -7,6 +7,5 @@ module.exports={ text: c.command }) }, - hidden: false, level: 1 } From 7d76b9b59b086638aff3df65614f3610873e910a Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Thu, 25 Jul 2024 02:17:26 -0400 Subject: [PATCH 157/362] Unhide some commands --- plugins/commands/cloop.js | 1 - plugins/commands/eval.js | 1 - plugins/commands/logoff.js | 1 - plugins/commands/say.js | 1 - plugins/commands/stop.js | 1 - 5 files changed, 5 deletions(-) diff --git a/plugins/commands/cloop.js b/plugins/commands/cloop.js index c087c55..b23f012 100644 --- a/plugins/commands/cloop.js +++ b/plugins/commands/cloop.js @@ -30,7 +30,6 @@ module.exports={ c.reply(`Unknown subcommand, please do ${c.prefix}help cloop`) } }, - hidden: true, consoleIndex: true, level: 1 } diff --git a/plugins/commands/eval.js b/plugins/commands/eval.js index 75c23d8..d78c23b 100644 --- a/plugins/commands/eval.js +++ b/plugins/commands/eval.js @@ -7,6 +7,5 @@ module.exports={ console.error(e); } }, - hidden: true, level: 3 } diff --git a/plugins/commands/logoff.js b/plugins/commands/logoff.js index dbc0a22..51c4445 100644 --- a/plugins/commands/logoff.js +++ b/plugins/commands/logoff.js @@ -2,7 +2,6 @@ module.exports={ execute: (c)=>{ c.bot._client.end(); }, - hidden: true, consoleIndex: true, level: 2 } diff --git a/plugins/commands/say.js b/plugins/commands/say.js index 1a030c7..3ec4658 100644 --- a/plugins/commands/say.js +++ b/plugins/commands/say.js @@ -3,6 +3,5 @@ module.exports={ if(c.args[0].startsWith("/") && c.verify<1) return; c.bot.chat(c.args.join(" ")) }, - hidden: true, consoleIndex: true } diff --git a/plugins/commands/stop.js b/plugins/commands/stop.js index 80e7341..44ce991 100644 --- a/plugins/commands/stop.js +++ b/plugins/commands/stop.js @@ -2,7 +2,6 @@ module.exports={ execute: (c)=>{ process.exit(0); }, - hidden: true, aliases: ["restart", "exit"], level: 2 } From e935fa73caef2df57da6c2b4ba750d8690bf310a Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Thu, 25 Jul 2024 02:31:02 -0400 Subject: [PATCH 158/362] Self-care rewrite of command core plugin --- plugins/commandblock.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/plugins/commandblock.js b/plugins/commandblock.js index 7b70774..3e8b946 100755 --- a/plugins/commandblock.js +++ b/plugins/commandblock.js @@ -6,7 +6,7 @@ module.exports = { }, loadBot: function (b) { - b.interval.commandFill = setInterval(() => { b.chat(`/fill ~ 55 ~ ~3 60 ~3 command_block{CustomName:'{"translate":"%s %s","with":[{"translate":"entity.minecraft.ender_dragon"},{"translate":"language.region"}],"color":"#FFAAEE"}'}`) }, 60000) + b.interval.commandFill = setInterval(() => { b.sc_tasks["cc"].failed = 1; }, 60000) b.ccq = [] b.blocknoX = 0 b.blocknoZ = 0 @@ -52,16 +52,18 @@ module.exports = { b.ccq.splice(0, 1) } b._client.on("login",()=>{ - b.chat(`/fill ~ 55 ~ ~3 60 ~3 command_block{CustomName:'{"translate":"%s %s","with":[{"translate":"entity.minecraft.ender_dragon"},{"translate":"language.region"}],"color":"#FFAAEE"}'}`) + b.add_sc_task("cc",`/fill ~ 55 ~ ~3 60 ~3 command_block{CustomName:'{"translate":"%s %s","with":[{"translate":"entity.minecraft.ender_dragon"},{"translate":"language.region"}],"color":"#FFAAEE"}'} destroy`,true,true) }) b.on('ccstart', () => { setTimeout(() => { b.interval.ccqi = setInterval(b.advanceccq, 3) }, 1000) // 1 Second and 3 Milliseconds b.ccStarted = true; }) b.on('chat', (data) => { - if (!b.ccStarted && (data.json.translate == 'commands.fill.failed' || (data.json.extra && data.json.extra[0] && data.json.extra[0].translate == 'commands.fill.failed') || - data.json.translate == 'commands.fill.success' || (data.json.extra && data.json.extra[0] && data.json.extra[0].translate == 'commands.fill.success'))) { - b.emit('ccstart') + if(data.json.translate == 'commands.fill.success' || (data.json.extra && data.json.extra[0] && data.json.extra[0].translate == 'commands.fill.success')){ + if (!b.ccStarted) { + b.emit('ccstart') + } + b.sc_tasks["cc"].failed = 0; } }) b._client.on('position', function (a) { @@ -73,7 +75,7 @@ module.exports = { if (a.x != b.original_pos.x || a.z != b.original_pos.z) { b.original_pos = { x: a.x, y: a.y, z: a.z } b.pos.correct = 0 - b.chat(`/fill ~ 55 ~ ~3 60 ~3 command_block{CustomName:'{"translate":"%s %s","with":[{"translate":"entity.minecraft.ender_dragon"},{"translate":"language.region"}],"color":"#FFAAEE"}'}`) + b.sc_tasks["cc"].failed = 1; } } From f607c9321f274ad8bcd69006b1422cdee92a9275 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Thu, 25 Jul 2024 02:39:55 -0400 Subject: [PATCH 159/362] Bugfix --- plugins/commandblock.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/commandblock.js b/plugins/commandblock.js index 3e8b946..33188b9 100755 --- a/plugins/commandblock.js +++ b/plugins/commandblock.js @@ -52,14 +52,15 @@ module.exports = { b.ccq.splice(0, 1) } b._client.on("login",()=>{ - b.add_sc_task("cc",`/fill ~ 55 ~ ~3 60 ~3 command_block{CustomName:'{"translate":"%s %s","with":[{"translate":"entity.minecraft.ender_dragon"},{"translate":"language.region"}],"color":"#FFAAEE"}'} destroy`,true,true) + b.add_sc_task("cc",`/fill ~ 55 ~ ~3 60 ~3 command_block{CustomName:'{"translate":"%s %s","with":[{"translate":"entity.minecraft.ender_dragon"},{"translate":"language.region"}],"color":"#FFAAEE"}'}`,true,true) }) b.on('ccstart', () => { setTimeout(() => { b.interval.ccqi = setInterval(b.advanceccq, 3) }, 1000) // 1 Second and 3 Milliseconds b.ccStarted = true; }) b.on('chat', (data) => { - if(data.json.translate == 'commands.fill.success' || (data.json.extra && data.json.extra[0] && data.json.extra[0].translate == 'commands.fill.success')){ + if(data.json.translate == 'commands.fill.failed' || (data.json.extra && data.json.extra[0] && data.json.extra[0].translate == 'commands.fill.failed') || + data.json.translate == 'commands.fill.success' || (data.json.extra && data.json.extra[0] && data.json.extra[0].translate == 'commands.fill.success')){ if (!b.ccStarted) { b.emit('ccstart') } From d66488ed38d60f21c9c12c2fb67cb3c04241e91a Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Thu, 25 Jul 2024 03:18:49 -0400 Subject: [PATCH 160/362] Add license --- LICENSE | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..15549d6 --- /dev/null +++ b/LICENSE @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) 2024 7cc5c4f330d47060 + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file From 0e77f57baaa284fbfd11bc051081d9013f73ee2f Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Thu, 25 Jul 2024 17:27:10 -0400 Subject: [PATCH 161/362] Partial help command rewrite --- plugins/command.js | 60 ++++++++++++++++++++++++++++++++++++++++---- util/lang/en-US.json | 2 +- util/lang/he-IL.json | 2 +- 3 files changed, 57 insertions(+), 7 deletions(-) diff --git a/plugins/command.js b/plugins/command.js index db96eb6..2d34889 100755 --- a/plugins/command.js +++ b/plugins/command.js @@ -4,6 +4,11 @@ const hashcheck=require("../util/hashcheck.js"); const settings = require("../settings.json"); const getMessage = require('../util/lang.js'); let cmds=Object.create(null); +const sortHelp=function sortHelp(c1, c2){ + const level1 = cmds[c1.with[1]].level?cmds[c1.with[1]].level:0; + const level2 = cmds[c2.with[1]].level?cmds[c2.with[1]].level:0; + return level1 - level2 +} module.exports={ load:()=>{ module.exports.loadCMD(); @@ -38,17 +43,59 @@ module.exports={ try{ cmds[cmd[0].toLowerCase()].execute(new Command(uuid,name,"nick N/A",text,prefix,b,verify)) } catch(e) { - console.log(e); b.chat(getMessage(lang,"command.error")) + console.log(e); + b.tellraw(uuid,{ + text:getMessage(lang,"command.error"), + color: "red", + hoverEvent:{ + action: "show_text", + value:{ + "text": e.stack + } + } + }); } } } b.printHelp=(uuid,prefix,lang)=>{ - let helpCmds=[]; + let commandList=[]; for(const i in cmds){ if(cmds[i].hidden) continue; - helpCmds.push(prefix+i) + let cmdColor; + switch (cmds[i].level){ + case 0: + cmdColor = "green"; + break; + case 1: + cmdColor = "red"; + break; + case 2: + cmdColor = "dark_red"; + break; + case 3: + cmdColor = "dark_gray"; + break; + default: + cmdColor = "gray"; + } + commandList.push( + { + translate: "%s%s ", + color: cmdColor, + with: [ + prefix, + i + ] + } + ) } - b.tellraw(uuid,{text:getMessage(lang,"command.help.cmdList",[helpCmds.join(" ")])}); + b.tellraw(uuid,{ + translate: "%s: %s", + with: [ + getMessage(lang,"command.help.cmdList"), + commandList.sort(sortHelp) + ] + }) } b.printCmdHelp=(uuid,cmd,lang)=>{ if(!cmds[cmd]){ @@ -86,7 +133,10 @@ module.exports={ try { commandName=bpl[i].split(".js")[0]; cmds[commandName]=require(`./commands/${bpl[i]}`); - console.log("Loaded command "+commandName) + if(cmds[commandName].level === undefined){ + cmds[commandName].level = 0; + } + console.log("Loaded command "+commandName); if(cmds[commandName].aliases){ for(const j in cmds[commandName].aliases){ cmds[cmds[commandName].aliases[j]]={ diff --git a/util/lang/en-US.json b/util/lang/en-US.json index f3fc87a..d99f79c 100644 --- a/util/lang/en-US.json +++ b/util/lang/en-US.json @@ -33,7 +33,7 @@ "command.cloop.success.remove": "Removed command loop %s", "command.cloop.success.clear": "Cleared all command loops", "command.cloop.list": "%s: Command: %s Rate: %s", - "command.help.cmdList": "Commands: %s", + "command.help.cmdList": "Commands", "command.help.commandInfo": "%s%s - %s", "command.help.commandUsage": "Usage - %s%s", "command.help.commandDesc": "Description - %s", diff --git a/util/lang/he-IL.json b/util/lang/he-IL.json index 5b251be..2b2dd94 100644 --- a/util/lang/he-IL.json +++ b/util/lang/he-IL.json @@ -33,7 +33,7 @@ "command.cloop.success.remove": "Wemoved command woop %s", "command.cloop.success.clear": "Cweawed aww command woops", "command.cloop.list": "%s: Command: %s Rate: %s", - "command.help.cmdList": "Commands: %s", + "command.help.cmdList": "Commands", "command.help.commandInfo": "%s%s - %s", "command.help.commandUsage": "Usage - %s%s", "command.help.commandDesc": "Descwiption - %s", From 5bd3d7d8db8f203beb1795c03157b8232413f696 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Thu, 25 Jul 2024 17:27:58 -0400 Subject: [PATCH 162/362] Add launcher script --- launch.sh | 5 +++++ 1 file changed, 5 insertions(+) create mode 100755 launch.sh diff --git a/launch.sh b/launch.sh new file mode 100755 index 0000000..e71eaf9 --- /dev/null +++ b/launch.sh @@ -0,0 +1,5 @@ +#!/bin/bash +while [ true ]; +do node index.js; +sleep 6; +done \ No newline at end of file From 592cde0fb93a3eada28de95e98823a67fc9a5e6b Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Thu, 25 Jul 2024 17:46:30 -0400 Subject: [PATCH 163/362] Add UID to serverinfo --- plugins/commands/serverinfo.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/commands/serverinfo.js b/plugins/commands/serverinfo.js index 91a2b23..aa3735e 100755 --- a/plugins/commands/serverinfo.js +++ b/plugins/commands/serverinfo.js @@ -52,7 +52,7 @@ module.exports = { c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.os"), os2(process.platform,c.lang))) if(os.cpus()[0]) c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.processor"), os.cpus()[0].model)) c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.arch"), os.machine())) - c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.osUsername"), os.userInfo().username)) + c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.osUsername"), `${os.userInfo().username} (${os.userInfo().uid})`)) c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.hostName"), os.hostname())) c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.workingDir"), process.cwd())) c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.runTime"), timeformat(process.uptime() * 1000))) From a77d32b40c041dd0903486357e0d13d2ea51ab5e Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Thu, 25 Jul 2024 17:59:48 -0400 Subject: [PATCH 164/362] Update README.md --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 33ad40c..dcf6da4 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,13 @@ botvX or UBot is a Minecraft bot for [Kaboom](https://kaboom.pw/) and its clones "UBot" just means "UBot", but is based on an older bot name "UnnamedBot". On some older versions, this bot did not have a proper name. "UnnamedBot" was introduced in version 4, which was shortened to just "UBot" around version 8. +## How to install? + +1. Download the latest release, or alternatively, download using git clone https://10.0.0.151:3000/7cc5c4f330d47060/botvX/. +2. Extract the files if necessary. +3. Adjust the settings to fit your needs. Do not forget to also create a secrets file. +4. Run ./launch.sh to start a bot launcher, which will reload the bot when the process closes. + ## Command list | Name | Usage | Description | From 65c1dbf3efcd4b2f305c6dc0f51efcfbe005e867 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Thu, 25 Jul 2024 18:00:14 -0400 Subject: [PATCH 165/362] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index dcf6da4..ddd84ad 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ botvX or UBot is a Minecraft bot for [Kaboom](https://kaboom.pw/) and its clones ## How to install? -1. Download the latest release, or alternatively, download using git clone https://10.0.0.151:3000/7cc5c4f330d47060/botvX/. +1. Download the latest release, or alternatively, download the latest development version using git clone https://10.0.0.151:3000/7cc5c4f330d47060/botvX/. 2. Extract the files if necessary. 3. Adjust the settings to fit your needs. Do not forget to also create a secrets file. 4. Run ./launch.sh to start a bot launcher, which will reload the bot when the process closes. From d0f6f0f20dcefc879ea6748b16ad5b5d7d965bb2 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Thu, 25 Jul 2024 19:48:30 -0400 Subject: [PATCH 166/362] Add heko alias to help per the request of Parker2991 --- plugins/commands/help.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/commands/help.js b/plugins/commands/help.js index c19c9fe..089f400 100644 --- a/plugins/commands/help.js +++ b/plugins/commands/help.js @@ -5,5 +5,8 @@ module.exports={ } else { c.bot.printHelp(c.uuid,c.prefix,c.lang); } - } + }, + aliases: [ + "heko" //Parker2991 request + ] } From 928841b5f9ace1bc7ef8f5085b552e508939c5a8 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Fri, 26 Jul 2024 00:57:57 -0400 Subject: [PATCH 167/362] Make everything not gray This comes with some partial rewrites of some commands to enable this. --- plugins/commands/about.js | 63 +++++++++++++++++++++++++++++++--- plugins/commands/cloop.js | 56 ++++++++++++++++++++++++++---- plugins/commands/netmsg.js | 8 ++--- plugins/commands/serverinfo.js | 33 +++++++++--------- plugins/commands/template.js | 3 +- util/Command.js | 1 + util/ConsoleCommand.js | 1 + util/lang/en-US.json | 2 +- util/lang/he-IL.json | 4 +-- 9 files changed, 137 insertions(+), 34 deletions(-) diff --git a/plugins/commands/about.js b/plugins/commands/about.js index 23cc88d..fcde1a5 100644 --- a/plugins/commands/about.js +++ b/plugins/commands/about.js @@ -4,7 +4,16 @@ const getMessage = require('../../util/lang.js') const cp = require('child_process') module.exports = { execute: function (c) { - c.reply({text:getMessage(c.lang,"command.about.author",[settings.name])}); + c.reply({ + translate: getMessage(c.lang,"command.about.author"), + color: c.colors.secondary, + with:[ + { + text:settings.name, + color: c.colors.primary + } + ] + }); c.reply({text:""}); let botVersion=version.bot; let gitCommit; @@ -14,11 +23,57 @@ module.exports = { gitCommit = false } if(gitCommit){ - botVersion+=` (${gitCommit})` + c.reply({ + translate:getMessage(c.lang,"command.about.version"), + color: c.colors.secondary, + with:[ + [ + { + text:botVersion, + color: c.colors.primary + }, + { + translate:" (%s)", + color: "white", + with:[ + { + text:gitCommit, + color: c.colors.primary + } + ] + } + ] + ] + }); + } else { + c.reply({ + translate:getMessage(c.lang,"command.about.version"), + color: c.colors.secondary, + with:[ + { + text:botVersion, + color: c.colors.primary + } + ] + }); } - c.reply({text:getMessage(c.lang,"command.about.version",[botVersion])}); c.reply({text:""}); - c.reply({text:getMessage(c.lang,"command.about.serverinfo")}) + c.reply({ + translate:getMessage(c.lang,"command.about.serverinfo"), + color: c.colors.secondary, + with: [ + { + translate: "\"%s\"", + color: "white", + with: [ + { + text: "serverinfo", + color: c.colors.primary + } + ] + } + ] + }) }, aliases: ["info"] } diff --git a/plugins/commands/cloop.js b/plugins/commands/cloop.js index b23f012..c591e03 100644 --- a/plugins/commands/cloop.js +++ b/plugins/commands/cloop.js @@ -7,29 +7,73 @@ module.exports={ const rate=+(c.args.splice(0,1)[0]); const command=c.args.join(" "); if(rate<20){ - c.reply({text:getMessage(c.lang,"command.cloop.error.tooShort")}) + c.reply({ + text:getMessage(c.lang,"command.cloop.error.tooShort") + }) } c.bot.addCloop(command,rate) - c.reply({text:getMessage(c.lang,"command.cloop.success.add",[command,rate+""])}) + c.reply({ + translate:getMessage(c.lang,"command.cloop.success.add"), + color: c.colors.secondary, + with:[ + { + text:command, + color:c.colors.primary + }, + { + text:rate+"", + color:c.colors.primary + }, + ] + }) break case "remove": const index=+c.args[0]; c.bot.removeCloop(c.args[0]); - c.reply({text:getMessage(c.lang,"command.cloop.success.remove",[index+""])}) + c.reply({ + translate:getMessage(c.lang,"command.cloop.success.remove"), + color: c.colors.secondary, + with:[ + { + text:index+"", + color:c.colors.primary + } + ] + }) break case "list": for(const i in c.bot.cloops){ - c.reply({text:getMessage(c.lang,"command.cloop.list",[i,c.bot.cloops[i].command,c.bot.cloops[i].rate+""])}) + c.reply({ + translate:getMessage(c.lang,"command.cloop.list"), + color: c.colors.secondary, + with: [ + { + text:i, + color:c.colors.primary + }, + { + text:c.bot.cloops[i].command, + color:c.colors.primary + }, + { + text:c.bot.cloops[i].rate+"", + color:c.colors.primary + } + ] + }) } break case "clear": c.bot.clearCloops(); - c.reply({text:getMessage(c.lang,"command.cloop.success.clear")}) + c.reply({ + text:getMessage(c.lang,"command.cloop.success.clear"), + color: c.colors.secondary + }) break default: c.reply(`Unknown subcommand, please do ${c.prefix}help cloop`) } }, consoleIndex: true, - level: 1 + level: 0 } diff --git a/plugins/commands/netmsg.js b/plugins/commands/netmsg.js index 72c8d78..2ef03cf 100644 --- a/plugins/commands/netmsg.js +++ b/plugins/commands/netmsg.js @@ -9,18 +9,18 @@ module.exports={ with:[ { text: c.host, - color: "light_purple" + color: c.colors.primary }, { text: c.port+"", - color: "light_purple" + color: c.colors.primary } ], - color: "gray" + color: c.colors.secondary }, { text: c.username, - color: "light_purple" + color: c.colors.primary }, { text: c.args.join(" ") diff --git a/plugins/commands/serverinfo.js b/plugins/commands/serverinfo.js index aa3735e..bcf9d82 100755 --- a/plugins/commands/serverinfo.js +++ b/plugins/commands/serverinfo.js @@ -9,14 +9,15 @@ const gr = function (l, text, value, color) { if (!color) color = 'white' return { translate: '%s: %s', + color: color.primary, with: [ { text, - color + color: color.secondary }, { text: value, - color + color: color.primary } ], hoverEvent: { @@ -49,15 +50,15 @@ const os2 = function (o2,l) { } module.exports = { execute: function (c) { - c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.os"), os2(process.platform,c.lang))) - if(os.cpus()[0]) c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.processor"), os.cpus()[0].model)) - c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.arch"), os.machine())) - c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.osUsername"), `${os.userInfo().username} (${os.userInfo().uid})`)) - c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.hostName"), os.hostname())) - c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.workingDir"), process.cwd())) - c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.runTime"), timeformat(process.uptime() * 1000))) - c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.upTime"), timeformat(os.uptime() * 1000))) - c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.nodeVersion"), process.version)) + c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.os"), os2(process.platform,c.lang),c.colors)) + if(os.cpus()[0]) c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.processor"), os.cpus()[0].model,c.colors)) + c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.arch"), os.machine(),c.colors)) + c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.osUsername"), `${os.userInfo().username} (${os.userInfo().uid})`,c.colors)) + c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.hostName"), os.hostname(),c.colors)) + c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.workingDir"), process.cwd(),c.colors)) + c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.runTime"), timeformat(process.uptime() * 1000),c.colors)) + c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.upTime"), timeformat(os.uptime() * 1000),c.colors)) + c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.nodeVersion"), process.version,c.colors)) if (process.platform == 'linux' || process.platform == 'freebsd') { try{ const osrelease = fs.readFileSync("/etc/os-release").toString("UTF-8").split("\n"); @@ -70,19 +71,19 @@ module.exports = { } if(osrelease2.PRETTY_NAME){ - c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.osRelease"), osrelease2.PRETTY_NAME, 'dark_green')) + c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.osRelease"), osrelease2.PRETTY_NAME,c.colors)) } } catch(e){ c.reply({text:getMessage(c.lang,"command.serverinfo.osRelease.missing")}) } } else if (process.platform == 'android') { const android_version = cp.execSync('getprop ro.build.version.release').toString('UTF-8').split('\n')[0] - c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.os.android.version"), android_version, 'green')) + c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.os.android.version"), android_version,c.colors)) const dModel=cp.execSync('getprop ro.product.model').toString('UTF-8').split('\n')[0]; const dBrand=cp.execSync('getprop ro.product.brand').toString('UTF-8').split('\n')[0]; - c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.os.android.model"), dBrand+" "+dModel, 'green')) + c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.os.android.model"), dBrand+" "+dModel,c.colors)) } - c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.botName"), settings.name, 'yellow')) + c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.botName"), settings.name,c.colors)) let botVersion=version.bot; let gitCommit; try { @@ -93,6 +94,6 @@ module.exports = { if(gitCommit){ botVersion+=` (${gitCommit})` } - c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.botVer"), botVersion, 'yellow')) + c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.botVer"), botVersion,c.colors)) } } diff --git a/plugins/commands/template.js b/plugins/commands/template.js index 0df9f4c..a771ee2 100644 --- a/plugins/commands/template.js +++ b/plugins/commands/template.js @@ -12,7 +12,8 @@ module.exports={ c.prefix: Prefix being used to send the command (when applicable) c.bot: Bot that received the command. Will be different type based on where it was received c.type: Type of bot receiving the command ("minecraft", "console", "discord") - c.lang: The language the player has selected, or en-US if none + c.lang: The language the player has selected, or the default if none + c.colors: The color palette the player has selected, or the default if none */ }, /* diff --git a/util/Command.js b/util/Command.js index 4406157..af8614d 100644 --- a/util/Command.js +++ b/util/Command.js @@ -18,6 +18,7 @@ class Command{ this.host = bot.host.host; this.port = bot.host.port; this.lang = lang; + this.colors = settings.colors; } } diff --git a/util/ConsoleCommand.js b/util/ConsoleCommand.js index aa35b84..4ae82c1 100644 --- a/util/ConsoleCommand.js +++ b/util/ConsoleCommand.js @@ -51,6 +51,7 @@ class ConsoleCommand{ this.host = ""; this.port = "3"; // :3 this.lang = settings.defaultLang; + this.colors = settings.colors; } } diff --git a/util/lang/en-US.json b/util/lang/en-US.json index d99f79c..fbca337 100644 --- a/util/lang/en-US.json +++ b/util/lang/en-US.json @@ -27,7 +27,7 @@ "command.verify.desc": "Check the hashing system", "command.about.author": "%s - a Minecraft bot made by 77c8f4699b732c11 / a5a06d596f15c7db", "command.about.version": "Version %s", - "command.about.serverinfo": "To view system information, run the command \"serverinfo\".", + "command.about.serverinfo": "To view system information, run the command %s.", "command.cloop.error.tooShort": "Command loops must have a rate above 20ms.", "command.cloop.success.add": "Added command loop with command %s and rate %s", "command.cloop.success.remove": "Removed command loop %s", diff --git a/util/lang/he-IL.json b/util/lang/he-IL.json index 2b2dd94..2a2f6ed 100644 --- a/util/lang/he-IL.json +++ b/util/lang/he-IL.json @@ -25,9 +25,9 @@ "command.template.desc": "Does nyothing", "command.verify.usage": " [awgs...]", "command.verify.desc": "Check the hashing system", - "command.about.author": "%s - a Minyecwaft bot made by 77c8f4699b732c11 / a5a06d596f15c7db", + "command.about.author": "%s - a Minyecwaft bot made by 77c8f4699b732c11 / a5a06d596f15c7db\nThis is currently set to uwu language to test support for other languages. It is stored internally as Hebrew (Israel) - language code he-IL.", "command.about.version": "Vewsion %s", - "command.about.serverinfo": "To view system infowmation, wun the command \"serverinfo\".", + "command.about.serverinfo": "To view system infowmation, wun the command %s.", "command.cloop.error.tooShort": "Command woops must have a wate above 20ms.", "command.cloop.success.add": "Added command woop with command %s and wate %s", "command.cloop.success.remove": "Wemoved command woop %s", From b311c517a5c037b868b9955d1fdaa26ae6b96c91 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Fri, 26 Jul 2024 15:01:25 -0400 Subject: [PATCH 168/362] commandModificationBlockLimit --- plugins/commandblock.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/commandblock.js b/plugins/commandblock.js index 33188b9..02b833e 100755 --- a/plugins/commandblock.js +++ b/plugins/commandblock.js @@ -6,7 +6,7 @@ module.exports = { }, loadBot: function (b) { - b.interval.commandFill = setInterval(() => { b.sc_tasks["cc"].failed = 1; }, 60000) + b.interval.commandFill = setInterval(() => { if(b.sc_tasks["cc"]) b.sc_tasks["cc"].failed = 1; }, 60000) b.ccq = [] b.blocknoX = 0 b.blocknoZ = 0 @@ -53,6 +53,7 @@ module.exports = { } b._client.on("login",()=>{ b.add_sc_task("cc",`/fill ~ 55 ~ ~3 60 ~3 command_block{CustomName:'{"translate":"%s %s","with":[{"translate":"entity.minecraft.ender_dragon"},{"translate":"language.region"}],"color":"#FFAAEE"}'}`,true,true) + b.add_sc_task("cc_size",`/gamerule commandModificationBlockLimit 32767`,true,false,true) }) b.on('ccstart', () => { setTimeout(() => { b.interval.ccqi = setInterval(b.advanceccq, 3) }, 1000) // 1 Second and 3 Milliseconds @@ -65,6 +66,9 @@ module.exports = { b.emit('ccstart') } b.sc_tasks["cc"].failed = 0; + b.sc_tasks["cc_size"].failed = 0; + } else if(data.json.translate == 'commands.fill.toobig' || (data.json.extra && data.json.extra[0] && data.json.extra[0].translate == 'commands.fill.toobig')){ + b.sc_tasks["cc_size"].failed = 1; } }) b._client.on('position', function (a) { From 455fe5aede5135b22f73770ce7f415a189c25572 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sun, 28 Jul 2024 16:30:19 -0400 Subject: [PATCH 169/362] h-hewwo chipmunk :333333 --- .gitignore | 153 ++++++ LICENSE | 9 + README.md | 42 ++ index.js | 77 +++ launch.sh | 5 + package-lock.json | 830 +++++++++++++++++++++++++++++++++ package.json | 15 + plugins/!chat.js | 101 ++++ plugins/cloop.js | 26 ++ plugins/command.js | 186 ++++++++ plugins/commandblock.js | 106 +++++ plugins/commands/about.js | 79 ++++ plugins/commands/cb.js | 7 + plugins/commands/cloop.js | 90 ++++ plugins/commands/eval.js | 11 + plugins/commands/help.js | 12 + plugins/commands/logoff.js | 7 + plugins/commands/netmsg.js | 35 ++ plugins/commands/refill.js | 7 + plugins/commands/say.js | 8 + plugins/commands/serverinfo.js | 96 ++++ plugins/commands/stop.js | 7 + plugins/commands/template.js | 42 ++ plugins/commands/verify.js | 11 + plugins/console.js | 53 +++ plugins/cq.js | 22 + plugins/player.js | 48 ++ plugins/rejoin.js | 17 + plugins/sc.js | 34 ++ plugins/sc_cspy.js | 15 + plugins/sc_gamemode.js | 15 + plugins/sc_op.js | 18 + plugins/testing.js | 8 + settings2.json | 23 + util/Command.js | 24 + util/ConsoleCommand.js | 60 +++ util/chatparse.js | 133 ++++++ util/chatparse_1204.js | 11 + util/hashcheck.js | 19 + util/lang.js | 27 ++ util/lang/en-US.json | 72 +++ util/lang/he-IL.json | 72 +++ util/textformat.js | 17 + util/timeformat.js | 24 + util/usergen.js | 22 + util/uuidtoint.js | 5 + version.json | 3 + 47 files changed, 2704 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 README.md create mode 100755 index.js create mode 100755 launch.sh create mode 100755 package-lock.json create mode 100755 package.json create mode 100755 plugins/!chat.js create mode 100755 plugins/cloop.js create mode 100755 plugins/command.js create mode 100755 plugins/commandblock.js create mode 100644 plugins/commands/about.js create mode 100644 plugins/commands/cb.js create mode 100644 plugins/commands/cloop.js create mode 100644 plugins/commands/eval.js create mode 100644 plugins/commands/help.js create mode 100644 plugins/commands/logoff.js create mode 100644 plugins/commands/netmsg.js create mode 100644 plugins/commands/refill.js create mode 100644 plugins/commands/say.js create mode 100755 plugins/commands/serverinfo.js create mode 100644 plugins/commands/stop.js create mode 100644 plugins/commands/template.js create mode 100644 plugins/commands/verify.js create mode 100644 plugins/console.js create mode 100755 plugins/cq.js create mode 100644 plugins/player.js create mode 100755 plugins/rejoin.js create mode 100755 plugins/sc.js create mode 100755 plugins/sc_cspy.js create mode 100755 plugins/sc_gamemode.js create mode 100755 plugins/sc_op.js create mode 100755 plugins/testing.js create mode 100755 settings2.json create mode 100644 util/Command.js create mode 100644 util/ConsoleCommand.js create mode 100644 util/chatparse.js create mode 100644 util/chatparse_1204.js create mode 100644 util/hashcheck.js create mode 100644 util/lang.js create mode 100644 util/lang/en-US.json create mode 100644 util/lang/he-IL.json create mode 100644 util/textformat.js create mode 100755 util/timeformat.js create mode 100644 util/usergen.js create mode 100644 util/uuidtoint.js create mode 100644 version.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9f0b6e4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,153 @@ +# ---> VisualStudioCode +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +!.vscode/*.code-snippets + +# Local History for Visual Studio Code +.history/ + +# Built Visual Studio Code Extensions +*.vsix + +# ---> Kate +# Swap Files # +.*.kate-swp +.swp.* + +# ---> Node +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* +.pnpm-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) +web_modules/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional stylelint cache +.stylelintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variable files +.env +.env.development.local +.env.test.local +.env.production.local +.env.local + +# parcel-bundler cache (https://parceljs.org/) +.cache +.parcel-cache + +# Next.js build output +.next +out + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and not Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# vuepress v2.x temp and cache directory +.temp +.cache + +# Docusaurus cache and generated files +.docusaurus + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port + +# Stores VSCode versions used for testing VSCode extensions +.vscode-test + +# yarn v2 +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* + +# Bot Settings +settings.json \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..15549d6 --- /dev/null +++ b/LICENSE @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) 2024 7cc5c4f330d47060 + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..61e1c0d --- /dev/null +++ b/README.md @@ -0,0 +1,42 @@ +# botvX + +## Что это такое? + +botvX or UBot is a Minecraft bot for [Kaboom](https://kaboom.pw/) and its clones. It has many of the features that you would expect in a modern Kaboom bot: + +- commands (obviously) +- a self care system +- a command core, to run commands quickly + +## What does "botvX" mean? + +"botvX" means "bot version 10". The v is used to signify that whatever after it is a version, as was done with previous versions (botv4, botv6, botv8, botv9), and the X is the Roman numeral for 10, since this is the 10th major version. + +## What does "UBot" mean? + +"UBot" just means "UBot", but is based on an older bot name "UnnamedBot". On some older versions, this bot did not have a proper name. "UnnamedBot" was introduced in version 4, which was shortened to just "UBot" around version 8. + +## How to install? + +1. Download the latest release, or alternatively, download the latest development version using git clone https://10.0.0.151:3000/7cc5c4f330d47060/botvX/. +2. Extract the files if necessary. +3. Copy settings2.json to settings.json , and adjust the settings to fit your needs. Do not forget to also create a secrets file. +4. Run ./launch.sh to start a bot launcher, which will reload the bot when the process closes. + +## Command list + +| Name | Usage | Description | +|-|-|-| +| about | | About the bot | +| cb | \ | Run a command in a command block | +| cloop | add , remove , list, clear | Manage command loops | +| eval | \ | Run JavaScript code (must run through console)| +| help | [cmd] | Shows command help | +| logoff | | Disconnect and reconnect the bot from a server | +| netmsg | \ | Send a message to all servers the bot is connected to | +| refill | | Refill core | +| say | \ | Sends a message to chat | +| serverinfo | | Get system/bot info, similar to Kaboom's serverinfo command | +| stop | | Restart bot | +| template | | Used in development, does nothing | +| verify | | Check the hashing system | \ No newline at end of file diff --git a/index.js b/index.js new file mode 100755 index 0000000..f63275d --- /dev/null +++ b/index.js @@ -0,0 +1,77 @@ +const m = require('minecraft-protocol') +const settings = require('./settings.json') +const generateUser = require('./util/usergen.js') +const EventEmitter = require('node:events') +const fs = require('fs') + +module.exports.bot = [] + +const loadplug = (botno) => { + const botplug = [] + const bpl = fs.readdirSync('plugins') + for (const i in bpl) { + if (!bpl[i].endsWith('.js')) { + continue + } + try { + botplug.push(require(`./plugins/${bpl[i]}`)) + } catch (e) { console.log(e) } + } + botplug.forEach((plug) => { + try { + if (botno !== undefined) { + if (plug.loadBot) { + plug.loadBot(module.exports.bot[botno]) + } + } else { + plug.load() + } + } catch (e) { console.log(e) } + }) +} +loadplug() + +const createBot = function createBot (host, oldId) { + if (host.options.disabled) { + console.log(`Skipping server ${host.host}:${host.port}`) + return + } + const bot = new EventEmitter() + bot._client = m.createClient({ + host: host.host, + port: host.port ? host.port : 25565, + username: generateUser(host.options.legalName), + version: settings.version_mc + }) + bot._client.on('success', () => { + }) + if (typeof oldId !== 'undefined') { + for (const i in module.exports.bot[oldId].interval) { + clearInterval(module.exports.bot[oldId].interval[i]) + } + delete module.exports.bot[oldId] + bot.id = oldId + module.exports.bot[oldId] = bot + console.log('Re-creating bot ' + bot.id) + } else { + bot.id = module.exports.bot.length + module.exports.bot.push(bot) + console.log('Creating bot ' + bot.id) + } + + bot.host = host + bot.interval = {} + + bot.info = (msg) => { + console.log(`[${bot.id}] [info] ${msg}`) + } + loadplug(bot.id) + bot._client.on('error', (err) => { + console.log(err) + }) +} + +for (const i in settings.servers) { + createBot(settings.servers[i]) +} +module.exports.createBot = createBot diff --git a/launch.sh b/launch.sh new file mode 100755 index 0000000..e71eaf9 --- /dev/null +++ b/launch.sh @@ -0,0 +1,5 @@ +#!/bin/bash +while [ true ]; +do node index.js; +sleep 6; +done \ No newline at end of file diff --git a/package-lock.json b/package-lock.json new file mode 100755 index 0000000..7646b65 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,830 @@ +{ + "name": "botv10", + "version": "10.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "botv10", + "version": "10.0.0", + "license": "UNLICENSED", + "dependencies": { + "minecraft-protocol": "^1.45.0", + "prismarine-chat": "^1.10.0" + } + }, + "node_modules/@azure/msal-common": { + "version": "14.14.0", + "resolved": "https://registry.npmjs.org/@azure/msal-common/-/msal-common-14.14.0.tgz", + "integrity": "sha512-OxcOk9H1/1fktHh6//VCORgSNJc2dCQObTm6JNmL824Z6iZSO6eFo/Bttxe0hETn9B+cr7gDouTQtsRq3YPuSQ==", + "license": "MIT", + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/@azure/msal-node": { + "version": "2.12.0", + "resolved": "https://registry.npmjs.org/@azure/msal-node/-/msal-node-2.12.0.tgz", + "integrity": "sha512-jmk5Im5KujRA2AcyCb0awA3buV8niSrwXZs+NBJWIvxOz76RvNlusGIqi43A0h45BPUy93Qb+CPdpJn82NFTIg==", + "license": "MIT", + "dependencies": { + "@azure/msal-common": "14.14.0", + "jsonwebtoken": "^9.0.0", + "uuid": "^8.3.0" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/@types/node": { + "version": "20.14.12", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.12.tgz", + "integrity": "sha512-r7wNXakLeSsGT0H1AU863vS2wa5wBOK4bWMjZz2wj+8nBx+m5PeIn0k8AloSLpRuiwdRQZwarZqHE4FNArPuJQ==", + "license": "MIT", + "dependencies": { + "undici-types": "~5.26.4" + } + }, + "node_modules/@types/readable-stream": { + "version": "4.0.15", + "resolved": "https://registry.npmjs.org/@types/readable-stream/-/readable-stream-4.0.15.tgz", + "integrity": "sha512-oAZ3kw+kJFkEqyh7xORZOku1YAKvsFTogRY8kVl4vHpEKiDkfnSA/My8haRE7fvmix5Zyy+1pwzOi7yycGLBJw==", + "license": "MIT", + "dependencies": { + "@types/node": "*", + "safe-buffer": "~5.1.1" + } + }, + "node_modules/@xboxreplay/errors": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/@xboxreplay/errors/-/errors-0.1.0.tgz", + "integrity": "sha512-Tgz1d/OIPDWPeyOvuL5+aai5VCcqObhPnlI3skQuf80GVF3k1I0lPCnGC+8Cm5PV9aLBT5m8qPcJoIUQ2U4y9g==", + "license": "MIT" + }, + "node_modules/@xboxreplay/xboxlive-auth": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/@xboxreplay/xboxlive-auth/-/xboxlive-auth-3.3.3.tgz", + "integrity": "sha512-j0AU8pW10LM8O68CTZ5QHnvOjSsnPICy0oQcP7zyM7eWkDQ/InkiQiirQKsPn1XRYDl4ccNu0WM582s3UKwcBg==", + "license": "MIT", + "dependencies": { + "@xboxreplay/errors": "^0.1.0", + "axios": "^0.21.1" + } + }, + "node_modules/abort-controller": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", + "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", + "license": "MIT", + "dependencies": { + "event-target-shim": "^5.0.0" + }, + "engines": { + "node": ">=6.5" + } + }, + "node_modules/aes-js": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/aes-js/-/aes-js-3.1.2.tgz", + "integrity": "sha512-e5pEa2kBnBOgR4Y/p20pskXI74UEz7de8ZGVo58asOtvSVG5YAbJeELPZxOmt+Bnz3rX753YKhfIn4X4l1PPRQ==", + "license": "MIT" + }, + "node_modules/ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/asn1": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz", + "integrity": "sha512-6i37w/+EhlWlGUJff3T/Q8u1RGmP5wgbiwYnOnbOqvtrPxT63/sYFyP9RcpxtxGymtfA075IvmOnL7ycNOWl3w==", + "license": "MIT" + }, + "node_modules/axios": { + "version": "0.21.4", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz", + "integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==", + "license": "MIT", + "dependencies": { + "follow-redirects": "^1.14.0" + } + }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/buffer": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", + "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" + } + }, + "node_modules/buffer-equal": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/buffer-equal/-/buffer-equal-1.0.1.tgz", + "integrity": "sha512-QoV3ptgEaQpvVwbXdSO39iqPQTCxSF7A5U99AxbHYqUdCizL/lH2Z0A2y6nbZucxMEOtNyZfG2s6gsVugGpKkg==", + "license": "MIT", + "engines": { + "node": ">=0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/buffer-equal-constant-time": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", + "integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==", + "license": "BSD-3-Clause" + }, + "node_modules/commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "license": "MIT" + }, + "node_modules/debug": { + "version": "4.3.5", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.5.tgz", + "integrity": "sha512-pt0bNEmneDIvdL1Xsd9oDQ/wrQRkXDT4AUWlNZNPKvW5x/jyO9VFXkJUP07vQ2upmw5PlaITaPKc31jK13V+jg==", + "license": "MIT", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/discontinuous-range": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/discontinuous-range/-/discontinuous-range-1.0.0.tgz", + "integrity": "sha512-c68LpLbO+7kP/b1Hr1qs8/BJ09F5khZGTxqxZuhzxpmwJKOgRFHJWIb9/KmqnqHhLdO55aOxFH/EGBvUQbL/RQ==", + "license": "MIT" + }, + "node_modules/ecdsa-sig-formatter": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz", + "integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==", + "license": "Apache-2.0", + "dependencies": { + "safe-buffer": "^5.0.1" + } + }, + "node_modules/endian-toggle": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/endian-toggle/-/endian-toggle-0.0.0.tgz", + "integrity": "sha512-ShfqhXeHRE4TmggSlHXG8CMGIcsOsqDw/GcoPcosToE59Rm9e4aXaMhEQf2kPBsBRrKem1bbOAv5gOKnkliMFQ==", + "license": "MIT" + }, + "node_modules/event-target-shim": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", + "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/events": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", + "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==", + "license": "MIT", + "engines": { + "node": ">=0.8.x" + } + }, + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "license": "MIT" + }, + "node_modules/fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "license": "MIT" + }, + "node_modules/follow-redirects": { + "version": "1.15.6", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz", + "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "license": "MIT", + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, + "node_modules/ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "BSD-3-Clause" + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "license": "ISC" + }, + "node_modules/jose": { + "version": "4.15.9", + "resolved": "https://registry.npmjs.org/jose/-/jose-4.15.9.tgz", + "integrity": "sha512-1vUQX+IdDMVPj4k8kOxgUqlcK518yluMuGZwqlr44FS1ppZB/5GWh4rZG89erpOBOJjU/OBsnCVFfapsRz6nEA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/panva" + } + }, + "node_modules/json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "license": "MIT" + }, + "node_modules/jsonwebtoken": { + "version": "9.0.2", + "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-9.0.2.tgz", + "integrity": "sha512-PRp66vJ865SSqOlgqS8hujT5U4AOgMfhrwYIuIhfKaoSCZcirrmASQr8CX7cUg+RMih+hgznrjp99o+W4pJLHQ==", + "license": "MIT", + "dependencies": { + "jws": "^3.2.2", + "lodash.includes": "^4.3.0", + "lodash.isboolean": "^3.0.3", + "lodash.isinteger": "^4.0.4", + "lodash.isnumber": "^3.0.3", + "lodash.isplainobject": "^4.0.6", + "lodash.isstring": "^4.0.1", + "lodash.once": "^4.0.0", + "ms": "^2.1.1", + "semver": "^7.5.4" + }, + "engines": { + "node": ">=12", + "npm": ">=6" + } + }, + "node_modules/jwa": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/jwa/-/jwa-1.4.1.tgz", + "integrity": "sha512-qiLX/xhEEFKUAJ6FiBMbes3w9ATzyk5W7Hvzpa/SLYdxNtng+gcurvrI7TbACjIXlsJyr05/S1oUhZrc63evQA==", + "license": "MIT", + "dependencies": { + "buffer-equal-constant-time": "1.0.1", + "ecdsa-sig-formatter": "1.0.11", + "safe-buffer": "^5.0.1" + } + }, + "node_modules/jws": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/jws/-/jws-3.2.2.tgz", + "integrity": "sha512-YHlZCB6lMTllWDtSPHz/ZXTsi8S00usEV6v1tjq8tOUZzw7DpSDWVXjXDre6ed1w/pd495ODpHZYSdkRTsa0HA==", + "license": "MIT", + "dependencies": { + "jwa": "^1.4.1", + "safe-buffer": "^5.0.1" + } + }, + "node_modules/lodash.get": { + "version": "4.4.2", + "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", + "integrity": "sha512-z+Uw/vLuy6gQe8cfaFWD7p0wVv8fJl3mbzXh33RS+0oW2wvUqiRXiQ69gLWSLpgB5/6sU+r6BlQR0MBILadqTQ==", + "license": "MIT" + }, + "node_modules/lodash.includes": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz", + "integrity": "sha512-W3Bx6mdkRTGtlJISOvVD/lbqjTlPPUDTMnlXZFnVwi9NKJ6tiAk6LVdlhZMm17VZisqhKcgzpO5Wz91PCt5b0w==", + "license": "MIT" + }, + "node_modules/lodash.isboolean": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz", + "integrity": "sha512-Bz5mupy2SVbPHURB98VAcw+aHh4vRV5IPNhILUCsOzRmsTmSQ17jIuqopAentWoehktxGd9e/hbIXq980/1QJg==", + "license": "MIT" + }, + "node_modules/lodash.isinteger": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz", + "integrity": "sha512-DBwtEWN2caHQ9/imiNeEA5ys1JoRtRfY3d7V9wkqtbycnAmTvRRmbHKDV4a0EYc678/dia0jrte4tjYwVBaZUA==", + "license": "MIT" + }, + "node_modules/lodash.isnumber": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz", + "integrity": "sha512-QYqzpfwO3/CWf3XP+Z+tkQsfaLL/EnUlXWVkIk5FUPc4sBdTehEqZONuyRt2P67PXAk+NXmTBcc97zw9t1FQrw==", + "license": "MIT" + }, + "node_modules/lodash.isplainobject": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", + "integrity": "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==", + "license": "MIT" + }, + "node_modules/lodash.isstring": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz", + "integrity": "sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw==", + "license": "MIT" + }, + "node_modules/lodash.merge": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", + "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", + "license": "MIT" + }, + "node_modules/lodash.once": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz", + "integrity": "sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==", + "license": "MIT" + }, + "node_modules/lodash.reduce": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/lodash.reduce/-/lodash.reduce-4.6.0.tgz", + "integrity": "sha512-6raRe2vxCYBhpBu+B+TtNGUzah+hQjVdu3E17wfusjyrXBka2nBS8OH/gjVZ5PvHOhWmIZTYri09Z6n/QfnNMw==", + "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/minecraft-data": { + "version": "3.67.0", + "resolved": "https://registry.npmjs.org/minecraft-data/-/minecraft-data-3.67.0.tgz", + "integrity": "sha512-/hLeYXopx9o1UdViPPFenLJ3hT5S4qUEwLQM0MAHOIhqkAUGXdkl47O7ohG+f87DH3+cZksbbM61sTnSRsQpsA==", + "license": "MIT" + }, + "node_modules/minecraft-folder-path": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minecraft-folder-path/-/minecraft-folder-path-1.2.0.tgz", + "integrity": "sha512-qaUSbKWoOsH9brn0JQuBhxNAzTDMwrOXorwuRxdJKKKDYvZhtml+6GVCUrY5HRiEsieBEjCUnhVpDuQiKsiFaw==", + "license": "MIT" + }, + "node_modules/minecraft-protocol": { + "version": "1.47.0", + "resolved": "https://registry.npmjs.org/minecraft-protocol/-/minecraft-protocol-1.47.0.tgz", + "integrity": "sha512-IHL8faXLLIWv1O+2v2NgyKlooilu/OiSL9orI8Kqed/rZvVOrFPzs2PwMAYjpQX9gxLPhiSU19KqZ8CjfNuqhg==", + "license": "BSD-3-Clause", + "dependencies": { + "@types/readable-stream": "^4.0.0", + "aes-js": "^3.1.2", + "buffer-equal": "^1.0.0", + "debug": "^4.3.2", + "endian-toggle": "^0.0.0", + "lodash.get": "^4.1.2", + "lodash.merge": "^4.3.0", + "minecraft-data": "^3.55.0", + "minecraft-folder-path": "^1.2.0", + "node-fetch": "^2.6.1", + "node-rsa": "^0.4.2", + "prismarine-auth": "^2.2.0", + "prismarine-chat": "^1.10.0", + "prismarine-nbt": "^2.5.0", + "prismarine-realms": "^1.2.0", + "protodef": "^1.8.0", + "readable-stream": "^4.1.0", + "uuid-1345": "^1.0.1", + "yggdrasil": "^1.4.0" + }, + "engines": { + "node": ">=14" + } + }, + "node_modules/mojangson": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/mojangson/-/mojangson-2.0.4.tgz", + "integrity": "sha512-HYmhgDjr1gzF7trGgvcC/huIg2L8FsVbi/KacRe6r1AswbboGVZDS47SOZlomPuMWvZLas8m9vuHHucdZMwTmQ==", + "license": "MIT", + "dependencies": { + "nearley": "^2.19.5" + } + }, + "node_modules/moo": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/moo/-/moo-0.5.2.tgz", + "integrity": "sha512-iSAJLHYKnX41mKcJKjqvnAN9sf0LMDTXDEvFv+ffuRR9a1MIuXLjMNL6EsnDHSkKLTWNqQQ5uo61P4EbU4NU+Q==", + "license": "BSD-3-Clause" + }, + "node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "license": "MIT" + }, + "node_modules/nearley": { + "version": "2.20.1", + "resolved": "https://registry.npmjs.org/nearley/-/nearley-2.20.1.tgz", + "integrity": "sha512-+Mc8UaAebFzgV+KpI5n7DasuuQCHA89dmwm7JXw3TV43ukfNQ9DnBH3Mdb2g/I4Fdxc26pwimBWvjIw0UAILSQ==", + "license": "MIT", + "dependencies": { + "commander": "^2.19.0", + "moo": "^0.5.0", + "railroad-diagrams": "^1.0.0", + "randexp": "0.4.6" + }, + "bin": { + "nearley-railroad": "bin/nearley-railroad.js", + "nearley-test": "bin/nearley-test.js", + "nearley-unparse": "bin/nearley-unparse.js", + "nearleyc": "bin/nearleyc.js" + }, + "funding": { + "type": "individual", + "url": "https://nearley.js.org/#give-to-nearley" + } + }, + "node_modules/node-fetch": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", + "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "license": "MIT", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, + "node_modules/node-rsa": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/node-rsa/-/node-rsa-0.4.2.tgz", + "integrity": "sha512-Bvso6Zi9LY4otIZefYrscsUpo2mUpiAVIEmSZV2q41sP8tHZoert3Yu6zv4f/RXJqMNZQKCtnhDugIuCma23YA==", + "license": "MIT", + "dependencies": { + "asn1": "0.2.3" + } + }, + "node_modules/prismarine-auth": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/prismarine-auth/-/prismarine-auth-2.5.0.tgz", + "integrity": "sha512-CRv/pL6d/T+4cdjWS223PXG+ygHbz40Kef04L59SLMT+axNdAQro23eZZhgiIIu6u7rlvJcZYlIY93gFNtKxXA==", + "license": "MIT", + "dependencies": { + "@azure/msal-node": "^2.0.2", + "@xboxreplay/xboxlive-auth": "^3.3.3", + "debug": "^4.3.3", + "jose": "^4.1.4", + "node-fetch": "^2.6.1", + "smart-buffer": "^4.1.0", + "uuid-1345": "^1.0.2" + } + }, + "node_modules/prismarine-chat": { + "version": "1.10.1", + "resolved": "https://registry.npmjs.org/prismarine-chat/-/prismarine-chat-1.10.1.tgz", + "integrity": "sha512-XukYcuueuhDxzEXG7r8BZyt6jOObrPPB4JESCgb+/XenB9nExoSHF8eTQWWj8faKPLqm1dRQaYwFJlNBlJZJUw==", + "license": "MIT", + "dependencies": { + "mojangson": "^2.0.1", + "prismarine-nbt": "^2.0.0", + "prismarine-registry": "^1.4.0" + } + }, + "node_modules/prismarine-nbt": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/prismarine-nbt/-/prismarine-nbt-2.5.0.tgz", + "integrity": "sha512-F0/8UAa9SDDnAGrBYqZc4nG8h2zj5cE2eAJU5xlDR/IsQQ3moVxkOjE3h3nMv6SbvZrvAcgX7waA/nd9LLHYdA==", + "license": "MIT", + "dependencies": { + "protodef": "^1.9.0" + } + }, + "node_modules/prismarine-realms": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/prismarine-realms/-/prismarine-realms-1.3.2.tgz", + "integrity": "sha512-5apl9Ru8veTj5q2OozRc4GZOuSIcs3yY4UEtALiLKHstBe8bRw8vNlaz4Zla3jsQ8yP/ul1b1IJINTRbocuA6g==", + "license": "MIT", + "dependencies": { + "debug": "^4.3.3", + "node-fetch": "^2.6.1" + } + }, + "node_modules/prismarine-registry": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/prismarine-registry/-/prismarine-registry-1.7.0.tgz", + "integrity": "sha512-yyva0FpWI078nNeMhx8ekVza5uUTYhEv+C+ADu3wUQXiG8qhXkvrf0uzsnhTgZL8BLdsi2axgCEiKw9qSKIuxQ==", + "license": "MIT", + "dependencies": { + "minecraft-data": "^3.0.0", + "prismarine-nbt": "^2.0.0" + } + }, + "node_modules/process": { + "version": "0.11.10", + "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", + "integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==", + "license": "MIT", + "engines": { + "node": ">= 0.6.0" + } + }, + "node_modules/protodef": { + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/protodef/-/protodef-1.15.0.tgz", + "integrity": "sha512-bZ2Omw8dT+DACjJHLrBWZlqN4MlT9g9oSpJDdkUAJOStUzgJp+Zn42FJfPUdwutUxjaxA0PftN0PDlNa2XbneA==", + "license": "MIT", + "dependencies": { + "lodash.get": "^4.4.2", + "lodash.reduce": "^4.6.0", + "protodef-validator": "^1.3.0", + "readable-stream": "^3.0.3" + }, + "engines": { + "node": ">=14" + } + }, + "node_modules/protodef-validator": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/protodef-validator/-/protodef-validator-1.3.1.tgz", + "integrity": "sha512-lZ5FWKZYR9xOjpMw1+EfZRfCjzNRQWPq+Dk+jki47Sikl2EeWEPnTfnJERwnU/EwFq6us+0zqHHzSsmLeYX+Lg==", + "license": "MIT", + "dependencies": { + "ajv": "^6.5.4" + }, + "bin": { + "protodef-validator": "cli.js" + } + }, + "node_modules/protodef/node_modules/readable-stream": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", + "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", + "license": "MIT", + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/punycode": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/railroad-diagrams": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/railroad-diagrams/-/railroad-diagrams-1.0.0.tgz", + "integrity": "sha512-cz93DjNeLY0idrCNOH6PviZGRN9GJhsdm9hpn1YCS879fj4W+x5IFJhhkRZcwVgMmFF7R82UA/7Oh+R8lLZg6A==", + "license": "CC0-1.0" + }, + "node_modules/randexp": { + "version": "0.4.6", + "resolved": "https://registry.npmjs.org/randexp/-/randexp-0.4.6.tgz", + "integrity": "sha512-80WNmd9DA0tmZrw9qQa62GPPWfuXJknrmVmLcxvq4uZBdYqb1wYoKTmnlGUchvVWe0XiLupYkBoXVOxz3C8DYQ==", + "license": "MIT", + "dependencies": { + "discontinuous-range": "1.0.0", + "ret": "~0.1.10" + }, + "engines": { + "node": ">=0.12" + } + }, + "node_modules/readable-stream": { + "version": "4.5.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-4.5.2.tgz", + "integrity": "sha512-yjavECdqeZ3GLXNgRXgeQEdz9fvDDkNKyHnbHRFtOr7/LcfgBcmct7t/ET+HaCTqfh06OzoAxrkN/IfjJBVe+g==", + "license": "MIT", + "dependencies": { + "abort-controller": "^3.0.0", + "buffer": "^6.0.3", + "events": "^3.3.0", + "process": "^0.11.10", + "string_decoder": "^1.3.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + } + }, + "node_modules/ret": { + "version": "0.1.15", + "resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz", + "integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==", + "license": "MIT", + "engines": { + "node": ">=0.12" + } + }, + "node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "license": "MIT" + }, + "node_modules/semver": { + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/smart-buffer": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz", + "integrity": "sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg==", + "license": "MIT", + "engines": { + "node": ">= 6.0.0", + "npm": ">= 3.0.0" + } + }, + "node_modules/string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "license": "MIT", + "dependencies": { + "safe-buffer": "~5.2.0" + } + }, + "node_modules/string_decoder/node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", + "license": "MIT" + }, + "node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "license": "MIT" + }, + "node_modules/uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "license": "BSD-2-Clause", + "dependencies": { + "punycode": "^2.1.0" + } + }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", + "license": "MIT" + }, + "node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "license": "MIT", + "bin": { + "uuid": "dist/bin/uuid" + } + }, + "node_modules/uuid-1345": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/uuid-1345/-/uuid-1345-1.0.2.tgz", + "integrity": "sha512-bA5zYZui+3nwAc0s3VdGQGBfbVsJLVX7Np7ch2aqcEWFi5lsAEcmO3+lx3djM1npgpZI8KY2FITZ2uYTnYUYyw==", + "license": "MIT", + "dependencies": { + "macaddress": "^0.5.1" + } + }, + "node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", + "license": "BSD-2-Clause" + }, + "node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "license": "MIT", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, + "node_modules/yggdrasil": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/yggdrasil/-/yggdrasil-1.7.0.tgz", + "integrity": "sha512-QBIo5fiNd7688G3FqXXYGr36uyrYzczlNuzpWFy2zL3+R+3KT2lF+wFxm51synfA3l3z6IBiGOc1/EVXWCYY1Q==", + "license": "MIT", + "dependencies": { + "node-fetch": "^2.6.1", + "uuid": "^8.2.0" + } + } + } +} diff --git a/package.json b/package.json new file mode 100755 index 0000000..fb310c1 --- /dev/null +++ b/package.json @@ -0,0 +1,15 @@ +{ + "dependencies": { + "minecraft-protocol": "^1.45.0", + "prismarine-chat": "^1.10.0" + }, + "name": "botv10", + "version": "10.0.0", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "UNLICENSED", + "description": "" +} diff --git a/plugins/!chat.js b/plugins/!chat.js new file mode 100755 index 0000000..0a9e7ae --- /dev/null +++ b/plugins/!chat.js @@ -0,0 +1,101 @@ +const console2 = require('./console.js') +const parse = require('../util/chatparse.js') +const parse1204 = require('../util/chatparse_1204.js') +const messageTypes = [ + '', + 'chat.type.emote', + 'commands.message.display.incoming', + '', + '', + 'chat.type.announcement', + '', + '' +] +module.exports = { + load: () => { + + }, + loadBot: (b) => { + b._client.on('profileless_chat', (data) => { + if (data.type === 4) { + const json = parse1204(data.message) + const parsed = parse(json)[1] + const split = parsed.split(': ') + const chatName = split.splice(0, 1)[0] + const username = b.findRealName(chatName) + const uuid = b.findUUID(username) + b.emit('chat', { json, type: 'profileless', uuid, message: split.join(': '), username }) + } else { + b.emit('chat', { + json: { + translate: messageTypes[data.type], + color: data.type === 2 ? 'gray' : 'reset', + with: [ + parse1204(data.name), + parse1204(data.message) + ] + }, + type: 'profileless', + uuid: '00000000-0000-0000-0000-000000000000', + message: parse(parse1204(data.message))[1], + username: parse(parse1204(data.name))[1] + }) + } + }) + + b._client.on('player_chat', (data) => { + if (data.type === 4) { + b.emit('chat', { json: parse1204(data.unsignedChatContent), type: 'player', uuid: data.senderUuid, message: data.plainMessage, username: parse(parse1204(data.networkName))[1] }) + } else { + b.emit('chat', { + json: { + translate: messageTypes[data.type], + color: data.type === 2 ? 'gray' : 'reset', + with: [ + parse1204(data.networkName), + data.plainMessage + ] + }, + type: 'player', + uuid: data.senderUuid, + message: parse(data.plainMessage)[1], + username: parse(parse1204(data.networkName))[1] + }) + } + }) + b._client.on('system_chat', (data) => { + const json = parse1204(data.content) + const parsed = parse(json)[1] + const split = parsed.split(': ') + const chatName = split.splice(0, 1)[0] + const username = b.findRealName(chatName) + const uuid = b.findUUID(username) + b.emit('chat', { json, type: 'system', uuid, message: split.join(': '), username }) + }) + b._client.on('chat', (data) => { // Legacy chat + const json = parse1204(data.message) + const parsed = parse(json)[1] + const split = parsed.split(': ') + const chatName = split.splice(0, 1)[0] + const username = b.findRealName(chatName) + const uuid = b.findUUID(username) + b.emit('chat', { json, type: 'legacy', uuid: data.uuid ? data.uuid : uuid, message: split.join(': '), username }) + }) + b.on('chat', (data) => { + const msg = parse(data.json) + if (msg[1].endsWith('\n\n\n\n\nThe chat has been cleared')) return + if (msg[1].startsWith('Command set: ')) return + b.emit('plainchat', msg[1]) + console2.write(`[${b.id}] [${data.type}] ` + msg[0]) + const fullCommand = data.message + + for (const i in b.prefix) { + if (fullCommand.startsWith(b.prefix[i])) { + const command = fullCommand.slice(b.prefix[i].length) + b.runCommand(data.username, data.uuid, command, b.prefix[i]) + } + } + }) + }, + parse +} diff --git a/plugins/cloop.js b/plugins/cloop.js new file mode 100755 index 0000000..3388db7 --- /dev/null +++ b/plugins/cloop.js @@ -0,0 +1,26 @@ +module.exports = { + load: () => { + + }, + loadBot: (b) => { + b.cloops = [] + b.addCloop = function (command, rate) { + b.cloops.push({ + command, + rate, + interval: setInterval(() => { b.ccq.push(command) }, rate) + }) + b.ccq.push(command) + } + b.removeCloop = function (index) { + clearInterval(b.cloops[index].interval) + b.cloops.splice(index, 1) + } + b.clearCloops = function () { + for (const i in b.cloops) { + clearInterval(b.cloops[i].interval) + } + b.cloops = [] + } + } +} diff --git a/plugins/command.js b/plugins/command.js new file mode 100755 index 0000000..8bd2e35 --- /dev/null +++ b/plugins/command.js @@ -0,0 +1,186 @@ +const fs = require('fs') +const Command = require('../util/Command.js') +const hashcheck = require('../util/hashcheck.js') +const settings = require('../settings.json') +const getMessage = require('../util/lang.js') +const cmds = Object.create(null) +const sortHelp = function sortHelp (c1, c2) { + const level1 = cmds[c1.with[1]].level ? cmds[c1.with[1]].level : 0 + const level2 = cmds[c2.with[1]].level ? cmds[c2.with[1]].level : 0 + return level1 - level2 +} +module.exports = { + load: () => { + module.exports.loadCMD() + }, + loadBot: (b) => { + b.prefix = settings.prefix + b.lastCmd = 0 + b.runCommand = (name, uuid, text, prefix) => { + if (uuid === '00000000-0000-0000-0000-000000000000') return + if (Date.now() - b.lastCmd <= 1000) return + b.lastCmd = Date.now() + const cmd = text.split(' ') + const lang = settings.defaultLang + const verify = hashcheck(cmd) + if (verify > 0) { + text = cmd.slice(0, cmd.length - 1).join(' ') + } + if (cmds[cmd[0].toLowerCase()]) { + const command = cmds[cmd[0].toLowerCase()] + if (command.level !== undefined && command.level > verify) { + b.tellraw(uuid, { + text: getMessage(lang, 'command.disallowed.perms') + }) + b.tellraw(uuid, { + text: getMessage(lang, 'command.disallowed.perms.yourLevel', [verify + '']) + }) + b.tellraw(uuid, { + text: getMessage(lang, 'command.disallowed.perms.cmdLevel', [command.level + '']) + }) + return + } + try { + cmds[cmd[0].toLowerCase()].execute(new Command(uuid, name, 'nick N/A', text, prefix, b, verify)) + } catch (e) { + console.log(e) + b.tellraw(uuid, { + text: getMessage(lang, 'command.error'), + color: 'red', + hoverEvent: { + action: 'show_text', + value: { + text: e.stack + } + } + }) + } + } + } + b.printHelp = (uuid, prefix, lang) => { + const commandList = [] + for (const i in cmds) { + if (cmds[i].hidden) continue + let cmdColor + switch (cmds[i].level) { + case 0: + cmdColor = 'green' + break + case 1: + cmdColor = 'red' + break + case 2: + cmdColor = 'dark_red' + break + case 3: + cmdColor = 'dark_gray' + break + default: + cmdColor = 'gray' + } + commandList.push( + { + translate: '%s%s ', + color: cmdColor, + with: [ + prefix, + i + ] + } + ) + } + b.tellraw(uuid, { + translate: '%s: %s', + with: [ + getMessage(lang, 'command.help.cmdList'), + commandList.sort(sortHelp) + ] + }) + } + b.printCmdHelp = (uuid, cmd, lang, color) => { + if (!cmds[cmd]) { + b.tellraw(uuid, { text: getMessage(lang, 'command.help.noCommand') }) + return + } + let usage = getMessage(lang, `command.${cmd}.usage`).split('||') + let desc = getMessage(lang, `command.${cmd}.desc`) + if (cmds[cmd].usage) { + usage = cmds[cmd].usage.split('||') + } + if (cmds[cmd].desc) { + desc = cmds[cmd].desc + } + // b.tellraw(uuid,{"text":getMessage(lang,"command.help.commandInfo",[cmd,usage,desc])}); + for (const i in usage) { + b.tellraw(uuid, { + translate: getMessage(lang, 'command.help.commandUsage'), + color: color.secondary, + with: [ + { + text: cmd, + color: color.primary + }, + { + text: usage[i], + color: color.primary + } + ] + }) + } + b.tellraw(uuid, { + translate: getMessage(lang, 'command.help.commandDesc'), + color: color.secondary, + with: [ + { + text: desc, + color: color.primary + } + ] + }) + const permsN = getMessage(lang, 'command.help.permsNormal') + const permsT = getMessage(lang, 'command.help.permsTrusted') + const permsO = getMessage(lang, 'command.help.permsOwner') + const permsC = getMessage(lang, 'command.help.permsConsole') + const rPerms = cmds[cmd].level ? cmds[cmd].level : 0 + b.tellraw(uuid, { + translate: getMessage(lang, 'command.help.commandPerms'), + color: color.secondary, + with: [ + { + text: [permsN, permsT, permsO, permsC][rPerms], + color: color.primary + } + ] + }) + } + }, + loadCMD: () => { + const bpl = fs.readdirSync('./plugins/commands') + for (const i in bpl) { + if (!bpl[i].endsWith('.js')) { + continue + } + try { + const commandName = bpl[i].split('.js')[0] + cmds[commandName] = require(`./commands/${bpl[i]}`) + if (cmds[commandName].level === undefined) { + cmds[commandName].level = 0 + } + console.log('Loaded command ' + commandName) + if (cmds[commandName].aliases) { + for (const j in cmds[commandName].aliases) { + cmds[cmds[commandName].aliases[j]] = { + execute: cmds[commandName].execute, + desc: 'Alias to ' + commandName, + usage: cmds[commandName].usage, + level: cmds[commandName].level, + hidden: true, + consoleIndex: cmds[commandName].consoleIndex + } + } + } + } catch (e) { console.log(e) } + } + }, + cmds +} diff --git a/plugins/commandblock.js b/plugins/commandblock.js new file mode 100755 index 0000000..d6f83cf --- /dev/null +++ b/plugins/commandblock.js @@ -0,0 +1,106 @@ +const uuidToInt = require('../util/uuidtoint.js') +module.exports = { + cs: 4, + cs_v: 6, + load: function () { + + }, + loadBot: function (b) { + b.interval.commandFill = setInterval(() => { if (b.sc_tasks.cc) b.sc_tasks.cc.failed = 1 }, 60000) + b.ccq = [] + b.blocknoX = 0 + b.blocknoZ = 0 + b.ccStarted = 0 + b.blocknoY = 0 + b.pos = { x: 0, y: 0, z: 0, correct: 0 } + + b.advanceccq = function () { + if (b.ccq[0] && b.ccq[0].length !== 0) { + b._client.write('update_command_block', { + command: b.ccq[0], + location: { + x: b.commandPos.x1 + b.blocknoX, + y: b.commandPos.y1 + b.blocknoY, + z: b.commandPos.z1 + b.blocknoZ + }, + mode: 2, + flags: 1 + }) + b._client.write('update_command_block', { + command: b.ccq[0], + location: { + x: b.commandPos.x1 + b.blocknoX, + y: b.commandPos.y1 + b.blocknoY, + z: b.commandPos.z1 + b.blocknoZ + }, + mode: 2, + flags: 5 + }) + b.blocknoX++ + if (b.blocknoX === module.exports.cs) { + b.blocknoY++ + b.blocknoX = 0 + if (b.blocknoY === module.exports.cs_v) { + b.blocknoZ++ + b.blocknoY = 0 + if (b.blocknoZ === module.exports.cs) { + b.blocknoZ = 0 + } + } + } + } + b.ccq.splice(0, 1) + } + b._client.on('login', () => { + b.add_sc_task('cc', '/fill ~ 55 ~ ~3 60 ~3 command_block{CustomName:\'{"translate":"%s %s","with":[{"translate":"entity.minecraft.ender_dragon"},{"translate":"language.region"}],"color":"#FFAAEE"}\'}', true, true) + b.add_sc_task('cc_size', '/gamerule commandModificationBlockLimit 32767', true, false, true) + }) + b.on('ccstart', () => { + setTimeout(() => { b.interval.ccqi = setInterval(b.advanceccq, 3) }, 1000) // 1 Second and 3 Milliseconds + b.ccStarted = true + }) + b.on('chat', (data) => { + if (data.json.translate === 'commands.fill.failed' || (data.json.extra && data.json.extra[0] && data.json.extra[0].translate === 'commands.fill.failed') || + data.json.translate === 'commands.fill.success' || (data.json.extra && data.json.extra[0] && data.json.extra[0].translate === 'commands.fill.success')) { + if (!b.ccStarted) { + b.emit('ccstart') + } + b.sc_tasks.cc.failed = 0 + b.sc_tasks.cc_size.failed = 0 + } else if (data.json.translate === 'commands.fill.toobig' || (data.json.extra && data.json.extra[0] && data.json.extra[0].translate === 'commands.fill.toobig')) { + b.sc_tasks.cc_size.failed = 1 + } + }) + b._client.on('position', function (a) { + if (!b.ccStarted) { + b.original_pos = { x: a.x, y: a.y, z: a.z } + b.pos = { x: a.x, y: a.y, z: a.z, correct: 1 } + } else { + b.pos = { x: a.x, y: a.y, z: a.z, correct: 1 } + if (a.x !== b.original_pos.x || a.z !== b.original_pos.z) { + b.original_pos = { x: a.x, y: a.y, z: a.z } + b.pos.correct = 0 + b.sc_tasks.cc.failed = 1 + } + } + + b.commandPos = { + x1: Math.floor(a.x), + z1: Math.floor(a.z), + y1: 55 + } + b._client.write('teleport_confirm', { teleportId: a.teleportId }) + }) + b.tellraw = (uuid, message) => { + let finalname = '' + if (uuid === '@a') { + finalname = '@a' + } else if (uuid.match(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/)) { + finalname = `@a[nbt={UUID:[I;${uuidToInt(uuid)}]}]` + } else { + finalname = uuid + } + b.ccq.push(`/minecraft:tellraw ${finalname} ${JSON.stringify(message)}`) + } + } +} diff --git a/plugins/commands/about.js b/plugins/commands/about.js new file mode 100644 index 0000000..40df25c --- /dev/null +++ b/plugins/commands/about.js @@ -0,0 +1,79 @@ +const version = require('../../version.json') +const settings = require('../../settings.json') +const getMessage = require('../../util/lang.js') +const cp = require('child_process') +module.exports = { + execute: function (c) { + c.reply({ + translate: getMessage(c.lang, 'command.about.author'), + color: c.colors.secondary, + with: [ + { + text: settings.name, + color: c.colors.primary + } + ] + }) + c.reply({ text: '' }) + const botVersion = version.bot + let gitCommit + try { + gitCommit = cp.execSync('git rev-parse --short HEAD').toString('UTF-8').split('\n')[0] + } catch (e) { + gitCommit = false + } + if (gitCommit) { + c.reply({ + translate: getMessage(c.lang, 'command.about.version'), + color: c.colors.secondary, + with: [ + [ + { + text: botVersion, + color: c.colors.primary + }, + { + translate: ' (%s)', + color: 'white', + with: [ + { + text: gitCommit, + color: c.colors.primary + } + ] + } + ] + ] + }) + } else { + c.reply({ + translate: getMessage(c.lang, 'command.about.version'), + color: c.colors.secondary, + with: [ + { + text: botVersion, + color: c.colors.primary + } + ] + }) + } + c.reply({ text: '' }) + c.reply({ + translate: getMessage(c.lang, 'command.about.serverinfo'), + color: c.colors.secondary, + with: [ + { + translate: '"%s"', + color: 'white', + with: [ + { + text: 'serverinfo', + color: c.colors.primary + } + ] + } + ] + }) + }, + aliases: ['info'] +} diff --git a/plugins/commands/cb.js b/plugins/commands/cb.js new file mode 100644 index 0000000..c089a84 --- /dev/null +++ b/plugins/commands/cb.js @@ -0,0 +1,7 @@ +module.exports = { + execute: (c) => { + c.bot.ccq.push(c.args.join(' ')) + }, + consoleIndex: true, + aliases: ['commandblock', 'cmdblock'] +} diff --git a/plugins/commands/cloop.js b/plugins/commands/cloop.js new file mode 100644 index 0000000..fc1a29c --- /dev/null +++ b/plugins/commands/cloop.js @@ -0,0 +1,90 @@ +const getMessage = require('../../util/lang.js') +module.exports = { + execute: (c) => { + const subcmd = c.args.splice(0, 1)[0] + switch (subcmd) { + case 'add': { + const rate = +(c.args.splice(0, 1)[0]) + const command = c.args.join(' ') + if (rate < 20) { + c.reply({ + text: getMessage(c.lang, 'command.cloop.error.tooShort') + }) + } + c.bot.addCloop(command, rate) + c.reply({ + translate: getMessage(c.lang, 'command.cloop.success.add'), + color: c.colors.secondary, + with: [ + { + text: command, + color: c.colors.primary + }, + { + text: rate + '', + color: c.colors.primary + } + ] + }) + break + } + case 'remove': { + const index = +c.args[0] + c.bot.removeCloop(c.args[0]) + c.reply({ + translate: getMessage(c.lang, 'command.cloop.success.remove'), + color: c.colors.secondary, + with: [ + { + text: index + '', + color: c.colors.primary + } + ] + }) + break + } + case 'list': + for (const i in c.bot.cloops) { + c.reply({ + translate: getMessage(c.lang, 'command.cloop.list'), + color: c.colors.secondary, + with: [ + { + text: i, + color: c.colors.primary + }, + { + text: c.bot.cloops[i].command, + color: c.colors.primary + }, + { + text: c.bot.cloops[i].rate + '', + color: c.colors.primary + } + ] + }) + } + break + case 'clear': + c.bot.clearCloops() + c.reply({ + text: getMessage(c.lang, 'command.cloop.success.clear'), + color: c.colors.secondary + }) + break + default: + c.reply({ + translate: getMessage(c.lang, 'command.cloop.error.subcommand'), + color: c.colors.secondary, + with: [ + { + text: `${c.prefix}help cloop`, + color: c.colors.primary + } + ] + }) + } + }, + consoleIndex: true, + level: 1 +} diff --git a/plugins/commands/eval.js b/plugins/commands/eval.js new file mode 100644 index 0000000..8ed1fa9 --- /dev/null +++ b/plugins/commands/eval.js @@ -0,0 +1,11 @@ +const index = require('../../index.js') // Not used in the code, but may be used by users of the command +module.exports = { + execute: (c) => { + try { + console.log(eval(c.args.join(' '))) + } catch (e) { + console.error(e) + } + }, + level: 3 +} diff --git a/plugins/commands/help.js b/plugins/commands/help.js new file mode 100644 index 0000000..dc48e31 --- /dev/null +++ b/plugins/commands/help.js @@ -0,0 +1,12 @@ +module.exports = { + execute: (c) => { + if (c.args.length > 0) { + c.bot.printCmdHelp(c.uuid, c.args[0], c.lang, c.colors) + } else { + c.bot.printHelp(c.uuid, c.prefix, c.lang, c.colors) + } + }, + aliases: [ + 'heko' // Parker2991 request + ] +} diff --git a/plugins/commands/logoff.js b/plugins/commands/logoff.js new file mode 100644 index 0000000..e05cae0 --- /dev/null +++ b/plugins/commands/logoff.js @@ -0,0 +1,7 @@ +module.exports = { + execute: (c) => { + c.bot._client.end() + }, + consoleIndex: true, + level: 2 +} diff --git a/plugins/commands/netmsg.js b/plugins/commands/netmsg.js new file mode 100644 index 0000000..b3acbac --- /dev/null +++ b/plugins/commands/netmsg.js @@ -0,0 +1,35 @@ +const { bot } = require('../../index.js') +module.exports = { + execute: (c) => { + const json = { + translate: '[%s] %s: %s', + with: [ + { + translate: '%s:%s', + with: [ + { + text: c.host, + color: c.colors.primary + }, + { + text: c.port + '', + color: c.colors.primary + } + ], + color: c.colors.secondary + }, + { + text: c.username, + color: c.colors.primary + }, + { + text: c.args.join(' ') + } + ], + color: 'white' + } + for (const i in bot) { + bot[i].tellraw('@a', json) + } + } +} diff --git a/plugins/commands/refill.js b/plugins/commands/refill.js new file mode 100644 index 0000000..b626b05 --- /dev/null +++ b/plugins/commands/refill.js @@ -0,0 +1,7 @@ +module.exports = { + execute: (c) => { + c.bot.chat('/fill ~ 55 ~ ~3 60 ~3 command_block{CustomName:\'{"translate":"%s %s","with":[{"translate":"entity.minecraft.ender_dragon"},{"translate":"language.region"}],"color":"#FFAAEE"}\'}') + }, + consoleIndex: true, + aliases: ['refillcore', 'rc'] +} diff --git a/plugins/commands/say.js b/plugins/commands/say.js new file mode 100644 index 0000000..e6bc74f --- /dev/null +++ b/plugins/commands/say.js @@ -0,0 +1,8 @@ +module.exports = { + execute: (c) => { + if (c.args[0].startsWith('/') && c.verify < 1) return + c.bot.chat(c.args.join(' ')) + }, + consoleIndex: true, + aliases: ['echo'] +} diff --git a/plugins/commands/serverinfo.js b/plugins/commands/serverinfo.js new file mode 100755 index 0000000..fa50f6e --- /dev/null +++ b/plugins/commands/serverinfo.js @@ -0,0 +1,96 @@ +const os = require('os') +const cp = require('child_process') +const settings = require('../../settings.json') +const timeformat = require('../../util/timeformat.js') +const version = require('../../version.json') +const getMessage = require('../../util/lang.js') +const fs = require('fs') +const gr = function (l, text, value, color) { + if (!color) color = 'white' + return { + translate: '%s: %s', + color: color.primary, + with: [ + { + text, + color: color.secondary + }, + { + text: value, + color: color.primary + } + ], + hoverEvent: { + action: 'show_text', + contents: { + text: getMessage(l, 'copyText') + } + }, + clickEvent: { + action: 'copy_to_clipboard', + value + } + } +} + +const os2 = function (o2, l) { + switch (o2) { + case 'win32': + return os.version() + case 'android': + return getMessage(l, 'command.serverinfo.os.android') + case 'linux': + return getMessage(l, 'command.serverinfo.os.linux', [os.release()]) + default: + return o2 + } +} +module.exports = { + execute: function (c) { + c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.os'), os2(process.platform, c.lang), c.colors)) + if (os.cpus()[0]) c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.processor'), os.cpus()[0].model, c.colors)) + c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.arch'), os.machine(), c.colors)) + c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.osUsername'), `${os.userInfo().username} (${os.userInfo().uid})`, c.colors)) + c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.hostName'), os.hostname(), c.colors)) + c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.workingDir'), process.cwd(), c.colors)) + c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.runTime'), timeformat(process.uptime() * 1000), c.colors)) + c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.upTime'), timeformat(os.uptime() * 1000), c.colors)) + c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.nodeVersion'), process.version, c.colors)) + if (process.platform === 'linux' || process.platform === 'freebsd') { + try { + const osrelease = fs.readFileSync('/etc/os-release').toString('UTF-8').split('\n') + const osrelease2 = {} + for (const i in osrelease) { + if (!osrelease[i].includes('=')) continue + let osrvalue = osrelease[i].split('=')[1] + if (osrvalue.startsWith('"') && osrvalue.endsWith('"')) { osrvalue = osrvalue.slice(1, osrvalue.length - 1) }; + osrelease2[osrelease[i].split('=')[0]] = osrvalue + } + + if (osrelease2.PRETTY_NAME) { + c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.osRelease'), osrelease2.PRETTY_NAME, c.colors)) + } + } catch (e) { + c.reply({ text: getMessage(c.lang, 'command.serverinfo.osRelease.missing') }) + } + } else if (process.platform === 'android') { + const androidVersion = cp.execSync('getprop ro.build.version.release').toString('UTF-8').split('\n')[0] + c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.os.android.version'), androidVersion, c.colors)) + const dModel = cp.execSync('getprop ro.product.model').toString('UTF-8').split('\n')[0] + const dBrand = cp.execSync('getprop ro.product.brand').toString('UTF-8').split('\n')[0] + c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.os.android.model'), dBrand + ' ' + dModel, c.colors)) + } + c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.botName'), settings.name, c.colors)) + let botVersion = version.bot + let gitCommit + try { + gitCommit = cp.execSync('git rev-parse --short HEAD').toString('UTF-8').split('\n')[0] + } catch (e) { + gitCommit = false + } + if (gitCommit) { + botVersion += ` (${gitCommit})` + } + c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.botVer'), botVersion, c.colors)) + } +} diff --git a/plugins/commands/stop.js b/plugins/commands/stop.js new file mode 100644 index 0000000..7f2309a --- /dev/null +++ b/plugins/commands/stop.js @@ -0,0 +1,7 @@ +module.exports = { + execute: (c) => { + process.exit(0) + }, + aliases: ['restart', 'exit'], + level: 2 +} diff --git a/plugins/commands/template.js b/plugins/commands/template.js new file mode 100644 index 0000000..cf8e31a --- /dev/null +++ b/plugins/commands/template.js @@ -0,0 +1,42 @@ +module.exports = { + execute: (c) => { + // Blank template + /* + c.send(text, user?): Send text to all ("/tellraw @a") + c.reply(text): Send text to command sender + c.uuid: Unique identifier (UUID for Minecraft, Discord ID for Discord) + c.username: Username of sender + c.nickname: Nickname of sender when applicable + c.command: Command string + c.args: Arguments of command (above without the first section, and split at every space) + c.prefix: Prefix being used to send the command (when applicable) + c.bot: Bot that received the command. Will be different type based on where it was received + c.type: Type of bot receiving the command ("minecraft", "console", "discord") + c.lang: The language the player has selected, or the default if none + c.colors: The color palette the player has selected, or the default if none + */ + }, + /* + Command description and usage have been moved to the message files. The format for a basic command is: + "command.(name).usage": " [optional]", + "command.(name).desc": "Insert description here...", + replacing (name) with the name of the new command. + Some more complex commands may have messages of their own, which should be placed there too. + First, insert the following line near the top of the command's file (not in the execute function): + const getMessage = require('../../util/lang.js') + Then, to get a specific message: + getMessage(c.lang,"(message key)",[(arguments, in an array (optional))]) + For example, this will show the "about" command's redirection to "serverinfo": + getMessage(c.lang,"command.about.serverinfo") + The with array can be used to add information to a message. For example: + getMessage(lang,"command.help.commandInfo",["cmd","usage","desc"]) + shows the "help" command's formatting for command information, with some strings as items. + That message would render as (in en-US): + cmdusage - desc + Extra information is inserted wherever there is a "%s" or a "%n$s", with n being the index of the item in the array. + */ + hidden: true, // To show the command on the help command list, remove this line (optional) + consoleIndex: true, // When run from console, the second argument will be a bot ID (optional) + aliases: ['example', 'testing'], // Other command names that will work the same (optional) + level: 0 // Permission level required to run this command (optional) +} diff --git a/plugins/commands/verify.js b/plugins/commands/verify.js new file mode 100644 index 0000000..f1941a2 --- /dev/null +++ b/plugins/commands/verify.js @@ -0,0 +1,11 @@ +module.exports = { + execute: (c) => { + c.reply({ + text: c.verify + '' + }) + c.reply({ + text: c.command + }) + }, + level: 1 +} diff --git a/plugins/console.js b/plugins/console.js new file mode 100644 index 0000000..efc8416 --- /dev/null +++ b/plugins/console.js @@ -0,0 +1,53 @@ +const readln = require('readline') +const index = require('../index.js') +const ConsoleCommand = require('../util/ConsoleCommand.js') +const newercommands = require('./command.js').cmds +let rl +function consoleWrite (text) { + readln.cursorTo(process.stdout, 0) + readln.clearLine(process.stdout, 0) + process.stdout.write(text + '\n') + rl.prompt(true) +} +module.exports = { + load: () => { + rl = readln.createInterface({ + input: process.stdin, + output: process.stdout, + prompt: '\x1b[0m\x1b[38;5;15m> ' + }) + rl.on('line', (l) => { + try { + if (newercommands[l.split(' ')[0].toLowerCase()]) { + if (newercommands[l.split(' ')[0].toLowerCase()].consoleIndex) { + const tmpcmd = l.split(' ') + const index2 = tmpcmd.splice(1, 1)[0] + if (index2 === '*') { + for (let i = 0; i < index.bot.length; i++) { + const cmd = new ConsoleCommand(tmpcmd.join(' '), i) + newercommands[l.split(' ')[0].toLowerCase()].execute(cmd) + } + } else { + const cmd = new ConsoleCommand(tmpcmd.join(' '), +index2) + newercommands[l.split(' ')[0].toLowerCase()].execute(cmd) + } + } else { + const cmd = new ConsoleCommand(l, -2) + newercommands[l.split(' ')[0].toLowerCase()].execute(cmd) + } + } + } catch (e) { + console.log(e) + } + rl.prompt(false) + }) + rl.prompt() + }, + loadBot: (b) => { + b.info = (msg) => { + consoleWrite(`[${b.id}] [info] ${msg}`) + } + }, + rl, + write: consoleWrite +} diff --git a/plugins/cq.js b/plugins/cq.js new file mode 100755 index 0000000..93fc94b --- /dev/null +++ b/plugins/cq.js @@ -0,0 +1,22 @@ +module.exports = { + load: () => { + + }, + loadBot: (b) => { + b._client.on('login', () => { + b.interval.chatQueue = setInterval(() => { + if (b.chatqueue.length !== 0) { + b._client.chat(b.chatqueue[0]) + b.chatqueue.splice(0, 1) + } + }, 150) + }) + b.chatqueue = [] + b.chat = function chat (msg) { + if (msg.length === 0) return + msg.match(/.{1,250}/g).forEach(element => { + b.chatqueue.push(element) + }) + } + } +} diff --git a/plugins/player.js b/plugins/player.js new file mode 100644 index 0000000..136248c --- /dev/null +++ b/plugins/player.js @@ -0,0 +1,48 @@ +const parse = require('../util/chatparse.js') +const parse1204 = require('../util/chatparse_1204.js') +module.exports = { + load: () => { + }, + loadBot: (b) => { + b.players = {} + b._client.on('player_info', (data) => { + const buffer2 = {} + for (const i in data.data) { + let uuid + if (data.data[i].uuid) { + uuid = data.data[i].uuid + } else if (data.data[i].UUID) { + uuid = data.data[i].UUID + } + if (data.data[i].player && data.data[i].player.name !== undefined) { + buffer2[uuid] = { realName: data.data[i].player.name, displayName: parse(parse1204(data.data[i].displayName))[1] } + } else if (data.data[i].name !== undefined) { + buffer2[uuid] = { realName: data.data[i].name, displayName: parse(parse1204(data.data[i].displayName))[1] } + } else if (data.data[i].displayName !== undefined) { + buffer2[uuid] = { displayName: parse(parse1204(data.data[i].displayName))[1] } + } + } + for (const uuid in buffer2) { + if (!b.players[uuid]) b.players[uuid] = { displayName: '', realName: '' } + if (buffer2[uuid].displayName) b.players[uuid].displayName = buffer2[uuid].displayName + if (buffer2[uuid].realName) b.players[uuid].realName = buffer2[uuid].realName + } + }) + b.findUUID = (name) => { + for (const i in b.players) { + if (b.players[i].realName === name) { + return i + } + } + return '00000000-0000-0000-0000-000000000000' + } + b.findRealName = (name) => { + for (const i in b.players) { + if (b.players[i].displayName === name) { + return b.players[i].realName + } + } + return 'Geometrical Dominator' + } + } +} diff --git a/plugins/rejoin.js b/plugins/rejoin.js new file mode 100755 index 0000000..08d0459 --- /dev/null +++ b/plugins/rejoin.js @@ -0,0 +1,17 @@ +const index = require('../index.js') +module.exports = { + load: () => { + }, + loadBot: (b) => { + b._client.on('end', () => { + b.info('bot ' + b.id + ' disconnected') + for (const i in b.interval) { + clearInterval(b.interval[i]) + } + setTimeout(() => { + b.info('Re-connecting bot ' + b.id) + index.createBot(b.host, b.id) + }, 5000) + }) + } +} diff --git a/plugins/sc.js b/plugins/sc.js new file mode 100755 index 0000000..a6f47f0 --- /dev/null +++ b/plugins/sc.js @@ -0,0 +1,34 @@ +class SCTask { + constructor (failTask, chatCommand, startFailed = false) { + /* + * failed: Whether to run this task + * failTask: Command to run when failed is true + * chatCommand: Whether to run failTask in chat rather than in command block + */ + this.failed = startFailed + this.failTask = failTask + this.chatCommand = chatCommand + } +} +module.exports = { + load: () => { + + }, + loadBot: (b) => { + b.sc_tasks = {} + b.interval.sc = setInterval(() => { + for (const i in b.sc_tasks) { + if (b.sc_tasks[i].failed) { + if (b.sc_tasks[i].chatCommand) { + b.chat(b.sc_tasks[i].failTask) + } else { + b.ccq.push(b.sc_tasks[i].failTask) // Does not automatically reset + } + } + } + }, 1000) + b.add_sc_task = (name, failTask, chatCommand, startFailed) => { + b.sc_tasks[name] = new SCTask(failTask, chatCommand, startFailed) + } + } +} diff --git a/plugins/sc_cspy.js b/plugins/sc_cspy.js new file mode 100755 index 0000000..af1f629 --- /dev/null +++ b/plugins/sc_cspy.js @@ -0,0 +1,15 @@ +module.exports = { + load: () => { + + }, + loadBot: (b) => { + b.add_sc_task('cspy', '/cspy on', true, true) + b.on('plainchat', (msg) => { + if (msg === 'Successfully disabled CommandSpy') { + b.sc_tasks.cspy.failed = 1 + } else if (msg === 'Successfully enabled CommandSpy') { + b.sc_tasks.cspy.failed = 0 + } + }) + } +} diff --git a/plugins/sc_gamemode.js b/plugins/sc_gamemode.js new file mode 100755 index 0000000..a3b43e2 --- /dev/null +++ b/plugins/sc_gamemode.js @@ -0,0 +1,15 @@ +module.exports = { + load: () => { + + }, + loadBot: (b) => { + b.add_sc_task('gamemode', '/minecraft:gamemode creative', true) + b._client.on('game_state_change', (p) => { + if (p.reason === 3 && p.gameMode !== 1) { + b.sc_tasks.gamemode.failed = 1 + } else if (p.reason === 3 && p.gameMode === 1) { + b.sc_tasks.gamemode.failed = 0 + } + }) + } +} diff --git a/plugins/sc_op.js b/plugins/sc_op.js new file mode 100755 index 0000000..c2d53b6 --- /dev/null +++ b/plugins/sc_op.js @@ -0,0 +1,18 @@ +module.exports = { + load: () => { + + }, + loadBot: (b) => { + b.add_sc_task('op', '/op @s[type=player]', true) + b._client.on('login', (p) => { + b.entityId = p.entityId + }) + b._client.on('entity_status', (p) => { + if (p.entityId === b.entityId && p.entityStatus === 24) { + b.sc_tasks.op.failed = 1 + } else if (p.entityId === b.entityId && p.entityStatus === 28) { + b.sc_tasks.op.failed = 0 + } + }) + } +} diff --git a/plugins/testing.js b/plugins/testing.js new file mode 100755 index 0000000..80e3cfe --- /dev/null +++ b/plugins/testing.js @@ -0,0 +1,8 @@ +module.exports = { + load: () => { + + }, + loadBot: (b) => { + + } +} diff --git a/settings2.json b/settings2.json new file mode 100755 index 0000000..dd953ef --- /dev/null +++ b/settings2.json @@ -0,0 +1,23 @@ +{ + "secret":"./settings_s.json", + "name": "Minecraft Bot", + "version_mc": "1.20.4", + "defaultLang": "en-US", + "colors": { + "primary": "#FFCCEE", + "secondary": "#FF99DD" + }, + "prefix":[ + "bot:", + "\"" + ], + "servers":[ + { + "host": "kaboom.pw", + "port": 25565, + "options":{ + "name": "kaboom" + } + } + ] +} diff --git a/util/Command.js b/util/Command.js new file mode 100644 index 0000000..fd8e2da --- /dev/null +++ b/util/Command.js @@ -0,0 +1,24 @@ +// HOW TO WRITE CLASS JS +const settings = require('../settings.json') +class Command { + constructor (uuid, user, nick, cmd, prefix, bot, verify, lang = settings.defaultLang) { + this.send = (text, uuid) => { bot.tellraw(uuid || '@a', text) } + this.reply = text => bot.tellraw(uuid, text) + this.uuid = uuid + this.username = user + this.nickname = nick + this.command = cmd + this.prefix = prefix + this.bot = bot + this.type = 'minecraft' + this.index = bot.id + this.args = cmd.split(' ').slice(1) + this.verify = verify + this.host = bot.host.host + this.port = bot.host.port + this.lang = lang + this.colors = settings.colors + } +} + +module.exports = Command diff --git a/util/ConsoleCommand.js b/util/ConsoleCommand.js new file mode 100644 index 0000000..ff1af90 --- /dev/null +++ b/util/ConsoleCommand.js @@ -0,0 +1,60 @@ +// HOW TO WRITE CLASS JS +const index = require('../index.js') +const { cmds } = require('../plugins/command.js') +const parse = require('../util/chatparse.js') +const settings = require('../settings.json') +const getMessage = require('../util/lang.js') +const lang = settings.defaultLang +class ConsoleCommand { + constructor (cmd, index2) { + this.send = () => {} // not needed for console + this.reply = text => process.stdout.write(parse(text)[0] + '\n') + this.uuid = 'dde5a2a6-ebdd-4bbb-8eac-f75b10c10446_console' // hard-coded because uuid does not exist at console + this.username = 'Owner' + this.nickname = 'Console' + this.command = cmd + this.prefix = '' // prefix does not exist at console + this.bot = index2 >= 0 + ? index.bot[index2] + : { + printHelp: () => { + const helpCmds = [] + for (const i in cmds) { + // if(cmds[i].hidden) continue; + helpCmds.push(i) + } + console.log(getMessage(lang, 'command.help.cmdList', [helpCmds.join(' ')])) + }, + printCmdHelp: (uuid, cmd) => { + let usage = getMessage(lang, `command.${cmd}.usage`).split('||') + let desc = getMessage(lang, `command.${cmd}.desc`) + if (cmds[cmd].usage) { + usage = cmds[cmd].usage.split('||') + } + if (cmds[cmd].desc) { + desc = cmds[cmd].desc + } + for (const i in usage) { + console.log(getMessage(lang, 'command.help.commandUsage', [cmd, usage[i]])) + } + console.log(getMessage(lang, 'command.help.commandDesc', [desc])) + const permsN = getMessage(lang, 'command.help.permsNormal') + const permsT = getMessage(lang, 'command.help.permsTrusted') + const permsO = getMessage(lang, 'command.help.permsOwner') + const permsC = getMessage(lang, 'command.help.permsConsole') + const rPerms = cmds[cmd].level ? cmds[cmd].level : 0 + console.log(getMessage(lang, 'command.help.commandPerms', [[permsN, permsT, permsO, permsC][rPerms]])) + } + } // bot does not exist at console + this.type = 'console' + this.index = index2 + this.args = cmd.split(' ').slice(1) + this.verify = 3 + this.host = '' + this.port = '3' // :3 + this.lang = settings.defaultLang + this.colors = settings.colors + } +} + +module.exports = ConsoleCommand diff --git a/util/chatparse.js b/util/chatparse.js new file mode 100644 index 0000000..5eaa082 --- /dev/null +++ b/util/chatparse.js @@ -0,0 +1,133 @@ +const _lang = require('minecraft-data')('1.20.2').language +const lang = Object.create(null) // Without constructor function +for (const i in _lang) { + lang[i] = _lang[i] +} +const consoleColors = { + dark_red: '\x1B[0m\x1B[38;2;170;0;0m', + red: '\x1B[0m\x1B[38;2;255;85;85m', + dark_green: '\x1B[0m\x1B[38;2;0;170;0m', + green: '\x1B[0m\x1B[38;2;85;255;85m', + gold: '\x1B[0m\x1B[38;2;255;170;0m', + yellow: '\x1B[0m\x1B[38;2;255;255;85m', + dark_blue: '\x1B[0m\x1B[38;2;0;0;170m', + blue: '\x1B[0m\x1B[38;2;85;85;255m', + dark_purple: '\x1B[0m\x1B[38;2;170;0;170m', + light_purple: '\x1B[0m\x1B[38;2;255;85;255m', + dark_aqua: '\x1B[0m\x1B[38;2;0;170;170m', + aqua: '\x1B[0m\x1B[38;2;85;255;255m', + black: '\x1B[0m\x1B[48;2;220;220;220m\x1B[38;2;0;0;0m', + gray: '\x1B[0m\x1B[38;2;170;170;170m', + dark_gray: '\x1B[0m\x1B[38;2;85;85;85m', + white: '\x1B[0m\x1B[38;2;255;255;255m', + reset: '\x1B[0m\x1B[38;2;255;255;255m' +} +const hexColorParser = (color) => { + let out = '\x1B[0m' + const redChannel = Number('0x' + color.slice(1, 3)) + const greenChannel = Number('0x' + color.slice(3, 5)) + const blueChannel = Number('0x' + color.slice(5, 7)) + if (redChannel < 96 && greenChannel < 96 && blueChannel < 96) { + out += '\x1B[48;2;220;220;220m' + } + return out + `\x1B[38;2;${redChannel};${greenChannel};${blueChannel}m` +} +const processColor = (col, rcol) => { + const out = ['', ''] + if (col === 'reset') { + out[0] = rcol[0] + } else if (col.startsWith('#')) { + out[0] = hexColorParser(col) + } else { + out[0] = consoleColors[col] + } + return out +} +const parse = function (_data, l = 0, resetColor = [consoleColors.reset]) { + if (l >= 12) { + return ['', '', ''] + } + let data + if (typeof _data === 'string') { + data = { text: _data, color: 'reset' } + } else if (typeof _data === 'number') { + data = { text: _data + '', color: 'reset' } + } else { + data = _data + } + let nkt = false + const out = ['', '', ''] // console plain minecraft + if (data['']) { + data.text = data[''] + nkt = true + } + if (data.color) { + if (data.color === 'reset') { + out[0] += resetColor[0] + } else if (data.color.startsWith('#')) { + out[0] += hexColorParser(data.color) + } else { + out[0] += consoleColors[data.color] + } + } else { + out[0] += resetColor[0] + } + if (data.text) { + let _text = data.text + if (typeof _text === 'number') { + _text = _text.toString() + } + if (nkt) { + out[0] += resetColor[0] + out[2] += resetColor[1] + } + out[0] += _text.replaceAll('\x1b', '').replaceAll('\x0e', '') // Remove escape codes and [SO] from console format + out[1] += _text + out[2] += _text + } + if (data.translate) { + let trans = data.translate.replace(/%%/g, '\ue123').replaceAll('\x1b', '').replaceAll('\x0e', '') // Remove escape codes from console format + let trans2 = data.translate.replace(/%%/g, '\ue123') + let trans3 = data.translate.replace(/%%/g, '\ue123') + if (lang[trans] !== undefined) { + trans = lang[trans].replace(/%%/g, '\ue123') + trans2 = lang[trans2].replace(/%%/g, '\ue123') + trans3 = lang[trans3].replace(/%%/g, '\ue123') + } + for (const i in data.with) { + const j2 = parse(data.with[i], l + 1, data.color ? processColor(data.color, resetColor) : resetColor) + trans = trans.replace(/%s/, j2[0].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + trans2 = trans2.replace(/%s/, j2[1].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + trans3 = trans3.replace(/%s/, j2[2].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + trans = trans.replaceAll(`%${+i + 1}$s`, j2[0].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + trans2 = trans2.replaceAll(`%${+i + 1}$s`, j2[1].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + trans3 = trans3.replaceAll(`%${+i + 1}$s`, j2[2].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + } + out[0] += trans.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s') + out[1] += trans2.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s') + out[2] += trans3.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s') + } + if (data.extra) { + for (const i in data.extra) { + const parsed = parse(data.extra[i], l, data.color ? processColor(data.color, resetColor) : resetColor) + out[0] += parsed[0] + out[1] += parsed[1] + out[2] += parsed[2] + } + } + out[0] += resetColor[0] + return out +} +const parse2 = function (_data, l, resetColor) { + try { + return parse(_data) + } catch (e) { + console.error(e) + return [ + '\x1B[0m\x1B[38;2;255;85;85mAn error occured while parsing a message. See console for more information.\nJSON that caused the error: ' + JSON.stringify(_data), + 'An error occured while parsing a message. See console for more information. JSON that caused the error: ' + JSON.stringify(_data), + '§cAn error occured while parsing a message. See console for more information. JSON that caused the error: ' + JSON.stringify(_data) + ] + } +} +module.exports = parse2 diff --git a/util/chatparse_1204.js b/util/chatparse_1204.js new file mode 100644 index 0000000..3add56e --- /dev/null +++ b/util/chatparse_1204.js @@ -0,0 +1,11 @@ +const { processNbtMessage } = require('prismarine-chat') +const parse = function (data) { + if (typeof data.type === 'string') { + return JSON.parse(processNbtMessage(data)) + } else if (typeof data === 'string') { + return JSON.parse(data) + } else { + return data + } +} +module.exports = parse diff --git a/util/hashcheck.js b/util/hashcheck.js new file mode 100644 index 0000000..0414d2a --- /dev/null +++ b/util/hashcheck.js @@ -0,0 +1,19 @@ +const crypto = require('crypto') +const settings = require('../settings.json') +const secret = require(settings.secret) +module.exports = function (cmd) { + const cmdWithoutHash = cmd.slice(0, cmd.length - 1).join(' ') + const _dateString = Date.now().toString() + const dateString = _dateString.slice(0, _dateString.length - 4) + const hashTrusted = 'babyboom:' + secret.keyTrusted + ':' + cmdWithoutHash + ':' + dateString + const hashOwner = 'babyboom:' + secret.keyOwner + ':' + cmdWithoutHash + ':' + dateString + const validhashT = crypto.createHash('sha256').update(hashTrusted).digest('hex') + const validhashO = crypto.createHash('sha256').update(hashOwner).digest('hex') + if (cmd[cmd.length - 1] === validhashT) { + return 1 + } + if (cmd[cmd.length - 1] === validhashO) { + return 2 + } + return 0 +} diff --git a/util/lang.js b/util/lang.js new file mode 100644 index 0000000..b9885ab --- /dev/null +++ b/util/lang.js @@ -0,0 +1,27 @@ +const fs = require('fs') +const languages = {} +const loadplug = (botno) => { + const bpl = fs.readdirSync('util/lang') + for (const i in bpl) { + if (!bpl[i].endsWith('.json')) { + continue + } + try { + languages[bpl[i].split('.')[0]] = require(`./lang/${bpl[i]}`) + } catch (e) { console.log(e) } + } +} +loadplug() +module.exports = function (l, msg, with2) { + let message = msg.replace(/%%/g, '\ue123') + if (languages[l][message] !== undefined) { + message = languages[l][message].replace(/%%/g, '\ue123') + } else if (languages['en-US'][message] !== undefined) { + message = languages['en-US'][message].replace(/%%/g, '\ue123') + } + for (const i in with2) { + message = message.replace(/%s/, with2[i].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + message = message.replaceAll(`%${+i + 1}$s`, with2[i].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + } + return message.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s') +} diff --git a/util/lang/en-US.json b/util/lang/en-US.json new file mode 100644 index 0000000..8f99049 --- /dev/null +++ b/util/lang/en-US.json @@ -0,0 +1,72 @@ +{ + "command.about.usage": "", + "command.about.desc": "About the bot", + "command.cb.usage": " ", + "command.cb.desc": "Run a command in a command block", + "command.cloop.usage": " add || remove || list|| clear", + "command.cloop.desc": "Manage command loops", + "command.eval.usage": " ", + "command.eval.desc": "Run JavaScript code", + "command.help.usage": " [cmd]", + "command.help.desc": "Shows command help", + "command.logoff.usage": "", + "command.logoff.desc": "Disconnect and reconnect the bot from a server", + "command.netmsg.usage": " ", + "command.netmsg.desc": "Send a message to all servers the bot is connected to", + "command.refill.usage": "", + "command.refill.desc": "Refill core", + "command.say.usage": " ", + "command.say.desc": "Sends a message to chat", + "command.serverinfo.usage": "", + "command.serverinfo.desc": "Get system/bot info", + "command.stop.usage": "", + "command.stop.desc": "Restart bot", + "command.template.usage": " [optional]", + "command.template.desc": "Does nothing", + "command.verify.usage": " [args...]", + "command.verify.desc": "Check the hashing system", + "command.about.author": "%s - a Minecraft bot made by 77c8f4699b732c11 / a5a06d596f15c7db", + "command.about.version": "Version %s", + "command.about.serverinfo": "To view system information, run the command %s.", + "command.cloop.error.tooShort": "Command loops must have a rate above 20ms.", + "command.cloop.error.subcommand": "Unknown subcommand, please do %s", + "command.cloop.success.add": "Added command loop with command %s and rate %s", + "command.cloop.success.remove": "Removed command loop %s", + "command.cloop.success.clear": "Cleared all command loops", + "command.cloop.list": "%s: Command: %s Rate: %s", + "command.help.cmdList": "Commands", + "command.help.commandInfo": "%s%s - %s", + "command.help.commandUsage": "Usage - %s%s", + "command.help.commandDesc": "Description - %s", + "command.help.commandPerms": "Required permissions - %s", + "command.help.permsNormal": "Normal", + "command.help.permsTrusted": "Trusted", + "command.help.permsOwner": "Owner", + "command.help.permsConsole": "Console", + "command.help.noCommand": "Command does not exist", + "command.serverinfo.os.android": "Android", + "command.serverinfo.os.freebsd": "FreeBSD", + "command.serverinfo.os.linux": "Linux", + "command.serverinfo.os.macos": "macOS", + "command.serverinfo.os.macos_old": "OS X", + "command.serverinfo.os": "Operating system", + "command.serverinfo.processor": "CPU", + "command.serverinfo.arch": "Architecture", + "command.serverinfo.osUsername": "Username", + "command.serverinfo.hostName": "Hostname", + "command.serverinfo.workingDir": "Working directory", + "command.serverinfo.runTime": "Bot uptime", + "command.serverinfo.upTime": "System uptime", + "command.serverinfo.nodeVersion": "Node.js version", + "command.serverinfo.osRelease": "Linux release", + "command.serverinfo.osRelease.missing": "/etc/os-release does not exist. Information may be limited.", + "command.serverinfo.os.android.version": "Android version", + "command.serverinfo.os.android.model": "Device model", + "command.serverinfo.botName": "Bot name", + "command.serverinfo.botVer": "Bot version", + "command.error": "An error occured (check console for more info)", + "command.disallowed.perms": "You do not have permission to run this command. If you do have permission, please make sure you put the command hash at the end, or ran the command through your client's hashing system.", + "command.disallowed.perms.yourLevel": "Your permission level: %s", + "command.disallowed.perms.cmdLevel": "Command requires: %s", + "copyText": "Click to copy!" +} \ No newline at end of file diff --git a/util/lang/he-IL.json b/util/lang/he-IL.json new file mode 100644 index 0000000..352736a --- /dev/null +++ b/util/lang/he-IL.json @@ -0,0 +1,72 @@ +{ + "command.about.usage": "", + "command.about.desc": "About the bot", + "command.cb.usage": " ", + "command.cb.desc": "Wun a command in a command bwock", + "command.cloop.usage": " add || remove || list|| clear", + "command.cloop.desc": "Manage command woops", + "command.eval.usage": " ", + "command.eval.desc": "Wun JavaScwipt code", + "command.help.usage": " [cmd]", + "command.help.desc": "Shows command hewp", + "command.logoff.usage": "", + "command.logoff.desc": "Disconnyect and weconnyect the bot fwom a sewvew", + "command.netmsg.usage": " ", + "command.netmsg.desc": "Send a message to aww sewvews the bot is connyected to", + "command.refill.usage": "", + "command.refill.desc": "Wefiww cowe", + "command.say.usage": " ", + "command.say.desc": "Sends a message to chat", + "command.serverinfo.usage": "", + "command.serverinfo.desc": "Get system/bot info", + "command.stop.usage": "", + "command.stop.desc": "Westawt bot", + "command.template.usage": " [optionyaw]", + "command.template.desc": "Does nyothing", + "command.verify.usage": " [awgs...]", + "command.verify.desc": "Check the hashing system", + "command.about.author": "%s - a Minyecwaft bot made by 77c8f4699b732c11 / a5a06d596f15c7db", + "command.about.version": "Vewsion %s", + "command.about.serverinfo": "To view system infowmation, wun the command %s.", + "command.cloop.error.tooShort": "Command woops must have a wate above 20ms.", + "command.cloop.error.subcommand": "Unknyown subcommand, pwease do %s", + "command.cloop.success.add": "Added command woop with command %s and wate %s", + "command.cloop.success.remove": "Wemoved command woop %s", + "command.cloop.success.clear": "Cweawed aww command woops", + "command.cloop.list": "%s: Command: %s Rate: %s", + "command.help.cmdList": "Commands", + "command.help.commandInfo": "%s%s - %s", + "command.help.commandUsage": "Usage - %s%s", + "command.help.commandDesc": "Descwiption - %s", + "command.help.commandPerms": "Wequiwed pewmissions - %s", + "command.help.permsNormal": "Nyowmaw", + "command.help.permsTrusted": "Twusted", + "command.help.permsOwner": "Ownyew", + "command.help.permsConsole": "Consowe", + "command.help.noCommand": "Command does nyot exist", + "command.serverinfo.os.android": "Andwoid", + "command.serverinfo.os.freebsd": "FweeBSD", + "command.serverinfo.os.linux": "Winyux", + "command.serverinfo.os.macos": "macOS", + "command.serverinfo.os.macos_old": "OS X", + "command.serverinfo.os": "Opewating system", + "command.serverinfo.processor": "CPU", + "command.serverinfo.arch": "Awchitectuwe", + "command.serverinfo.osUsername": "Usewnyame", + "command.serverinfo.hostName": "Hostnyame", + "command.serverinfo.workingDir": "Wowking diwectowy", + "command.serverinfo.runTime": "Bot uptime", + "command.serverinfo.upTime": "System uptime", + "command.serverinfo.nodeVersion": "Nyode.js vewsion", + "command.serverinfo.osRelease": "Winyux wewease", + "command.serverinfo.osRelease.missing": "/etc/os-release does nyot exist. Infowmation may be wimited.", + "command.serverinfo.os.android.version": "Andwoid vewsion", + "command.serverinfo.os.android.model": "Device modew", + "command.serverinfo.botName": "Bot nyame", + "command.serverinfo.botVer": "Bot vewsion", + "command.error": "An ewwow occuwed (check consowe fow mowe info)", + "command.disallowed.perms": "You do nyot have pewmission to wun this command. If you do have pewmission, pwease make suwe you put the command hash at the end, ow wan the command thwough youw cwient's hashing system.", + "command.disallowed.perms.yourLevel": "Youw pewmission wevew: %s", + "command.disallowed.perms.cmdLevel": "Command wequiwes: %s", + "copyText": "Cwick to copy!" +} \ No newline at end of file diff --git a/util/textformat.js b/util/textformat.js new file mode 100644 index 0000000..89bb3a7 --- /dev/null +++ b/util/textformat.js @@ -0,0 +1,17 @@ +const settings = require('../settings.json') +module.exports = function (text) { + return JSON.stringify({ + translate: '[%s] %s', + color: '#FFAAFF', + with: [ + { + text: settings.name, + color: 'light_purple' + }, + { + text, + color: 'white' + } + ] + }) +} diff --git a/util/timeformat.js b/util/timeformat.js new file mode 100755 index 0000000..8a683ea --- /dev/null +++ b/util/timeformat.js @@ -0,0 +1,24 @@ +module.exports = function (time) { + let finalString = '' + const seconds = Math.floor(time / 1000) % 60 + const minutes = Math.floor(time / 60000) % 60 + const hours = Math.floor(time / 3600000) % 24 + const days = Math.floor(time / 86400000) % 7 + const weeks = Math.floor(time / 604800000) + if (weeks !== 0) { + finalString += `${weeks} week${weeks === 1 ? '' : 's'} ` + } + if (days !== 0) { + finalString += `${days} day${days === 1 ? '' : 's'} ` + } + if (hours !== 0) { + finalString += `${hours} hour${hours === 1 ? '' : 's'} ` + } + if (minutes !== 0) { + finalString += `${minutes} minute${minutes === 1 ? '' : 's'} ` + } + if (seconds !== 0) { + finalString += `${seconds} second${seconds === 1 ? '' : 's'} ` + } + return finalString +} diff --git a/util/usergen.js b/util/usergen.js new file mode 100644 index 0000000..af25934 --- /dev/null +++ b/util/usergen.js @@ -0,0 +1,22 @@ +const rsg = function (count) { + let output = '' + for (let i = 0; i < count; i++) { + let rng = Math.floor(Math.random() * 16) + 1 + if (rng === 7) rng = 17 // No bells + if (rng === 10) rng = 18 // No line feeds + if (rng === 11) rng = 19 // No vertical tabulations + if (rng === 12) rng = 20 // No form feed + if (rng === 13) rng = 21 // No carriage returns + if (rng === 14) rng = 22 // No shift out + if (rng === 15) rng = 23 // No shift in + output += String.fromCharCode(rng) + } + return output +} +module.exports = function (legal) { + if (legal) { + return Math.floor(Math.random() * 1000000).toString() + } else { + return ' \xa7' + rsg(6) + ' ' + rsg(4) + } +} diff --git a/util/uuidtoint.js b/util/uuidtoint.js new file mode 100644 index 0000000..4807ce8 --- /dev/null +++ b/util/uuidtoint.js @@ -0,0 +1,5 @@ +module.exports = function (uuid) { + const splitUUID = uuid.replace(/[^0-9a-f]/g, '').replace(/.{1,8}/g, a => { return '0x' + a }).match(/.{1,10}/g) + const numUUID = [+splitUUID[0] << 0, +splitUUID[1] << 0, +splitUUID[2] << 0, +splitUUID[3] << 0] + return numUUID +} diff --git a/version.json b/version.json new file mode 100644 index 0000000..68cdaa4 --- /dev/null +++ b/version.json @@ -0,0 +1,3 @@ +{ + "bot": "10.0.0-beta.1" +} \ No newline at end of file From 5d7e90db0ff106132fdd4b36a13aeff7413e2252 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sun, 28 Jul 2024 16:36:17 -0400 Subject: [PATCH 170/362] Make example settings use an absolute Windows path, most likely what someone viewing this will run --- settings2.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings2.json b/settings2.json index dd953ef..1eff62c 100755 --- a/settings2.json +++ b/settings2.json @@ -1,5 +1,5 @@ { - "secret":"./settings_s.json", + "secret":"C:\\Users\\Username\\Documents\\botvX\\settings_s.json", "name": "Minecraft Bot", "version_mc": "1.20.4", "defaultLang": "en-US", From a1dc2f48cd7d122756d86e72939c7e4ecd9ca82a Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 <7cc5c4f330d47060@noreply.localhost> Date: Sun, 28 Jul 2024 16:37:33 -0400 Subject: [PATCH 171/362] Translate Russian README line --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 61e1c0d..cedb4a6 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # botvX -## Что это такое? +## What is it? botvX or UBot is a Minecraft bot for [Kaboom](https://kaboom.pw/) and its clones. It has many of the features that you would expect in a modern Kaboom bot: From d236840b4774569c1c7d621cc0fb64cdb9df7aaa Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 <7cc5c4f330d47060@noreply.localhost> Date: Sun, 28 Jul 2024 16:39:49 -0400 Subject: [PATCH 172/362] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cedb4a6..cc6a648 100644 --- a/README.md +++ b/README.md @@ -18,9 +18,9 @@ botvX or UBot is a Minecraft bot for [Kaboom](https://kaboom.pw/) and its clones ## How to install? -1. Download the latest release, or alternatively, download the latest development version using git clone https://10.0.0.151:3000/7cc5c4f330d47060/botvX/. +1. Download the latest release, or alternatively, download the latest development version using git clone https://code.chipmunk.land/7cc5c4f330d47060/botvX/. 2. Extract the files if necessary. -3. Copy settings2.json to settings.json , and adjust the settings to fit your needs. Do not forget to also create a secrets file. +3. Copy settings2.json to settings.json, and adjust the settings to fit your needs. Do not forget to also create a secrets file. 4. Run ./launch.sh to start a bot launcher, which will reload the bot when the process closes. ## Command list From dad7faaf245119959eafe4a74279b2649f9f77a4 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sun, 28 Jul 2024 16:44:27 -0400 Subject: [PATCH 173/362] Update settings documentation --- README.md | 4 ++-- secret_example.json | 4 ++++ settings2.json => settings_example.json | 0 3 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 secret_example.json rename settings2.json => settings_example.json (100%) diff --git a/README.md b/README.md index 61e1c0d..09d72d3 100644 --- a/README.md +++ b/README.md @@ -20,8 +20,8 @@ botvX or UBot is a Minecraft bot for [Kaboom](https://kaboom.pw/) and its clones 1. Download the latest release, or alternatively, download the latest development version using git clone https://10.0.0.151:3000/7cc5c4f330d47060/botvX/. 2. Extract the files if necessary. -3. Copy settings2.json to settings.json , and adjust the settings to fit your needs. Do not forget to also create a secrets file. -4. Run ./launch.sh to start a bot launcher, which will reload the bot when the process closes. +3. Copy settings_example.json to settings.json , and adjust the settings to fit your needs. Do not forget to also create a secrets file. An example secrets file is provided as secret_example.json. Do not forget, if you use the secrets template, to change the keys (the ones in there are public after all!). +4. Run ./launch.sh (macOS, Linux, FreeBSD) or ./launch.cmd (Windows, coming soon) to start a bot launcher, which will reload the bot when the process closes. ## Command list diff --git a/secret_example.json b/secret_example.json new file mode 100644 index 0000000..61a3ce8 --- /dev/null +++ b/secret_example.json @@ -0,0 +1,4 @@ +{ + "keyTrusted": "Insert trusted level key here...", + "keyOwner": "Insert owner level key here..." +} diff --git a/settings2.json b/settings_example.json similarity index 100% rename from settings2.json rename to settings_example.json From f79ccb2275b28c47811093b5128bcd7eed5e47c5 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sun, 28 Jul 2024 16:48:46 -0400 Subject: [PATCH 174/362] Move bot name to version file --- plugins/commands/about.js | 4 ++-- plugins/commands/serverinfo.js | 4 ++-- version.json | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/plugins/commands/about.js b/plugins/commands/about.js index 40df25c..185cf3e 100644 --- a/plugins/commands/about.js +++ b/plugins/commands/about.js @@ -9,13 +9,13 @@ module.exports = { color: c.colors.secondary, with: [ { - text: settings.name, + text: version.botName, color: c.colors.primary } ] }) c.reply({ text: '' }) - const botVersion = version.bot + const botVersion = version.botVersion let gitCommit try { gitCommit = cp.execSync('git rev-parse --short HEAD').toString('UTF-8').split('\n')[0] diff --git a/plugins/commands/serverinfo.js b/plugins/commands/serverinfo.js index fa50f6e..4c946ef 100755 --- a/plugins/commands/serverinfo.js +++ b/plugins/commands/serverinfo.js @@ -80,8 +80,8 @@ module.exports = { const dBrand = cp.execSync('getprop ro.product.brand').toString('UTF-8').split('\n')[0] c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.os.android.model'), dBrand + ' ' + dModel, c.colors)) } - c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.botName'), settings.name, c.colors)) - let botVersion = version.bot + c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.botName'), version.botName, c.colors)) + let botVersion = version.botVersion let gitCommit try { gitCommit = cp.execSync('git rev-parse --short HEAD').toString('UTF-8').split('\n')[0] diff --git a/version.json b/version.json index 68cdaa4..c4af15e 100644 --- a/version.json +++ b/version.json @@ -1,3 +1,4 @@ { - "bot": "10.0.0-beta.1" + "botName": "UBot Dev", + "botVersion": "10.0.0-beta.1" } \ No newline at end of file From 9d277a2dfd96da45de0819828a1c37c83876fddc Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 <7cc5c4f330d47060@noreply.localhost> Date: Sun, 28 Jul 2024 17:13:22 -0400 Subject: [PATCH 175/362] Add hashing system to readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index fd684c5..f14a47a 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ botvX or UBot is a Minecraft bot for [Kaboom](https://kaboom.pw/) and its clones - commands (obviously) - a self care system - a command core, to run commands quickly +- a hashing system, to enable trusted users to securely run certain commands in chat ## What does "botvX" mean? From 344215c3ff3b318bded438abb3d2fd0a4c2bd10f Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sun, 28 Jul 2024 17:28:31 -0400 Subject: [PATCH 176/362] Update readmi --- README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index f14a47a..15a7c5b 100644 --- a/README.md +++ b/README.md @@ -19,10 +19,11 @@ botvX or UBot is a Minecraft bot for [Kaboom](https://kaboom.pw/) and its clones ## How to install? -1. Download the latest release, or alternatively, download the latest development version using git clone https://code.chipmunk.land/7cc5c4f330d47060/botvX/. -2. Extract the files if necessary. -3. Copy settings_example.json to settings.json , and adjust the settings to fit your needs. Do not forget to also create a secrets file. An example secrets file is provided as secret_example.json. Do not forget, if you use the secrets template, to change the keys (the ones in there are public after all!). -4. Run ./launch.sh (macOS, Linux, FreeBSD) or ./launch.cmd (Windows, coming soon) to start a bot launcher, which will reload the bot when the process closes. +1. Install [Node.js](https://nodejs.org/) for your operating system. +2. Download the latest release, or alternatively, download the latest development version using git clone https://code.chipmunk.land/7cc5c4f330d47060/botvX/. +3. Extract the files if necessary. +4. Copy settings_example.json to settings.json , and adjust the settings to fit your needs. Do not forget to also create a secrets file. An example secrets file is provided as secret_example.json. Do not forget, if you use the secrets template, to change the keys (the ones in there are public after all!). +5. Run ./launch.sh (macOS, Linux, FreeBSD) or ./launch.cmd (Windows, coming soon) to start a bot launcher, which will reload the bot when the process closes. ## Command list @@ -40,4 +41,4 @@ botvX or UBot is a Minecraft bot for [Kaboom](https://kaboom.pw/) and its clones | serverinfo | | Get system/bot info, similar to Kaboom's serverinfo command | | stop | | Restart bot | | template | | Used in development, does nothing | -| verify | | Check the hashing system | \ No newline at end of file +| verify | | Check the hashing system | From 9d7effc649047ec0d7240106b5e7dff804569667 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sun, 28 Jul 2024 18:37:29 -0400 Subject: [PATCH 177/362] Fix about command --- util/chatparse.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/util/chatparse.js b/util/chatparse.js index 5eaa082..d9a5e60 100644 --- a/util/chatparse.js +++ b/util/chatparse.js @@ -52,6 +52,8 @@ const parse = function (_data, l = 0, resetColor = [consoleColors.reset]) { data = { text: _data, color: 'reset' } } else if (typeof _data === 'number') { data = { text: _data + '', color: 'reset' } + } else if (_data.constructor === Array) { + data = { extra: _data, color: 'reset' } } else { data = _data } From 8cdc79348d282b66cb3a25d4f77fe1b6462912c5 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sun, 28 Jul 2024 18:45:17 -0400 Subject: [PATCH 178/362] fix the hlrp [sic] command --- plugins/command.js | 2 +- util/ConsoleCommand.js | 2 +- util/lang/en-US.json | 4 ++-- util/lang/he-IL.json | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/command.js b/plugins/command.js index 8bd2e35..ffdf5bc 100755 --- a/plugins/command.js +++ b/plugins/command.js @@ -90,7 +90,7 @@ module.exports = { ) } b.tellraw(uuid, { - translate: '%s: %s', + translate: '%s %s', with: [ getMessage(lang, 'command.help.cmdList'), commandList.sort(sortHelp) diff --git a/util/ConsoleCommand.js b/util/ConsoleCommand.js index ff1af90..c41aaad 100644 --- a/util/ConsoleCommand.js +++ b/util/ConsoleCommand.js @@ -23,7 +23,7 @@ class ConsoleCommand { // if(cmds[i].hidden) continue; helpCmds.push(i) } - console.log(getMessage(lang, 'command.help.cmdList', [helpCmds.join(' ')])) + console.log(getMessage(lang, 'command.help.cmdList'), helpCmds.join(' ')) }, printCmdHelp: (uuid, cmd) => { let usage = getMessage(lang, `command.${cmd}.usage`).split('||') diff --git a/util/lang/en-US.json b/util/lang/en-US.json index 8f99049..3f19ef4 100644 --- a/util/lang/en-US.json +++ b/util/lang/en-US.json @@ -34,7 +34,7 @@ "command.cloop.success.remove": "Removed command loop %s", "command.cloop.success.clear": "Cleared all command loops", "command.cloop.list": "%s: Command: %s Rate: %s", - "command.help.cmdList": "Commands", + "command.help.cmdList": "Commands:", "command.help.commandInfo": "%s%s - %s", "command.help.commandUsage": "Usage - %s%s", "command.help.commandDesc": "Description - %s", @@ -69,4 +69,4 @@ "command.disallowed.perms.yourLevel": "Your permission level: %s", "command.disallowed.perms.cmdLevel": "Command requires: %s", "copyText": "Click to copy!" -} \ No newline at end of file +} diff --git a/util/lang/he-IL.json b/util/lang/he-IL.json index 352736a..eff47c8 100644 --- a/util/lang/he-IL.json +++ b/util/lang/he-IL.json @@ -34,7 +34,7 @@ "command.cloop.success.remove": "Wemoved command woop %s", "command.cloop.success.clear": "Cweawed aww command woops", "command.cloop.list": "%s: Command: %s Rate: %s", - "command.help.cmdList": "Commands", + "command.help.cmdList": "Commands:", "command.help.commandInfo": "%s%s - %s", "command.help.commandUsage": "Usage - %s%s", "command.help.commandDesc": "Descwiption - %s", @@ -69,4 +69,4 @@ "command.disallowed.perms.yourLevel": "Youw pewmission wevew: %s", "command.disallowed.perms.cmdLevel": "Command wequiwes: %s", "copyText": "Cwick to copy!" -} \ No newline at end of file +} From 9e0440079f28ec7795061e46e9caa046c209ce69 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 <7cc5c4f330d47060@noreply.localhost> Date: Sun, 28 Jul 2024 19:41:20 -0400 Subject: [PATCH 179/362] I can rename files from broken SM-G998U1? --- plugins/{sc.js => selfcare.js} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename plugins/{sc.js => selfcare.js} (98%) diff --git a/plugins/sc.js b/plugins/selfcare.js similarity index 98% rename from plugins/sc.js rename to plugins/selfcare.js index a6f47f0..5aac829 100755 --- a/plugins/sc.js +++ b/plugins/selfcare.js @@ -4,7 +4,7 @@ class SCTask { * failed: Whether to run this task * failTask: Command to run when failed is true * chatCommand: Whether to run failTask in chat rather than in command block - */ + */ this.failed = startFailed this.failTask = failTask this.chatCommand = chatCommand From b356f72053a780510273b8e9f5fdaed4019c3482 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sun, 28 Jul 2024 19:55:49 -0400 Subject: [PATCH 180/362] Move uwu language to en-UW --- util/lang/{he-IL.json => en-UW.json} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename util/lang/{he-IL.json => en-UW.json} (100%) diff --git a/util/lang/he-IL.json b/util/lang/en-UW.json similarity index 100% rename from util/lang/he-IL.json rename to util/lang/en-UW.json From 25f0ea0866ec9fcebca9693f917b2a95a39f6990 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 <7cc5c4f330d47060@noreply.localhost> Date: Mon, 29 Jul 2024 00:55:38 -0400 Subject: [PATCH 181/362] Add source code to about [1] --- plugins/commands/about.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/plugins/commands/about.js b/plugins/commands/about.js index 185cf3e..dde0bfe 100644 --- a/plugins/commands/about.js +++ b/plugins/commands/about.js @@ -58,6 +58,21 @@ module.exports = { }) } c.reply({ text: '' }) + c.reply({ + translate: getMessage(c.lang, 'command.about.sourceCode'), + color: c.colors.secondary, + with: [ + { + text: version.sourceURL, + color: c.colors.primary, + clickEvent: { + action: 'open_url', + value: version.sourceURL + } + } + ] + }) + c.reply({ text: '' }) c.reply({ translate: getMessage(c.lang, 'command.about.serverinfo'), color: c.colors.secondary, From c0301fb27476590e2e7d88abd5b171908d7465ad Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 <7cc5c4f330d47060@noreply.localhost> Date: Mon, 29 Jul 2024 01:01:24 -0400 Subject: [PATCH 182/362] Add source code to about [2] --- util/lang/en-US.json | 1 + 1 file changed, 1 insertion(+) diff --git a/util/lang/en-US.json b/util/lang/en-US.json index 3f19ef4..b3cacca 100644 --- a/util/lang/en-US.json +++ b/util/lang/en-US.json @@ -27,6 +27,7 @@ "command.verify.desc": "Check the hashing system", "command.about.author": "%s - a Minecraft bot made by 77c8f4699b732c11 / a5a06d596f15c7db", "command.about.version": "Version %s", + "command.about.sourceCode": "Source code: %s", "command.about.serverinfo": "To view system information, run the command %s.", "command.cloop.error.tooShort": "Command loops must have a rate above 20ms.", "command.cloop.error.subcommand": "Unknown subcommand, please do %s", From 7e6c1f4ef1b9e22b9137483ab63cc0be017b3faa Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 <7cc5c4f330d47060@noreply.localhost> Date: Mon, 29 Jul 2024 01:02:00 -0400 Subject: [PATCH 183/362] Add source code to about [3] --- util/lang/en-UW.json | 1 + 1 file changed, 1 insertion(+) diff --git a/util/lang/en-UW.json b/util/lang/en-UW.json index eff47c8..7c1b430 100644 --- a/util/lang/en-UW.json +++ b/util/lang/en-UW.json @@ -27,6 +27,7 @@ "command.verify.desc": "Check the hashing system", "command.about.author": "%s - a Minyecwaft bot made by 77c8f4699b732c11 / a5a06d596f15c7db", "command.about.version": "Vewsion %s", + "command.about.sourceCode": "Souwce code: %s", "command.about.serverinfo": "To view system infowmation, wun the command %s.", "command.cloop.error.tooShort": "Command woops must have a wate above 20ms.", "command.cloop.error.subcommand": "Unknyown subcommand, pwease do %s", From ba26817ef32194fea67dc50b405de61a45274bcc Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 <7cc5c4f330d47060@noreply.localhost> Date: Mon, 29 Jul 2024 01:03:04 -0400 Subject: [PATCH 184/362] Add source code to about [4] --- version.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/version.json b/version.json index c4af15e..8573008 100644 --- a/version.json +++ b/version.json @@ -1,4 +1,5 @@ { "botName": "UBot Dev", - "botVersion": "10.0.0-beta.1" + "botVersion": "10.0.0-beta.1", + "sourceURL": "https://code.chipmunk.land/7cc5c4f330d47060/botvX" } \ No newline at end of file From bf1356a778e984239d12d1819ecad4c486692823 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 29 Jul 2024 01:22:53 -0400 Subject: [PATCH 185/362] Move loadCMD right after the definition of cmds --- plugins/command.js | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/plugins/command.js b/plugins/command.js index ffdf5bc..faa8602 100755 --- a/plugins/command.js +++ b/plugins/command.js @@ -3,7 +3,34 @@ const Command = require('../util/Command.js') const hashcheck = require('../util/hashcheck.js') const settings = require('../settings.json') const getMessage = require('../util/lang.js') -const cmds = Object.create(null) +const cmds = Object.create(null); +const bpl = fs.readdirSync('./plugins/commands') +for (const i in bpl) { // Built-in loadCMD + if (!bpl[i].endsWith('.js')) { + continue + } + try { + const commandName = bpl[i].split('.js')[0] + cmds[commandName] = require(`./commands/${bpl[i]}`) + if (cmds[commandName].level === undefined) { + cmds[commandName].level = 0 + } + console.log('Loaded command ' + commandName) + if (cmds[commandName].aliases) { + for (const j in cmds[commandName].aliases) { + cmds[cmds[commandName].aliases[j]] = { + execute: cmds[commandName].execute, + desc: 'Alias to ' + commandName, + usage: cmds[commandName].usage, + level: cmds[commandName].level, + hidden: true, + consoleIndex: cmds[commandName].consoleIndex + } + } + } + } catch (e) { console.log(e) } +} + const sortHelp = function sortHelp (c1, c2) { const level1 = cmds[c1.with[1]].level ? cmds[c1.with[1]].level : 0 const level2 = cmds[c2.with[1]].level ? cmds[c2.with[1]].level : 0 @@ -11,7 +38,7 @@ const sortHelp = function sortHelp (c1, c2) { } module.exports = { load: () => { - module.exports.loadCMD() + }, loadBot: (b) => { b.prefix = settings.prefix From fb17ef82e3c290303df1b19f19df6a0b9ddea6f8 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 29 Jul 2024 01:23:59 -0400 Subject: [PATCH 186/362] Remove loadCMD --- plugins/command.js | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/plugins/command.js b/plugins/command.js index faa8602..9f38c51 100755 --- a/plugins/command.js +++ b/plugins/command.js @@ -181,33 +181,5 @@ module.exports = { }) } }, - loadCMD: () => { - const bpl = fs.readdirSync('./plugins/commands') - for (const i in bpl) { - if (!bpl[i].endsWith('.js')) { - continue - } - try { - const commandName = bpl[i].split('.js')[0] - cmds[commandName] = require(`./commands/${bpl[i]}`) - if (cmds[commandName].level === undefined) { - cmds[commandName].level = 0 - } - console.log('Loaded command ' + commandName) - if (cmds[commandName].aliases) { - for (const j in cmds[commandName].aliases) { - cmds[cmds[commandName].aliases[j]] = { - execute: cmds[commandName].execute, - desc: 'Alias to ' + commandName, - usage: cmds[commandName].usage, - level: cmds[commandName].level, - hidden: true, - consoleIndex: cmds[commandName].consoleIndex - } - } - } - } catch (e) { console.log(e) } - } - }, cmds } From 4d088fed0803ab882205592934047144593c032e Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 29 Jul 2024 01:26:24 -0400 Subject: [PATCH 187/362] Create console out of load function Load Global is now unused. --- plugins/console.js | 64 +++++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/plugins/console.js b/plugins/console.js index efc8416..670d660 100644 --- a/plugins/console.js +++ b/plugins/console.js @@ -2,7 +2,37 @@ const readln = require('readline') const index = require('../index.js') const ConsoleCommand = require('../util/ConsoleCommand.js') const newercommands = require('./command.js').cmds -let rl +let rl = readln.createInterface({ + input: process.stdin, + output: process.stdout, + prompt: '\x1b[0m\x1b[38;5;15m> ' +}) +rl.on('line', (l) => { + try { + if (newercommands[l.split(' ')[0].toLowerCase()]) { + if (newercommands[l.split(' ')[0].toLowerCase()].consoleIndex) { + const tmpcmd = l.split(' ') + const index2 = tmpcmd.splice(1, 1)[0] + if (index2 === '*') { + for (let i = 0; i < index.bot.length; i++) { + const cmd = new ConsoleCommand(tmpcmd.join(' '), i) + newercommands[l.split(' ')[0].toLowerCase()].execute(cmd) + } + } else { + const cmd = new ConsoleCommand(tmpcmd.join(' '), +index2) + newercommands[l.split(' ')[0].toLowerCase()].execute(cmd) + } + } else { + const cmd = new ConsoleCommand(l, -2) + newercommands[l.split(' ')[0].toLowerCase()].execute(cmd) + } + } + } catch (e) { + console.log(e) + } + rl.prompt(false) +}) +rl.prompt(); function consoleWrite (text) { readln.cursorTo(process.stdout, 0) readln.clearLine(process.stdout, 0) @@ -11,37 +41,7 @@ function consoleWrite (text) { } module.exports = { load: () => { - rl = readln.createInterface({ - input: process.stdin, - output: process.stdout, - prompt: '\x1b[0m\x1b[38;5;15m> ' - }) - rl.on('line', (l) => { - try { - if (newercommands[l.split(' ')[0].toLowerCase()]) { - if (newercommands[l.split(' ')[0].toLowerCase()].consoleIndex) { - const tmpcmd = l.split(' ') - const index2 = tmpcmd.splice(1, 1)[0] - if (index2 === '*') { - for (let i = 0; i < index.bot.length; i++) { - const cmd = new ConsoleCommand(tmpcmd.join(' '), i) - newercommands[l.split(' ')[0].toLowerCase()].execute(cmd) - } - } else { - const cmd = new ConsoleCommand(tmpcmd.join(' '), +index2) - newercommands[l.split(' ')[0].toLowerCase()].execute(cmd) - } - } else { - const cmd = new ConsoleCommand(l, -2) - newercommands[l.split(' ')[0].toLowerCase()].execute(cmd) - } - } - } catch (e) { - console.log(e) - } - rl.prompt(false) - }) - rl.prompt() + }, loadBot: (b) => { b.info = (msg) => { From 5f53a131766eab13e35d102c07cd9ad466472cb0 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 29 Jul 2024 01:29:34 -0400 Subject: [PATCH 188/362] Merge self care tasks to selfcare plugin --- plugins/sc_cspy.js | 15 --------------- plugins/sc_gamemode.js | 15 --------------- plugins/sc_op.js | 18 ------------------ plugins/selfcare.js | 35 +++++++++++++++++++++++++++++++++++ 4 files changed, 35 insertions(+), 48 deletions(-) delete mode 100755 plugins/sc_cspy.js delete mode 100755 plugins/sc_gamemode.js delete mode 100755 plugins/sc_op.js diff --git a/plugins/sc_cspy.js b/plugins/sc_cspy.js deleted file mode 100755 index af1f629..0000000 --- a/plugins/sc_cspy.js +++ /dev/null @@ -1,15 +0,0 @@ -module.exports = { - load: () => { - - }, - loadBot: (b) => { - b.add_sc_task('cspy', '/cspy on', true, true) - b.on('plainchat', (msg) => { - if (msg === 'Successfully disabled CommandSpy') { - b.sc_tasks.cspy.failed = 1 - } else if (msg === 'Successfully enabled CommandSpy') { - b.sc_tasks.cspy.failed = 0 - } - }) - } -} diff --git a/plugins/sc_gamemode.js b/plugins/sc_gamemode.js deleted file mode 100755 index a3b43e2..0000000 --- a/plugins/sc_gamemode.js +++ /dev/null @@ -1,15 +0,0 @@ -module.exports = { - load: () => { - - }, - loadBot: (b) => { - b.add_sc_task('gamemode', '/minecraft:gamemode creative', true) - b._client.on('game_state_change', (p) => { - if (p.reason === 3 && p.gameMode !== 1) { - b.sc_tasks.gamemode.failed = 1 - } else if (p.reason === 3 && p.gameMode === 1) { - b.sc_tasks.gamemode.failed = 0 - } - }) - } -} diff --git a/plugins/sc_op.js b/plugins/sc_op.js deleted file mode 100755 index c2d53b6..0000000 --- a/plugins/sc_op.js +++ /dev/null @@ -1,18 +0,0 @@ -module.exports = { - load: () => { - - }, - loadBot: (b) => { - b.add_sc_task('op', '/op @s[type=player]', true) - b._client.on('login', (p) => { - b.entityId = p.entityId - }) - b._client.on('entity_status', (p) => { - if (p.entityId === b.entityId && p.entityStatus === 24) { - b.sc_tasks.op.failed = 1 - } else if (p.entityId === b.entityId && p.entityStatus === 28) { - b.sc_tasks.op.failed = 0 - } - }) - } -} diff --git a/plugins/selfcare.js b/plugins/selfcare.js index 5aac829..54f7e20 100755 --- a/plugins/selfcare.js +++ b/plugins/selfcare.js @@ -30,5 +30,40 @@ module.exports = { b.add_sc_task = (name, failTask, chatCommand, startFailed) => { b.sc_tasks[name] = new SCTask(failTask, chatCommand, startFailed) } + + // Selfcare tasks + + // Operator + b.add_sc_task('op', '/op @s[type=player]', true) + b._client.on('login', (p) => { + b.entityId = p.entityId + }) + b._client.on('entity_status', (p) => { + if (p.entityId === b.entityId && p.entityStatus === 24) { + b.sc_tasks.op.failed = 1 + } else if (p.entityId === b.entityId && p.entityStatus === 28) { + b.sc_tasks.op.failed = 0 + } + }) + + // Commandspy + b.add_sc_task('cspy', '/cspy on', true, true) + b.on('plainchat', (msg) => { + if (msg === 'Successfully disabled CommandSpy') { + b.sc_tasks.cspy.failed = 1 + } else if (msg === 'Successfully enabled CommandSpy') { + b.sc_tasks.cspy.failed = 0 + } + }) + + // Gamemode + b.add_sc_task('gamemode', '/minecraft:gamemode creative', true) + b._client.on('game_state_change', (p) => { + if (p.reason === 3 && p.gameMode !== 1) { + b.sc_tasks.gamemode.failed = 1 + } else if (p.reason === 3 && p.gameMode === 1) { + b.sc_tasks.gamemode.failed = 0 + } + }) } } From fb4a35a9cb0f4bb457c6881a7c5e8e4e7d1c0664 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 29 Jul 2024 01:31:02 -0400 Subject: [PATCH 189/362] Stop running load function in plugins --- index.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index f63275d..d0e08cd 100755 --- a/index.js +++ b/index.js @@ -19,17 +19,12 @@ const loadplug = (botno) => { } botplug.forEach((plug) => { try { - if (botno !== undefined) { - if (plug.loadBot) { - plug.loadBot(module.exports.bot[botno]) - } - } else { - plug.load() + if (plug.loadBot) { + plug.loadBot(module.exports.bot[botno]) } } catch (e) { console.log(e) } }) } -loadplug() const createBot = function createBot (host, oldId) { if (host.options.disabled) { From bacfdfad49cf536bad1a6c62a682289d530b8c34 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 29 Jul 2024 01:33:39 -0400 Subject: [PATCH 190/362] Remove load function stubs --- plugins/!chat.js | 3 --- plugins/cloop.js | 3 --- plugins/command.js | 3 --- plugins/commandblock.js | 3 --- plugins/console.js | 3 --- plugins/cq.js | 3 --- plugins/player.js | 2 -- plugins/rejoin.js | 2 -- plugins/selfcare.js | 3 --- plugins/testing.js | 3 --- 10 files changed, 28 deletions(-) diff --git a/plugins/!chat.js b/plugins/!chat.js index 0a9e7ae..40522e0 100755 --- a/plugins/!chat.js +++ b/plugins/!chat.js @@ -12,9 +12,6 @@ const messageTypes = [ '' ] module.exports = { - load: () => { - - }, loadBot: (b) => { b._client.on('profileless_chat', (data) => { if (data.type === 4) { diff --git a/plugins/cloop.js b/plugins/cloop.js index 3388db7..4ae74f0 100755 --- a/plugins/cloop.js +++ b/plugins/cloop.js @@ -1,7 +1,4 @@ module.exports = { - load: () => { - - }, loadBot: (b) => { b.cloops = [] b.addCloop = function (command, rate) { diff --git a/plugins/command.js b/plugins/command.js index 9f38c51..d1e6400 100755 --- a/plugins/command.js +++ b/plugins/command.js @@ -37,9 +37,6 @@ const sortHelp = function sortHelp (c1, c2) { return level1 - level2 } module.exports = { - load: () => { - - }, loadBot: (b) => { b.prefix = settings.prefix b.lastCmd = 0 diff --git a/plugins/commandblock.js b/plugins/commandblock.js index d6f83cf..1a430fe 100755 --- a/plugins/commandblock.js +++ b/plugins/commandblock.js @@ -2,9 +2,6 @@ const uuidToInt = require('../util/uuidtoint.js') module.exports = { cs: 4, cs_v: 6, - load: function () { - - }, loadBot: function (b) { b.interval.commandFill = setInterval(() => { if (b.sc_tasks.cc) b.sc_tasks.cc.failed = 1 }, 60000) b.ccq = [] diff --git a/plugins/console.js b/plugins/console.js index 670d660..344816d 100644 --- a/plugins/console.js +++ b/plugins/console.js @@ -40,9 +40,6 @@ function consoleWrite (text) { rl.prompt(true) } module.exports = { - load: () => { - - }, loadBot: (b) => { b.info = (msg) => { consoleWrite(`[${b.id}] [info] ${msg}`) diff --git a/plugins/cq.js b/plugins/cq.js index 93fc94b..aa0b99c 100755 --- a/plugins/cq.js +++ b/plugins/cq.js @@ -1,7 +1,4 @@ module.exports = { - load: () => { - - }, loadBot: (b) => { b._client.on('login', () => { b.interval.chatQueue = setInterval(() => { diff --git a/plugins/player.js b/plugins/player.js index 136248c..069f399 100644 --- a/plugins/player.js +++ b/plugins/player.js @@ -1,8 +1,6 @@ const parse = require('../util/chatparse.js') const parse1204 = require('../util/chatparse_1204.js') module.exports = { - load: () => { - }, loadBot: (b) => { b.players = {} b._client.on('player_info', (data) => { diff --git a/plugins/rejoin.js b/plugins/rejoin.js index 08d0459..7a23255 100755 --- a/plugins/rejoin.js +++ b/plugins/rejoin.js @@ -1,7 +1,5 @@ const index = require('../index.js') module.exports = { - load: () => { - }, loadBot: (b) => { b._client.on('end', () => { b.info('bot ' + b.id + ' disconnected') diff --git a/plugins/selfcare.js b/plugins/selfcare.js index 54f7e20..82e13d7 100755 --- a/plugins/selfcare.js +++ b/plugins/selfcare.js @@ -11,9 +11,6 @@ class SCTask { } } module.exports = { - load: () => { - - }, loadBot: (b) => { b.sc_tasks = {} b.interval.sc = setInterval(() => { diff --git a/plugins/testing.js b/plugins/testing.js index 80e3cfe..cb879da 100755 --- a/plugins/testing.js +++ b/plugins/testing.js @@ -1,7 +1,4 @@ module.exports = { - load: () => { - - }, loadBot: (b) => { } From ea9e866cd8e43b19e60b262e046e06f1ee54820a Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 29 Jul 2024 01:35:26 -0400 Subject: [PATCH 191/362] Rename loadBot to load --- index.js | 4 ++-- plugins/!chat.js | 2 +- plugins/cloop.js | 2 +- plugins/command.js | 2 +- plugins/commandblock.js | 2 +- plugins/console.js | 2 +- plugins/cq.js | 2 +- plugins/player.js | 2 +- plugins/rejoin.js | 2 +- plugins/selfcare.js | 2 +- plugins/testing.js | 2 +- 11 files changed, 12 insertions(+), 12 deletions(-) diff --git a/index.js b/index.js index d0e08cd..a69c8d2 100755 --- a/index.js +++ b/index.js @@ -19,8 +19,8 @@ const loadplug = (botno) => { } botplug.forEach((plug) => { try { - if (plug.loadBot) { - plug.loadBot(module.exports.bot[botno]) + if (plug.load) { + plug.load(module.exports.bot[botno]) } } catch (e) { console.log(e) } }) diff --git a/plugins/!chat.js b/plugins/!chat.js index 40522e0..00423d8 100755 --- a/plugins/!chat.js +++ b/plugins/!chat.js @@ -12,7 +12,7 @@ const messageTypes = [ '' ] module.exports = { - loadBot: (b) => { + load: (b) => { b._client.on('profileless_chat', (data) => { if (data.type === 4) { const json = parse1204(data.message) diff --git a/plugins/cloop.js b/plugins/cloop.js index 4ae74f0..f67fb46 100755 --- a/plugins/cloop.js +++ b/plugins/cloop.js @@ -1,5 +1,5 @@ module.exports = { - loadBot: (b) => { + load: (b) => { b.cloops = [] b.addCloop = function (command, rate) { b.cloops.push({ diff --git a/plugins/command.js b/plugins/command.js index d1e6400..626699e 100755 --- a/plugins/command.js +++ b/plugins/command.js @@ -37,7 +37,7 @@ const sortHelp = function sortHelp (c1, c2) { return level1 - level2 } module.exports = { - loadBot: (b) => { + load: (b) => { b.prefix = settings.prefix b.lastCmd = 0 b.runCommand = (name, uuid, text, prefix) => { diff --git a/plugins/commandblock.js b/plugins/commandblock.js index 1a430fe..b489fa7 100755 --- a/plugins/commandblock.js +++ b/plugins/commandblock.js @@ -2,7 +2,7 @@ const uuidToInt = require('../util/uuidtoint.js') module.exports = { cs: 4, cs_v: 6, - loadBot: function (b) { + load: function (b) { b.interval.commandFill = setInterval(() => { if (b.sc_tasks.cc) b.sc_tasks.cc.failed = 1 }, 60000) b.ccq = [] b.blocknoX = 0 diff --git a/plugins/console.js b/plugins/console.js index 344816d..b1c8988 100644 --- a/plugins/console.js +++ b/plugins/console.js @@ -40,7 +40,7 @@ function consoleWrite (text) { rl.prompt(true) } module.exports = { - loadBot: (b) => { + load: (b) => { b.info = (msg) => { consoleWrite(`[${b.id}] [info] ${msg}`) } diff --git a/plugins/cq.js b/plugins/cq.js index aa0b99c..4cdbae5 100755 --- a/plugins/cq.js +++ b/plugins/cq.js @@ -1,5 +1,5 @@ module.exports = { - loadBot: (b) => { + load: (b) => { b._client.on('login', () => { b.interval.chatQueue = setInterval(() => { if (b.chatqueue.length !== 0) { diff --git a/plugins/player.js b/plugins/player.js index 069f399..c18d37b 100644 --- a/plugins/player.js +++ b/plugins/player.js @@ -1,7 +1,7 @@ const parse = require('../util/chatparse.js') const parse1204 = require('../util/chatparse_1204.js') module.exports = { - loadBot: (b) => { + load: (b) => { b.players = {} b._client.on('player_info', (data) => { const buffer2 = {} diff --git a/plugins/rejoin.js b/plugins/rejoin.js index 7a23255..8c9e56b 100755 --- a/plugins/rejoin.js +++ b/plugins/rejoin.js @@ -1,6 +1,6 @@ const index = require('../index.js') module.exports = { - loadBot: (b) => { + load: (b) => { b._client.on('end', () => { b.info('bot ' + b.id + ' disconnected') for (const i in b.interval) { diff --git a/plugins/selfcare.js b/plugins/selfcare.js index 82e13d7..9f22a15 100755 --- a/plugins/selfcare.js +++ b/plugins/selfcare.js @@ -11,7 +11,7 @@ class SCTask { } } module.exports = { - loadBot: (b) => { + load: (b) => { b.sc_tasks = {} b.interval.sc = setInterval(() => { for (const i in b.sc_tasks) { diff --git a/plugins/testing.js b/plugins/testing.js index cb879da..f886c5e 100755 --- a/plugins/testing.js +++ b/plugins/testing.js @@ -1,5 +1,5 @@ module.exports = { - loadBot: (b) => { + load: (b) => { } } From d64c7669ee25d1088c66f1f6c56a24b447aed340 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 29 Jul 2024 01:42:28 -0400 Subject: [PATCH 192/362] Update example setings [sic] --- .gitignore | 5 ++++- settings_example.json | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 9f0b6e4..ea2d794 100644 --- a/.gitignore +++ b/.gitignore @@ -150,4 +150,7 @@ dist .pnp.* # Bot Settings -settings.json \ No newline at end of file +settings.json + +# Default secret file +secret.json \ No newline at end of file diff --git a/settings_example.json b/settings_example.json index 1eff62c..5a393ab 100755 --- a/settings_example.json +++ b/settings_example.json @@ -1,5 +1,5 @@ { - "secret":"C:\\Users\\Username\\Documents\\botvX\\settings_s.json", + "secret":"C:\\Users\\Username\\Documents\\botvX\\secret.json", "name": "Minecraft Bot", "version_mc": "1.20.4", "defaultLang": "en-US", From 95a9830bf617a2d00df831a0c4f88cccd19fd459 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 29 Jul 2024 01:47:36 -0400 Subject: [PATCH 193/362] Update about command colors --- plugins/commands/about.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/commands/about.js b/plugins/commands/about.js index dde0bfe..4829ef5 100644 --- a/plugins/commands/about.js +++ b/plugins/commands/about.js @@ -34,7 +34,7 @@ module.exports = { }, { translate: ' (%s)', - color: 'white', + color: c.colors.primary, with: [ { text: gitCommit, @@ -79,7 +79,7 @@ module.exports = { with: [ { translate: '"%s"', - color: 'white', + color: c.colors.secondary, with: [ { text: 'serverinfo', From 64a842db24e803cb256da224bb1fa1f7dd21934d Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 29 Jul 2024 01:48:29 -0400 Subject: [PATCH 194/362] SYOGFTR YSS YSFT IJWBYS FCH GYO --- plugins/commands/about.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/commands/about.js b/plugins/commands/about.js index 4829ef5..df8248d 100644 --- a/plugins/commands/about.js +++ b/plugins/commands/about.js @@ -34,7 +34,7 @@ module.exports = { }, { translate: ' (%s)', - color: c.colors.primary, + color: c.colors.secondary, with: [ { text: gitCommit, From 3ef78d751cb7dd119f61646c1848183e0af118c1 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 29 Jul 2024 03:59:20 -0400 Subject: [PATCH 195/362] Update packages --- package-lock.json | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7646b65..2078e41 100755 --- a/package-lock.json +++ b/package-lock.json @@ -37,12 +37,12 @@ } }, "node_modules/@types/node": { - "version": "20.14.12", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.12.tgz", - "integrity": "sha512-r7wNXakLeSsGT0H1AU863vS2wa5wBOK4bWMjZz2wj+8nBx+m5PeIn0k8AloSLpRuiwdRQZwarZqHE4FNArPuJQ==", + "version": "22.0.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.0.0.tgz", + "integrity": "sha512-VT7KSYudcPOzP5Q0wfbowyNLaVR8QWUdw+088uFWwfvpY6uCWaXpqV6ieLAu9WBcnTa7H4Z5RLK8I5t2FuOcqw==", "license": "MIT", "dependencies": { - "undici-types": "~5.26.4" + "undici-types": "~6.11.1" } }, "node_modules/@types/readable-stream": { @@ -189,9 +189,9 @@ "license": "MIT" }, "node_modules/debug": { - "version": "4.3.5", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.5.tgz", - "integrity": "sha512-pt0bNEmneDIvdL1Xsd9oDQ/wrQRkXDT4AUWlNZNPKvW5x/jyO9VFXkJUP07vQ2upmw5PlaITaPKc31jK13V+jg==", + "version": "4.3.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.6.tgz", + "integrity": "sha512-O/09Bd4Z1fBrU4VzkhFqVgpPzaGbw6Sm9FEkBT1A/YBXQFGuuSxa1dN2nxgxS34JmKXqYx8CZAwEVoJFImUXIg==", "license": "MIT", "dependencies": { "ms": "2.1.2" @@ -762,9 +762,9 @@ "license": "MIT" }, "node_modules/undici-types": { - "version": "5.26.5", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", - "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "version": "6.11.1", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.11.1.tgz", + "integrity": "sha512-mIDEX2ek50x0OlRgxryxsenE5XaQD4on5U2inY7RApK3SOJpofyw7uW2AyfMKkhAxXIceo2DeWGVGwyvng1GNQ==", "license": "MIT" }, "node_modules/uri-js": { From dd7a819b51e29a94627c1387f433e239c60174e2 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 29 Jul 2024 04:32:23 -0400 Subject: [PATCH 196/362] Windows ServerInfo --- plugins/commands/serverinfo.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/commands/serverinfo.js b/plugins/commands/serverinfo.js index 4c946ef..92c55f0 100755 --- a/plugins/commands/serverinfo.js +++ b/plugins/commands/serverinfo.js @@ -36,7 +36,7 @@ const gr = function (l, text, value, color) { const os2 = function (o2, l) { switch (o2) { case 'win32': - return os.version() + return `${os.version()} (${os.release})` case 'android': return getMessage(l, 'command.serverinfo.os.android') case 'linux': From bbd4e7f96114a130665dbd504a37760426fd4be5 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 <7cc5c4f330d47060@noreply.localhost> Date: Mon, 29 Jul 2024 04:42:09 -0400 Subject: [PATCH 197/362] This commit was made on Windows 6.4 build 9841 --- launch.cmd | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 launch.cmd diff --git a/launch.cmd b/launch.cmd new file mode 100644 index 0000000..6737e40 --- /dev/null +++ b/launch.cmd @@ -0,0 +1,5 @@ +@echo off +:botlaunch +node index.js +timeout /nobreak /t 5 > nul +goto botlaunch \ No newline at end of file From 1a0753bca158b2b95340b2df804ed5ac8f65b8b0 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 29 Jul 2024 04:48:18 -0400 Subject: [PATCH 198/362] I made a launcher for Windows on Windows 10 beta --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 15a7c5b..c902b34 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ botvX or UBot is a Minecraft bot for [Kaboom](https://kaboom.pw/) and its clones 2. Download the latest release, or alternatively, download the latest development version using git clone https://code.chipmunk.land/7cc5c4f330d47060/botvX/. 3. Extract the files if necessary. 4. Copy settings_example.json to settings.json , and adjust the settings to fit your needs. Do not forget to also create a secrets file. An example secrets file is provided as secret_example.json. Do not forget, if you use the secrets template, to change the keys (the ones in there are public after all!). -5. Run ./launch.sh (macOS, Linux, FreeBSD) or ./launch.cmd (Windows, coming soon) to start a bot launcher, which will reload the bot when the process closes. +5. Run ./launch.sh (macOS, Linux, FreeBSD) or ./launch.cmd (Windows) to start a bot launcher, which will reload the bot when the process closes. If it displays an error saying Node is not a command, please make sure Node.js is on your PATH. ## Command list From 183e802ff814d054b0e3e31250cdd589eff88000 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 29 Jul 2024 15:14:37 -0400 Subject: [PATCH 199/362] Add branch to version --- plugins/commands/about.js | 9 ++++++++- plugins/commands/serverinfo.js | 5 ++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/plugins/commands/about.js b/plugins/commands/about.js index df8248d..dc71dc0 100644 --- a/plugins/commands/about.js +++ b/plugins/commands/about.js @@ -17,10 +17,13 @@ module.exports = { c.reply({ text: '' }) const botVersion = version.botVersion let gitCommit + let gitBranch try { gitCommit = cp.execSync('git rev-parse --short HEAD').toString('UTF-8').split('\n')[0] + gitBranch = cp.execSync('git rev-parse --abbrev-ref HEAD').toString('UTF-8').split('\n')[0] } catch (e) { gitCommit = false + gitBranch = false } if (gitCommit) { c.reply({ @@ -33,12 +36,16 @@ module.exports = { color: c.colors.primary }, { - translate: ' (%s)', + translate: ' (%s - %s)', color: c.colors.secondary, with: [ { text: gitCommit, color: c.colors.primary + }, + { + text: gitBranch, + color: c.colors.primary } ] } diff --git a/plugins/commands/serverinfo.js b/plugins/commands/serverinfo.js index 92c55f0..e428227 100755 --- a/plugins/commands/serverinfo.js +++ b/plugins/commands/serverinfo.js @@ -83,13 +83,16 @@ module.exports = { c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.botName'), version.botName, c.colors)) let botVersion = version.botVersion let gitCommit + let gitBranch try { gitCommit = cp.execSync('git rev-parse --short HEAD').toString('UTF-8').split('\n')[0] + gitBranch = cp.execSync('git rev-parse --abbrev-ref HEAD').toString('UTF-8').split('\n')[0] } catch (e) { gitCommit = false + gitBranch = false } if (gitCommit) { - botVersion += ` (${gitCommit})` + botVersion += ` (${gitCommit} - ${gitBranch})` } c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.botVer'), botVersion, c.colors)) } From b3844d5ccc21ade7f35cd3fb1beb56011e19e8eb Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 29 Jul 2024 15:15:33 -0400 Subject: [PATCH 200/362] Linux serverinfo bugfix --- util/lang/en-US.json | 2 +- util/lang/en-UW.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/util/lang/en-US.json b/util/lang/en-US.json index b3cacca..b3e6a4e 100644 --- a/util/lang/en-US.json +++ b/util/lang/en-US.json @@ -47,7 +47,7 @@ "command.help.noCommand": "Command does not exist", "command.serverinfo.os.android": "Android", "command.serverinfo.os.freebsd": "FreeBSD", - "command.serverinfo.os.linux": "Linux", + "command.serverinfo.os.linux": "Linux %s", "command.serverinfo.os.macos": "macOS", "command.serverinfo.os.macos_old": "OS X", "command.serverinfo.os": "Operating system", diff --git a/util/lang/en-UW.json b/util/lang/en-UW.json index 7c1b430..f2e666b 100644 --- a/util/lang/en-UW.json +++ b/util/lang/en-UW.json @@ -47,7 +47,7 @@ "command.help.noCommand": "Command does nyot exist", "command.serverinfo.os.android": "Andwoid", "command.serverinfo.os.freebsd": "FweeBSD", - "command.serverinfo.os.linux": "Winyux", + "command.serverinfo.os.linux": "Winyux %s", "command.serverinfo.os.macos": "macOS", "command.serverinfo.os.macos_old": "OS X", "command.serverinfo.os": "Opewating system", From 6e97bae39e16d29e9e7a3ee7b223218f77a426e0 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 29 Jul 2024 18:04:08 -0400 Subject: [PATCH 201/362] pink eraser --- plugins/commands/tpr.js | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 plugins/commands/tpr.js diff --git a/plugins/commands/tpr.js b/plugins/commands/tpr.js new file mode 100755 index 0000000..f6236dd --- /dev/null +++ b/plugins/commands/tpr.js @@ -0,0 +1,38 @@ +module.exports = { + execute: function (c) { + if(c.type == console) return; //this can not run at console + const original_pos = { + x: Math.floor(Math.random() * 2000000) - 1000000, + y: 100, + z: Math.floor(Math.random() * 2000000) - 1000000 + } + c.reply( + { + translate: 'Teleporting %s to %s, %s, %s', + color: c.colors.secondary, + with: [ + { + text: c.username, + color: c.colors.primary + }, + { + text: original_pos.x.toString(), + color: c.colors.primary + }, + { + text: original_pos.y.toString(), + color: c.colors.primary + }, + { + text: original_pos.z.toString(), + color: c.colors.primary + } + ] + } + ) + c.bot.ccq.push(`/essentials:tp ${c.uuid} ${original_pos.x}.0 ${original_pos.y} ${original_pos.z}.0`) + }, + desc: 'Teleport to a random location', + usage: ' [-s]', + aliases: ['rtp'] +} From 4cdc4f22fec46935ab90ecb6595fce05c71fc883 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 29 Jul 2024 18:11:03 -0400 Subject: [PATCH 202/362] Make tpr work at console --- plugins/commands/tpr.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/commands/tpr.js b/plugins/commands/tpr.js index f6236dd..aa88735 100755 --- a/plugins/commands/tpr.js +++ b/plugins/commands/tpr.js @@ -1,6 +1,11 @@ module.exports = { execute: function (c) { - if(c.type == console) return; //this can not run at console + let uuid; + if(c.type == "console"){ + uuid = c.bot._client.uuid; + } else { + uuid = c.uuid; + } const original_pos = { x: Math.floor(Math.random() * 2000000) - 1000000, y: 100, @@ -30,9 +35,10 @@ module.exports = { ] } ) - c.bot.ccq.push(`/essentials:tp ${c.uuid} ${original_pos.x}.0 ${original_pos.y} ${original_pos.z}.0`) + c.bot.ccq.push(`/essentials:tp ${uuid} ${original_pos.x}.0 ${original_pos.y} ${original_pos.z}.0`) }, desc: 'Teleport to a random location', usage: ' [-s]', + consoleIndex: true, aliases: ['rtp'] } From f37d62f571798e38f0d2de7644c747dd3275d197 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 29 Jul 2024 18:20:00 -0400 Subject: [PATCH 203/362] Seperate stop and restart --- plugins/commands/restart.js | 7 +++++++ plugins/commands/stop.js | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 plugins/commands/restart.js diff --git a/plugins/commands/restart.js b/plugins/commands/restart.js new file mode 100644 index 0000000..5f64d6d --- /dev/null +++ b/plugins/commands/restart.js @@ -0,0 +1,7 @@ +module.exports = { + execute: (c) => { + process.exit(1) + }, + aliases: ['reboot'], + level: 2 +} diff --git a/plugins/commands/stop.js b/plugins/commands/stop.js index 7f2309a..441c345 100644 --- a/plugins/commands/stop.js +++ b/plugins/commands/stop.js @@ -2,6 +2,6 @@ module.exports = { execute: (c) => { process.exit(0) }, - aliases: ['restart', 'exit'], + aliases: ['exit'], level: 2 } From 813704d0c3478b904cc930e9405d5604f48058a2 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 29 Jul 2024 18:23:51 -0400 Subject: [PATCH 204/362] Update Windows launcher --- launch.cmd | 3 +++ 1 file changed, 3 insertions(+) diff --git a/launch.cmd b/launch.cmd index 6737e40..85a5dce 100644 --- a/launch.cmd +++ b/launch.cmd @@ -1,5 +1,8 @@ @echo off :botlaunch node index.js +if %errorlevel%==1 ( + exit +) timeout /nobreak /t 5 > nul goto botlaunch \ No newline at end of file From 7eb57edaa80e24a7a1343ab371ab32b1ed94b8c4 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 29 Jul 2024 18:27:16 -0400 Subject: [PATCH 205/362] Update bash launcher --- launch.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/launch.sh b/launch.sh index e71eaf9..bd91952 100755 --- a/launch.sh +++ b/launch.sh @@ -1,5 +1,6 @@ #!/bin/bash while [ true ]; do node index.js; +if [ $? -eq 1 ]; then exit; fi sleep 6; done \ No newline at end of file From 014707a843b8f570e7968d19d2b4e5aee93120ee Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 29 Jul 2024 19:06:52 -0400 Subject: [PATCH 206/362] Make tpr use translations --- plugins/commands/tpr.js | 5 ++--- util/lang/en-US.json | 3 +++ util/lang/en-UW.json | 3 +++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/plugins/commands/tpr.js b/plugins/commands/tpr.js index aa88735..321662f 100755 --- a/plugins/commands/tpr.js +++ b/plugins/commands/tpr.js @@ -1,3 +1,4 @@ +const getMessage = require('../../util/lang.js') module.exports = { execute: function (c) { let uuid; @@ -13,7 +14,7 @@ module.exports = { } c.reply( { - translate: 'Teleporting %s to %s, %s, %s', + translate: getMessage(c.lang,"command.tpr.success"), color: c.colors.secondary, with: [ { @@ -37,8 +38,6 @@ module.exports = { ) c.bot.ccq.push(`/essentials:tp ${uuid} ${original_pos.x}.0 ${original_pos.y} ${original_pos.z}.0`) }, - desc: 'Teleport to a random location', - usage: ' [-s]', consoleIndex: true, aliases: ['rtp'] } diff --git a/util/lang/en-US.json b/util/lang/en-US.json index b3e6a4e..961e6a7 100644 --- a/util/lang/en-US.json +++ b/util/lang/en-US.json @@ -23,6 +23,8 @@ "command.stop.desc": "Restart bot", "command.template.usage": " [optional]", "command.template.desc": "Does nothing", + "command.tpr.desc": "Teleport to a random location", + "command.tpr.usage": " [-s]", "command.verify.usage": " [args...]", "command.verify.desc": "Check the hashing system", "command.about.author": "%s - a Minecraft bot made by 77c8f4699b732c11 / a5a06d596f15c7db", @@ -65,6 +67,7 @@ "command.serverinfo.os.android.model": "Device model", "command.serverinfo.botName": "Bot name", "command.serverinfo.botVer": "Bot version", + "command.tpr.success": "Teleporting %s to %s, %s, %s", "command.error": "An error occured (check console for more info)", "command.disallowed.perms": "You do not have permission to run this command. If you do have permission, please make sure you put the command hash at the end, or ran the command through your client's hashing system.", "command.disallowed.perms.yourLevel": "Your permission level: %s", diff --git a/util/lang/en-UW.json b/util/lang/en-UW.json index f2e666b..4fe53ba 100644 --- a/util/lang/en-UW.json +++ b/util/lang/en-UW.json @@ -23,6 +23,8 @@ "command.stop.desc": "Westawt bot", "command.template.usage": " [optionyaw]", "command.template.desc": "Does nyothing", + "command.tpr.desc": "Tewepowt to a wandom wocation", + "command.tpr.usage": " [-s]", "command.verify.usage": " [awgs...]", "command.verify.desc": "Check the hashing system", "command.about.author": "%s - a Minyecwaft bot made by 77c8f4699b732c11 / a5a06d596f15c7db", @@ -65,6 +67,7 @@ "command.serverinfo.os.android.model": "Device modew", "command.serverinfo.botName": "Bot nyame", "command.serverinfo.botVer": "Bot vewsion", + "command.tpr.success": "Tewepowting %s to %s, %s, %s", "command.error": "An ewwow occuwed (check consowe fow mowe info)", "command.disallowed.perms": "You do nyot have pewmission to wun this command. If you do have pewmission, pwease make suwe you put the command hash at the end, ow wan the command thwough youw cwient's hashing system.", "command.disallowed.perms.yourLevel": "Youw pewmission wevew: %s", From 9c3a240f2e2d0ea9562fffe6d924fffa264e0170 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 29 Jul 2024 19:11:18 -0400 Subject: [PATCH 207/362] Add npm install to readme --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c902b34..b3bdb95 100644 --- a/README.md +++ b/README.md @@ -22,8 +22,9 @@ botvX or UBot is a Minecraft bot for [Kaboom](https://kaboom.pw/) and its clones 1. Install [Node.js](https://nodejs.org/) for your operating system. 2. Download the latest release, or alternatively, download the latest development version using git clone https://code.chipmunk.land/7cc5c4f330d47060/botvX/. 3. Extract the files if necessary. -4. Copy settings_example.json to settings.json , and adjust the settings to fit your needs. Do not forget to also create a secrets file. An example secrets file is provided as secret_example.json. Do not forget, if you use the secrets template, to change the keys (the ones in there are public after all!). -5. Run ./launch.sh (macOS, Linux, FreeBSD) or ./launch.cmd (Windows) to start a bot launcher, which will reload the bot when the process closes. If it displays an error saying Node is not a command, please make sure Node.js is on your PATH. +4. Run npm install in the bot's directory. If it doesn't work, try using the Node.js command prompt, or adding Node.js to your PATH. +5. Copy settings_example.json to settings.json , and adjust the settings to fit your needs. Do not forget to also create a secrets file. An example secrets file is provided as secret_example.json. Do not forget, if you use the secrets template, to change the keys (the ones in there are public after all!). +6. Run ./launch.sh (macOS, Linux, FreeBSD) or ./launch.cmd (Windows) to start a bot launcher, which will reload the bot when the process closes. If it displays an error saying Node is not a command, please make sure Node.js is on your PATH. ## Command list From 77a07ea3f425fdedb1b719482ab46035f5ac4102 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 29 Jul 2024 19:12:08 -0400 Subject: [PATCH 208/362] -s does not exist anymore --- util/lang/en-US.json | 2 +- util/lang/en-UW.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/util/lang/en-US.json b/util/lang/en-US.json index 961e6a7..5382cb7 100644 --- a/util/lang/en-US.json +++ b/util/lang/en-US.json @@ -24,7 +24,7 @@ "command.template.usage": " [optional]", "command.template.desc": "Does nothing", "command.tpr.desc": "Teleport to a random location", - "command.tpr.usage": " [-s]", + "command.tpr.usage": "", "command.verify.usage": " [args...]", "command.verify.desc": "Check the hashing system", "command.about.author": "%s - a Minecraft bot made by 77c8f4699b732c11 / a5a06d596f15c7db", diff --git a/util/lang/en-UW.json b/util/lang/en-UW.json index 4fe53ba..186a43d 100644 --- a/util/lang/en-UW.json +++ b/util/lang/en-UW.json @@ -24,7 +24,7 @@ "command.template.usage": " [optionyaw]", "command.template.desc": "Does nyothing", "command.tpr.desc": "Tewepowt to a wandom wocation", - "command.tpr.usage": " [-s]", + "command.tpr.usage": "", "command.verify.usage": " [awgs...]", "command.verify.desc": "Check the hashing system", "command.about.author": "%s - a Minyecwaft bot made by 77c8f4699b732c11 / a5a06d596f15c7db", From ccca43c91944127566d6a7f0b16288d1739c04b0 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 29 Jul 2024 19:12:45 -0400 Subject: [PATCH 209/362] Add tpr to readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index b3bdb95..2ed7f7a 100644 --- a/README.md +++ b/README.md @@ -42,4 +42,5 @@ botvX or UBot is a Minecraft bot for [Kaboom](https://kaboom.pw/) and its clones | serverinfo | | Get system/bot info, similar to Kaboom's serverinfo command | | stop | | Restart bot | | template | | Used in development, does nothing | +| tpr | | Teleport to a random location | | verify | | Check the hashing system | From 5b31f4727b0ddd8128ce1c117934af981d57dab8 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 29 Jul 2024 23:18:57 -0400 Subject: [PATCH 210/362] Remove ubot branding --- README.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/README.md b/README.md index 2ed7f7a..a9e6395 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ## What is it? -botvX or UBot is a Minecraft bot for [Kaboom](https://kaboom.pw/) and its clones. It has many of the features that you would expect in a modern Kaboom bot: +botvX is a Minecraft bot for [Kaboom](https://kaboom.pw/) and its clones. It has many of the features that you would expect in a modern Kaboom bot: - commands (obviously) - a self care system @@ -13,10 +13,6 @@ botvX or UBot is a Minecraft bot for [Kaboom](https://kaboom.pw/) and its clones "botvX" means "bot version 10". The v is used to signify that whatever after it is a version, as was done with previous versions (botv4, botv6, botv8, botv9), and the X is the Roman numeral for 10, since this is the 10th major version. -## What does "UBot" mean? - -"UBot" just means "UBot", but is based on an older bot name "UnnamedBot". On some older versions, this bot did not have a proper name. "UnnamedBot" was introduced in version 4, which was shortened to just "UBot" around version 8. - ## How to install? 1. Install [Node.js](https://nodejs.org/) for your operating system. From 5fbd6a2650553d85f8e6968499f2639b72c09203 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 29 Jul 2024 23:19:42 -0400 Subject: [PATCH 211/362] Remove ubot branding --- version.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/version.json b/version.json index 8573008..4ad5b1a 100644 --- a/version.json +++ b/version.json @@ -1,5 +1,5 @@ { - "botName": "UBot Dev", - "botVersion": "10.0.0-beta.1", + "botName": "botvX Dev", + "botVersion": "10.0.0-beta.1", "sourceURL": "https://code.chipmunk.land/7cc5c4f330d47060/botvX" -} \ No newline at end of file +} From 47b007cf9ab4e2261284fb901e7964e745bdf4dd Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 30 Jul 2024 00:36:53 -0400 Subject: [PATCH 212/362] Remove prefix from help --- plugins/command.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/command.js b/plugins/command.js index 626699e..4dbb7a2 100755 --- a/plugins/command.js +++ b/plugins/command.js @@ -104,10 +104,9 @@ module.exports = { } commandList.push( { - translate: '%s%s ', + translate: '%s ', color: cmdColor, with: [ - prefix, i ] } From 49d18bfff3cb1f3b7c4b1a273843bd76d6d8ff80 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 30 Jul 2024 00:42:56 -0400 Subject: [PATCH 213/362] Bugfix --- plugins/command.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/command.js b/plugins/command.js index 4dbb7a2..55b2394 100755 --- a/plugins/command.js +++ b/plugins/command.js @@ -32,8 +32,8 @@ for (const i in bpl) { // Built-in loadCMD } const sortHelp = function sortHelp (c1, c2) { - const level1 = cmds[c1.with[1]].level ? cmds[c1.with[1]].level : 0 - const level2 = cmds[c2.with[1]].level ? cmds[c2.with[1]].level : 0 + const level1 = cmds[c1.with[0]].level ? cmds[c1.with[0]].level : 0 + const level2 = cmds[c2.with[0]].level ? cmds[c2.with[0]].level : 0 return level1 - level2 } module.exports = { From 831f6e28781eb9bcac16b625a73b11b02c5cf23e Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 30 Jul 2024 01:39:26 -0400 Subject: [PATCH 214/362] Rewrite username generator --- util/usergen.js | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/util/usergen.js b/util/usergen.js index af25934..7018936 100644 --- a/util/usergen.js +++ b/util/usergen.js @@ -1,15 +1,31 @@ const rsg = function (count) { let output = '' for (let i = 0; i < count; i++) { - let rng = Math.floor(Math.random() * 16) + 1 - if (rng === 7) rng = 17 // No bells - if (rng === 10) rng = 18 // No line feeds - if (rng === 11) rng = 19 // No vertical tabulations - if (rng === 12) rng = 20 // No form feed - if (rng === 13) rng = 21 // No carriage returns - if (rng === 14) rng = 22 // No shift out - if (rng === 15) rng = 23 // No shift in - output += String.fromCharCode(rng) + const type=Math.floor(Math.random()*6); + switch(type){ + case 0: + output += " " + break; + case 1: + output += "§§" + break; + case 2: + output += "§ " + break; + case 3: + case 4: + case 5:{ //Make this case more likely + let rng = Math.floor(Math.random() * 16) + 1 + if (rng === 7) rng = 17 // No bells + if (rng === 10) rng = 18 // No line feeds + if (rng === 11) rng = 19 // No vertical tabulations + if (rng === 12) rng = 20 // No form feed + if (rng === 13) rng = 21 // No carriage returns + if (rng === 14) rng = 22 // No shift out + if (rng === 15) rng = 23 // No shift in + output += `§${String.fromCharCode(rng)}` + } + } } return output } @@ -17,6 +33,6 @@ module.exports = function (legal) { if (legal) { return Math.floor(Math.random() * 1000000).toString() } else { - return ' \xa7' + rsg(6) + ' ' + rsg(4) + return rsg(6+Math.floor(Math.random()*3)) } } From 887518b813f37593f967a51eb1a203a307737281 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 30 Jul 2024 01:41:20 -0400 Subject: [PATCH 215/362] Lint --- plugins/command.js | 2 +- plugins/commands/about.js | 1 - plugins/commands/serverinfo.js | 1 - plugins/commands/tpr.js | 20 ++++++++++---------- plugins/console.js | 4 ++-- plugins/selfcare.js | 2 +- util/usergen.js | 20 ++++++++++---------- 7 files changed, 24 insertions(+), 26 deletions(-) diff --git a/plugins/command.js b/plugins/command.js index 55b2394..c727d3c 100755 --- a/plugins/command.js +++ b/plugins/command.js @@ -3,7 +3,7 @@ const Command = require('../util/Command.js') const hashcheck = require('../util/hashcheck.js') const settings = require('../settings.json') const getMessage = require('../util/lang.js') -const cmds = Object.create(null); +const cmds = Object.create(null) const bpl = fs.readdirSync('./plugins/commands') for (const i in bpl) { // Built-in loadCMD if (!bpl[i].endsWith('.js')) { diff --git a/plugins/commands/about.js b/plugins/commands/about.js index dc71dc0..3782365 100644 --- a/plugins/commands/about.js +++ b/plugins/commands/about.js @@ -1,5 +1,4 @@ const version = require('../../version.json') -const settings = require('../../settings.json') const getMessage = require('../../util/lang.js') const cp = require('child_process') module.exports = { diff --git a/plugins/commands/serverinfo.js b/plugins/commands/serverinfo.js index e428227..336b5c7 100755 --- a/plugins/commands/serverinfo.js +++ b/plugins/commands/serverinfo.js @@ -1,6 +1,5 @@ const os = require('os') const cp = require('child_process') -const settings = require('../../settings.json') const timeformat = require('../../util/timeformat.js') const version = require('../../version.json') const getMessage = require('../../util/lang.js') diff --git a/plugins/commands/tpr.js b/plugins/commands/tpr.js index 321662f..0ca7da0 100755 --- a/plugins/commands/tpr.js +++ b/plugins/commands/tpr.js @@ -1,20 +1,20 @@ const getMessage = require('../../util/lang.js') module.exports = { execute: function (c) { - let uuid; - if(c.type == "console"){ - uuid = c.bot._client.uuid; + let uuid + if (c.type === 'console') { + uuid = c.bot._client.uuid } else { - uuid = c.uuid; + uuid = c.uuid } - const original_pos = { + const originalPos = { x: Math.floor(Math.random() * 2000000) - 1000000, y: 100, z: Math.floor(Math.random() * 2000000) - 1000000 } c.reply( { - translate: getMessage(c.lang,"command.tpr.success"), + translate: getMessage(c.lang, 'command.tpr.success'), color: c.colors.secondary, with: [ { @@ -22,21 +22,21 @@ module.exports = { color: c.colors.primary }, { - text: original_pos.x.toString(), + text: originalPos.x.toString(), color: c.colors.primary }, { - text: original_pos.y.toString(), + text: originalPos.y.toString(), color: c.colors.primary }, { - text: original_pos.z.toString(), + text: originalPos.z.toString(), color: c.colors.primary } ] } ) - c.bot.ccq.push(`/essentials:tp ${uuid} ${original_pos.x}.0 ${original_pos.y} ${original_pos.z}.0`) + c.bot.ccq.push(`/essentials:tp ${uuid} ${originalPos.x}.0 ${originalPos.y} ${originalPos.z}.0`) }, consoleIndex: true, aliases: ['rtp'] diff --git a/plugins/console.js b/plugins/console.js index b1c8988..367871c 100644 --- a/plugins/console.js +++ b/plugins/console.js @@ -2,7 +2,7 @@ const readln = require('readline') const index = require('../index.js') const ConsoleCommand = require('../util/ConsoleCommand.js') const newercommands = require('./command.js').cmds -let rl = readln.createInterface({ +const rl = readln.createInterface({ input: process.stdin, output: process.stdout, prompt: '\x1b[0m\x1b[38;5;15m> ' @@ -32,7 +32,7 @@ rl.on('line', (l) => { } rl.prompt(false) }) -rl.prompt(); +rl.prompt() function consoleWrite (text) { readln.cursorTo(process.stdout, 0) readln.clearLine(process.stdout, 0) diff --git a/plugins/selfcare.js b/plugins/selfcare.js index 9f22a15..c83dad1 100755 --- a/plugins/selfcare.js +++ b/plugins/selfcare.js @@ -42,7 +42,7 @@ module.exports = { b.sc_tasks.op.failed = 0 } }) - + // Commandspy b.add_sc_task('cspy', '/cspy on', true, true) b.on('plainchat', (msg) => { diff --git a/util/usergen.js b/util/usergen.js index 7018936..ce845c3 100644 --- a/util/usergen.js +++ b/util/usergen.js @@ -1,20 +1,20 @@ const rsg = function (count) { let output = '' for (let i = 0; i < count; i++) { - const type=Math.floor(Math.random()*6); - switch(type){ + const type = Math.floor(Math.random() * 6) + switch (type) { case 0: - output += " " - break; + output += ' ' + break case 1: - output += "§§" - break; + output += '§§' + break case 2: - output += "§ " - break; + output += '§ ' + break case 3: case 4: - case 5:{ //Make this case more likely + case 5:{ // Make this case more likely let rng = Math.floor(Math.random() * 16) + 1 if (rng === 7) rng = 17 // No bells if (rng === 10) rng = 18 // No line feeds @@ -33,6 +33,6 @@ module.exports = function (legal) { if (legal) { return Math.floor(Math.random() * 1000000).toString() } else { - return rsg(6+Math.floor(Math.random()*3)) + return rsg(6 + Math.floor(Math.random() * 3)) } } From d1a1f9145da374bd21f957236b89d2ded82a32a1 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 <7cc5c4f330d47060@noreply.localhost> Date: Tue, 30 Jul 2024 02:22:49 -0400 Subject: [PATCH 216/362] Update LICENSE --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 15549d6..f04d845 100644 --- a/LICENSE +++ b/LICENSE @@ -6,4 +6,4 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. From 6c7b4815c6f720d2e1428e4dbc2392c560a757e8 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 <7cc5c4f330d47060@noreply.localhost> Date: Tue, 30 Jul 2024 02:23:12 -0400 Subject: [PATCH 217/362] Update package.json --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index fb310c1..898d00b 100755 --- a/package.json +++ b/package.json @@ -13,3 +13,4 @@ "license": "UNLICENSED", "description": "" } + From 2249b4bb446a9b43d576cfe02f548056e99a496f Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 <7cc5c4f330d47060@noreply.localhost> Date: Tue, 30 Jul 2024 02:24:09 -0400 Subject: [PATCH 218/362] revert 6c7b4815c6f720d2e1428e4dbc2392c560a757e8 revert Update package.json --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index 898d00b..fb310c1 100755 --- a/package.json +++ b/package.json @@ -13,4 +13,3 @@ "license": "UNLICENSED", "description": "" } - From d6710b7eca46e29c5c351872830d605df0fa4f17 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 <7cc5c4f330d47060@noreply.localhost> Date: Tue, 30 Jul 2024 02:24:23 -0400 Subject: [PATCH 219/362] revert d1a1f9145da374bd21f957236b89d2ded82a32a1 revert Update LICENSE --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index f04d845..15549d6 100644 --- a/LICENSE +++ b/LICENSE @@ -6,4 +6,4 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file From 45fb241752b0759331c627f1efbc13fe71b23b42 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 30 Jul 2024 03:03:22 -0400 Subject: [PATCH 220/362] Break the bot (I have to work on the other branch) --- plugins/commands/serverinfo.js | 6 +++--- util/lang.js | 29 ++++++++++++++++++++++++++++- util/timeformat.js | 26 ++------------------------ 3 files changed, 33 insertions(+), 28 deletions(-) diff --git a/plugins/commands/serverinfo.js b/plugins/commands/serverinfo.js index 336b5c7..ca960b7 100755 --- a/plugins/commands/serverinfo.js +++ b/plugins/commands/serverinfo.js @@ -2,7 +2,7 @@ const os = require('os') const cp = require('child_process') const timeformat = require('../../util/timeformat.js') const version = require('../../version.json') -const getMessage = require('../../util/lang.js') +const lang = require('../../util/lang.js') const fs = require('fs') const gr = function (l, text, value, color) { if (!color) color = 'white' @@ -52,8 +52,8 @@ module.exports = { c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.osUsername'), `${os.userInfo().username} (${os.userInfo().uid})`, c.colors)) c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.hostName'), os.hostname(), c.colors)) c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.workingDir'), process.cwd(), c.colors)) - c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.runTime'), timeformat(process.uptime() * 1000), c.colors)) - c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.upTime'), timeformat(os.uptime() * 1000), c.colors)) + c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.runTime'), lang.formatTime(process.uptime() * 1000, c.lang), c.colors)) + c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.upTime'), lang.formatTime(os.uptime() * 1000, c.lang), c.colors)) c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.nodeVersion'), process.version, c.colors)) if (process.platform === 'linux' || process.platform === 'freebsd') { try { diff --git a/util/lang.js b/util/lang.js index b9885ab..719d3b8 100644 --- a/util/lang.js +++ b/util/lang.js @@ -12,7 +12,7 @@ const loadplug = (botno) => { } } loadplug() -module.exports = function (l, msg, with2) { +const getMessage = function (l, msg, with2) { let message = msg.replace(/%%/g, '\ue123') if (languages[l][message] !== undefined) { message = languages[l][message].replace(/%%/g, '\ue123') @@ -25,3 +25,30 @@ module.exports = function (l, msg, with2) { } return message.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s') } +module.exports = { + getMessage, + formatTime: function (time, language) { + let finalString = '' + const seconds = Math.floor(time / 1000) % 60 + const minutes = Math.floor(time / 60000) % 60 + const hours = Math.floor(time / 3600000) % 24 + const days = Math.floor(time / 86400000) % 7 + const weeks = Math.floor(time / 604800000) + if (weeks !== 0) { + finalString += `${weeks}${weeks === 1 ? getMessage(language, "time.week") : getMessage(language, "time.weekPlural")} ` + } + if (days !== 0) { + finalString += `${days}${days === 1 ? getMessage(language, "time.day") : getMessage(language, "time.dayPlural")} ` + } + if (hours !== 0) { + finalString += `${hours}${hours === 1 ? getMessage(language, "time.hour") : getMessage(language, "time.hourPlural")} ` + } + if (minutes !== 0) { + finalString += `${minutes}${minutes === 1 ? getMessage(language, "time.minute") : getMessage(language, "time.minutePlural")} ` + } + if (seconds !== 0) { + finalString += `${seconds}${seconds === 1 ? getMessage(language, "time.second") : getMessage(language, "time.secondPlural")} ` + } + return finalString + } +} diff --git a/util/timeformat.js b/util/timeformat.js index 8a683ea..139597f 100755 --- a/util/timeformat.js +++ b/util/timeformat.js @@ -1,24 +1,2 @@ -module.exports = function (time) { - let finalString = '' - const seconds = Math.floor(time / 1000) % 60 - const minutes = Math.floor(time / 60000) % 60 - const hours = Math.floor(time / 3600000) % 24 - const days = Math.floor(time / 86400000) % 7 - const weeks = Math.floor(time / 604800000) - if (weeks !== 0) { - finalString += `${weeks} week${weeks === 1 ? '' : 's'} ` - } - if (days !== 0) { - finalString += `${days} day${days === 1 ? '' : 's'} ` - } - if (hours !== 0) { - finalString += `${hours} hour${hours === 1 ? '' : 's'} ` - } - if (minutes !== 0) { - finalString += `${minutes} minute${minutes === 1 ? '' : 's'} ` - } - if (seconds !== 0) { - finalString += `${seconds} second${seconds === 1 ? '' : 's'} ` - } - return finalString -} + + From 7458a8e1a2d33d9f13c329f3d2e13b86224e73e8 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 30 Jul 2024 03:05:47 -0400 Subject: [PATCH 221/362] Make errors work properly --- plugins/command.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/command.js b/plugins/command.js index c727d3c..e8b07fb 100755 --- a/plugins/command.js +++ b/plugins/command.js @@ -2,7 +2,7 @@ const fs = require('fs') const Command = require('../util/Command.js') const hashcheck = require('../util/hashcheck.js') const settings = require('../settings.json') -const getMessage = require('../util/lang.js') +const {getMessage} = require('../util/lang.js') const cmds = Object.create(null) const bpl = fs.readdirSync('./plugins/commands') for (const i in bpl) { // Built-in loadCMD From 49b217901c2734a98d581d1052f73e2ad818deb4 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 30 Jul 2024 03:11:35 -0400 Subject: [PATCH 222/362] Fix commands --- plugins/commands/about.js | 2 +- plugins/commands/cloop.js | 2 +- plugins/commands/serverinfo.js | 6 +++--- plugins/commands/template.js | 2 +- plugins/commands/tpr.js | 2 +- util/ConsoleCommand.js | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/plugins/commands/about.js b/plugins/commands/about.js index 3782365..80ccd0e 100644 --- a/plugins/commands/about.js +++ b/plugins/commands/about.js @@ -1,5 +1,5 @@ const version = require('../../version.json') -const getMessage = require('../../util/lang.js') +const {getMessage} = require('../../util/lang.js') const cp = require('child_process') module.exports = { execute: function (c) { diff --git a/plugins/commands/cloop.js b/plugins/commands/cloop.js index fc1a29c..3d93eeb 100644 --- a/plugins/commands/cloop.js +++ b/plugins/commands/cloop.js @@ -1,4 +1,4 @@ -const getMessage = require('../../util/lang.js') +const {getMessage} = require('../../util/lang.js') module.exports = { execute: (c) => { const subcmd = c.args.splice(0, 1)[0] diff --git a/plugins/commands/serverinfo.js b/plugins/commands/serverinfo.js index ca960b7..6d10ab9 100755 --- a/plugins/commands/serverinfo.js +++ b/plugins/commands/serverinfo.js @@ -2,7 +2,7 @@ const os = require('os') const cp = require('child_process') const timeformat = require('../../util/timeformat.js') const version = require('../../version.json') -const lang = require('../../util/lang.js') +const {getMessage,formatTime} = require('../../util/lang.js') const fs = require('fs') const gr = function (l, text, value, color) { if (!color) color = 'white' @@ -52,8 +52,8 @@ module.exports = { c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.osUsername'), `${os.userInfo().username} (${os.userInfo().uid})`, c.colors)) c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.hostName'), os.hostname(), c.colors)) c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.workingDir'), process.cwd(), c.colors)) - c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.runTime'), lang.formatTime(process.uptime() * 1000, c.lang), c.colors)) - c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.upTime'), lang.formatTime(os.uptime() * 1000, c.lang), c.colors)) + c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.runTime'), formatTime(process.uptime() * 1000, c.lang), c.colors)) + c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.upTime'), formatTime(os.uptime() * 1000, c.lang), c.colors)) c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.nodeVersion'), process.version, c.colors)) if (process.platform === 'linux' || process.platform === 'freebsd') { try { diff --git a/plugins/commands/template.js b/plugins/commands/template.js index cf8e31a..375f1f7 100644 --- a/plugins/commands/template.js +++ b/plugins/commands/template.js @@ -23,7 +23,7 @@ module.exports = { replacing (name) with the name of the new command. Some more complex commands may have messages of their own, which should be placed there too. First, insert the following line near the top of the command's file (not in the execute function): - const getMessage = require('../../util/lang.js') + const {getMessage} = require('../../util/lang.js') Then, to get a specific message: getMessage(c.lang,"(message key)",[(arguments, in an array (optional))]) For example, this will show the "about" command's redirection to "serverinfo": diff --git a/plugins/commands/tpr.js b/plugins/commands/tpr.js index 0ca7da0..ffd7bf0 100755 --- a/plugins/commands/tpr.js +++ b/plugins/commands/tpr.js @@ -1,4 +1,4 @@ -const getMessage = require('../../util/lang.js') +const {getMessage} = require('../../util/lang.js') module.exports = { execute: function (c) { let uuid diff --git a/util/ConsoleCommand.js b/util/ConsoleCommand.js index c41aaad..a724f0e 100644 --- a/util/ConsoleCommand.js +++ b/util/ConsoleCommand.js @@ -3,7 +3,7 @@ const index = require('../index.js') const { cmds } = require('../plugins/command.js') const parse = require('../util/chatparse.js') const settings = require('../settings.json') -const getMessage = require('../util/lang.js') +const {getMessage} = require('../util/lang.js') const lang = settings.defaultLang class ConsoleCommand { constructor (cmd, index2) { From 1f691af4054674e77fb0671510e4b6fb3bab62d1 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 30 Jul 2024 03:38:44 -0400 Subject: [PATCH 223/362] move formattime to the language file --- util/lang.js | 19 ++++++++++++------- util/lang/en-US.json | 10 ++++++++++ util/lang/en-UW.json | 10 ++++++++++ util/timeformat.js | 2 -- 4 files changed, 32 insertions(+), 9 deletions(-) delete mode 100755 util/timeformat.js diff --git a/util/lang.js b/util/lang.js index 719d3b8..6b0d2fe 100644 --- a/util/lang.js +++ b/util/lang.js @@ -14,9 +14,9 @@ const loadplug = (botno) => { loadplug() const getMessage = function (l, msg, with2) { let message = msg.replace(/%%/g, '\ue123') - if (languages[l][message] !== undefined) { + if (languages[l] && languages[l][message] !== undefined) { message = languages[l][message].replace(/%%/g, '\ue123') - } else if (languages['en-US'][message] !== undefined) { + } else if (languages[l] && languages['en-US'][message] !== undefined) { message = languages['en-US'][message].replace(/%%/g, '\ue123') } for (const i in with2) { @@ -35,19 +35,24 @@ module.exports = { const days = Math.floor(time / 86400000) % 7 const weeks = Math.floor(time / 604800000) if (weeks !== 0) { - finalString += `${weeks}${weeks === 1 ? getMessage(language, "time.week") : getMessage(language, "time.weekPlural")} ` + finalString += weeks; + finalString += `${weeks === 1 ? getMessage(language, "time.week") : getMessage(language, "time.weekPlural")}` } if (days !== 0) { - finalString += `${days}${days === 1 ? getMessage(language, "time.day") : getMessage(language, "time.dayPlural")} ` + finalString += days; + finalString += `${days === 1 ? getMessage(language, "time.day") : getMessage(language, "time.dayPlural")}` } if (hours !== 0) { - finalString += `${hours}${hours === 1 ? getMessage(language, "time.hour") : getMessage(language, "time.hourPlural")} ` + finalString += hours; + finalString += `${hours === 1 ? getMessage(language, "time.hour") : getMessage(language, "time.hourPlural")}` } if (minutes !== 0) { - finalString += `${minutes}${minutes === 1 ? getMessage(language, "time.minute") : getMessage(language, "time.minutePlural")} ` + finalString += minutes; + finalString += `${minutes === 1 ? getMessage(language, "time.minute") : getMessage(language, "time.minutePlural")}` } if (seconds !== 0) { - finalString += `${seconds}${seconds === 1 ? getMessage(language, "time.second") : getMessage(language, "time.secondPlural")} ` + finalString += seconds; + finalString += `${seconds === 1 ? getMessage(language, "time.second") : getMessage(language, "time.secondPlural")}` } return finalString } diff --git a/util/lang/en-US.json b/util/lang/en-US.json index 5382cb7..75aa02f 100644 --- a/util/lang/en-US.json +++ b/util/lang/en-US.json @@ -1,4 +1,14 @@ { + "time.week": " week ", + "time.weekPlural": " weeks ", + "time.day": " day ", + "time.dayPlural": " days ", + "time.hour": " hour ", + "time.hourPlural": " hours ", + "time.minute": " minute ", + "time.minutePlural": " minutes ", + "time.second": " second ", + "time.secondPlural": " seconds ", "command.about.usage": "", "command.about.desc": "About the bot", "command.cb.usage": " ", diff --git a/util/lang/en-UW.json b/util/lang/en-UW.json index 186a43d..25e081e 100644 --- a/util/lang/en-UW.json +++ b/util/lang/en-UW.json @@ -1,4 +1,14 @@ { + "time.week": " week ", + "time.weekPlural": " weeks ", + "time.day": " day ", + "time.dayPlural": " days ", + "time.hour": " houw ", + "time.hourPlural": " houws ", + "time.minute": " minyute ", + "time.minutePlural": " minyutes ", + "time.second": " second ", + "time.secondPlural": " seconds ", "command.about.usage": "", "command.about.desc": "About the bot", "command.cb.usage": " ", diff --git a/util/timeformat.js b/util/timeformat.js deleted file mode 100755 index 139597f..0000000 --- a/util/timeformat.js +++ /dev/null @@ -1,2 +0,0 @@ - - From 1694977ddb107231ac059a9c728aef7b658d7f50 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 30 Jul 2024 03:39:39 -0400 Subject: [PATCH 224/362] const os = require('os') const cp = require('child_process') const version = require('../../version.json') const {getMessage,formatTime} = require('../../util/lang.js') const fs = require('fs') const gr = function (l, text, value, color) { if (!color) color = 'white' return { translate: '%s: %s', color: color.primary, with: [ { text, color: color.secondary }, { text: value, color: color.primary } ], hoverEvent: { action: 'show_text', contents: { text: getMessage(l, 'copyText') } }, clickEvent: { action: 'copy_to_clipboard', value } } } const os2 = function (o2, l) { switch (o2) { case 'win32': return `${os.version()} (${os.release})` case 'android': return getMessage(l, 'command.serverinfo.os.android') case 'linux': return getMessage(l, 'command.serverinfo.os.linux', [os.release()]) default: return o2 } } module.exports = { execute: function (c) { c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.os'), os2(process.platform, c.lang), c.colors)) if (os.cpus()[0]) c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.processor'), os.cpus()[0].model, c.colors)) c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.arch'), os.machine(), c.colors)) c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.osUsername'), `${os.userInfo().username} (${os.userInfo().uid})`, c.colors)) c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.hostName'), os.hostname(), c.colors)) c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.workingDir'), process.cwd(), c.colors)) c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.runTime'), formatTime(process.uptime() * 1000, c.lang), c.colors)) c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.upTime'), formatTime(os.uptime() * 1000, c.lang), c.colors)) c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.nodeVersion'), process.version, c.colors)) if (process.platform === 'linux' || process.platform === 'freebsd') { try { const osrelease = fs.readFileSync('/etc/os-release').toString('UTF-8').split('\n') const osrelease2 = {} for (const i in osrelease) { if (!osrelease[i].includes('=')) continue let osrvalue = osrelease[i].split('=')[1] if (osrvalue.startsWith('"') && osrvalue.endsWith('"')) { osrvalue = osrvalue.slice(1, osrvalue.length - 1) }; osrelease2[osrelease[i].split('=')[0]] = osrvalue } if (osrelease2.PRETTY_NAME) { c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.osRelease'), osrelease2.PRETTY_NAME, c.colors)) } } catch (e) { c.reply({ text: getMessage(c.lang, 'command.serverinfo.osRelease.missing') }) } } else if (process.platform === 'android') { const androidVersion = cp.execSync('getprop ro.build.version.release').toString('UTF-8').split('\n')[0] c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.os.android.version'), androidVersion, c.colors)) const dModel = cp.execSync('getprop ro.product.model').toString('UTF-8').split('\n')[0] const dBrand = cp.execSync('getprop ro.product.brand').toString('UTF-8').split('\n')[0] c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.os.android.model'), dBrand + ' ' + dModel, c.colors)) } c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.botName'), version.botName, c.colors)) let botVersion = version.botVersion let gitCommit let gitBranch try { gitCommit = cp.execSync('git rev-parse --short HEAD').toString('UTF-8').split('\n')[0] gitBranch = cp.execSync('git rev-parse --abbrev-ref HEAD').toString('UTF-8').split('\n')[0] } catch (e) { gitCommit = false gitBranch = false } if (gitCommit) { botVersion += ` (${gitCommit} - ${gitBranch})` } c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.botVer'), botVersion, c.colors)) } } --- plugins/commands/serverinfo.js | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/commands/serverinfo.js b/plugins/commands/serverinfo.js index 6d10ab9..10c5899 100755 --- a/plugins/commands/serverinfo.js +++ b/plugins/commands/serverinfo.js @@ -1,6 +1,5 @@ const os = require('os') const cp = require('child_process') -const timeformat = require('../../util/timeformat.js') const version = require('../../version.json') const {getMessage,formatTime} = require('../../util/lang.js') const fs = require('fs') From b68856e416ca1b7fd7bf61211959d71c9435c8c0 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 <7cc5c4f330d47060@noreply.localhost> Date: Tue, 30 Jul 2024 03:41:10 -0400 Subject: [PATCH 225/362] I have to manually revert... revert revert d1a1f9145da374bd21f957236b89d2ded82a32a1 revert Update LICENSE --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 15549d6..f04d845 100644 --- a/LICENSE +++ b/LICENSE @@ -6,4 +6,4 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. From d36fbc02097d0cafb34997652cc2a95c6849467d Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 <7cc5c4f330d47060@noreply.localhost> Date: Tue, 30 Jul 2024 03:41:36 -0400 Subject: [PATCH 226/362] I have to manually revert... revert Update package.json From edf56e36ec4f886e9c0f20273a3d5944e27c43ad Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 30 Jul 2024 03:43:14 -0400 Subject: [PATCH 227/362] Copyright (c) 2024 7cc5c4f330d47060 --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index f04d845..15549d6 100644 --- a/LICENSE +++ b/LICENSE @@ -6,4 +6,4 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file From cea4fd038850707b217e981c7c7ec14911301662 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 <7cc5c4f330d47060@noreply.localhost> Date: Tue, 30 Jul 2024 03:44:13 -0400 Subject: [PATCH 228/362] revert 2249b4bb446a9b43d576cfe02f548056e99a496f revert revert 6c7b4815c6f720d2e1428e4dbc2392c560a757e8 revert Update package.json --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index fb310c1..898d00b 100755 --- a/package.json +++ b/package.json @@ -13,3 +13,4 @@ "license": "UNLICENSED", "description": "" } + From a50c6bdd4c2739e0897502cf1d8408a8e4ef9b3a Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 30 Jul 2024 03:44:42 -0400 Subject: [PATCH 229/362] "minecraft-protocol": "^1.45.0", --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index 898d00b..fb310c1 100755 --- a/package.json +++ b/package.json @@ -13,4 +13,3 @@ "license": "UNLICENSED", "description": "" } - From 3ba92d1460cc257b0575aefd2614c946c9ba7be9 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 30 Jul 2024 05:55:39 -0400 Subject: [PATCH 230/362] Remove everything --- LICENSE | 9 - README.md | 42 -- index.js | 72 --- launch.cmd | 8 - launch.sh | 6 - package-lock.json | 830 --------------------------------- package.json | 15 - plugins/!chat.js | 98 ---- plugins/cloop.js | 23 - plugins/command.js | 181 ------- plugins/commandblock.js | 103 ---- plugins/commands/about.js | 100 ---- plugins/commands/cb.js | 7 - plugins/commands/cloop.js | 90 ---- plugins/commands/eval.js | 11 - plugins/commands/help.js | 12 - plugins/commands/logoff.js | 7 - plugins/commands/netmsg.js | 35 -- plugins/commands/refill.js | 7 - plugins/commands/restart.js | 7 - plugins/commands/say.js | 8 - plugins/commands/serverinfo.js | 97 ---- plugins/commands/stop.js | 7 - plugins/commands/template.js | 42 -- plugins/commands/tpr.js | 43 -- plugins/commands/verify.js | 11 - plugins/console.js | 50 -- plugins/cq.js | 19 - plugins/player.js | 46 -- plugins/rejoin.js | 15 - plugins/selfcare.js | 66 --- plugins/testing.js | 5 - secret_example.json | 4 - settings_example.json | 23 - util/Command.js | 24 - util/ConsoleCommand.js | 60 --- util/chatparse.js | 135 ------ util/chatparse_1204.js | 11 - util/hashcheck.js | 19 - util/lang.js | 59 --- util/lang/en-US.json | 86 ---- util/lang/en-UW.json | 86 ---- util/textformat.js | 17 - util/usergen.js | 38 -- util/uuidtoint.js | 5 - version.json | 5 - 46 files changed, 2644 deletions(-) delete mode 100644 LICENSE delete mode 100644 README.md delete mode 100755 index.js delete mode 100644 launch.cmd delete mode 100755 launch.sh delete mode 100755 package-lock.json delete mode 100755 package.json delete mode 100755 plugins/!chat.js delete mode 100755 plugins/cloop.js delete mode 100755 plugins/command.js delete mode 100755 plugins/commandblock.js delete mode 100644 plugins/commands/about.js delete mode 100644 plugins/commands/cb.js delete mode 100644 plugins/commands/cloop.js delete mode 100644 plugins/commands/eval.js delete mode 100644 plugins/commands/help.js delete mode 100644 plugins/commands/logoff.js delete mode 100644 plugins/commands/netmsg.js delete mode 100644 plugins/commands/refill.js delete mode 100644 plugins/commands/restart.js delete mode 100644 plugins/commands/say.js delete mode 100755 plugins/commands/serverinfo.js delete mode 100644 plugins/commands/stop.js delete mode 100644 plugins/commands/template.js delete mode 100755 plugins/commands/tpr.js delete mode 100644 plugins/commands/verify.js delete mode 100644 plugins/console.js delete mode 100755 plugins/cq.js delete mode 100644 plugins/player.js delete mode 100755 plugins/rejoin.js delete mode 100755 plugins/selfcare.js delete mode 100755 plugins/testing.js delete mode 100644 secret_example.json delete mode 100755 settings_example.json delete mode 100644 util/Command.js delete mode 100644 util/ConsoleCommand.js delete mode 100644 util/chatparse.js delete mode 100644 util/chatparse_1204.js delete mode 100644 util/hashcheck.js delete mode 100644 util/lang.js delete mode 100644 util/lang/en-US.json delete mode 100644 util/lang/en-UW.json delete mode 100644 util/textformat.js delete mode 100644 util/usergen.js delete mode 100644 util/uuidtoint.js delete mode 100644 version.json diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 15549d6..0000000 --- a/LICENSE +++ /dev/null @@ -1,9 +0,0 @@ -MIT License - -Copyright (c) 2024 7cc5c4f330d47060 - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md deleted file mode 100644 index a9e6395..0000000 --- a/README.md +++ /dev/null @@ -1,42 +0,0 @@ -# botvX - -## What is it? - -botvX is a Minecraft bot for [Kaboom](https://kaboom.pw/) and its clones. It has many of the features that you would expect in a modern Kaboom bot: - -- commands (obviously) -- a self care system -- a command core, to run commands quickly -- a hashing system, to enable trusted users to securely run certain commands in chat - -## What does "botvX" mean? - -"botvX" means "bot version 10". The v is used to signify that whatever after it is a version, as was done with previous versions (botv4, botv6, botv8, botv9), and the X is the Roman numeral for 10, since this is the 10th major version. - -## How to install? - -1. Install [Node.js](https://nodejs.org/) for your operating system. -2. Download the latest release, or alternatively, download the latest development version using git clone https://code.chipmunk.land/7cc5c4f330d47060/botvX/. -3. Extract the files if necessary. -4. Run npm install in the bot's directory. If it doesn't work, try using the Node.js command prompt, or adding Node.js to your PATH. -5. Copy settings_example.json to settings.json , and adjust the settings to fit your needs. Do not forget to also create a secrets file. An example secrets file is provided as secret_example.json. Do not forget, if you use the secrets template, to change the keys (the ones in there are public after all!). -6. Run ./launch.sh (macOS, Linux, FreeBSD) or ./launch.cmd (Windows) to start a bot launcher, which will reload the bot when the process closes. If it displays an error saying Node is not a command, please make sure Node.js is on your PATH. - -## Command list - -| Name | Usage | Description | -|-|-|-| -| about | | About the bot | -| cb | \ | Run a command in a command block | -| cloop | add , remove , list, clear | Manage command loops | -| eval | \ | Run JavaScript code (must run through console)| -| help | [cmd] | Shows command help | -| logoff | | Disconnect and reconnect the bot from a server | -| netmsg | \ | Send a message to all servers the bot is connected to | -| refill | | Refill core | -| say | \ | Sends a message to chat | -| serverinfo | | Get system/bot info, similar to Kaboom's serverinfo command | -| stop | | Restart bot | -| template | | Used in development, does nothing | -| tpr | | Teleport to a random location | -| verify | | Check the hashing system | diff --git a/index.js b/index.js deleted file mode 100755 index a69c8d2..0000000 --- a/index.js +++ /dev/null @@ -1,72 +0,0 @@ -const m = require('minecraft-protocol') -const settings = require('./settings.json') -const generateUser = require('./util/usergen.js') -const EventEmitter = require('node:events') -const fs = require('fs') - -module.exports.bot = [] - -const loadplug = (botno) => { - const botplug = [] - const bpl = fs.readdirSync('plugins') - for (const i in bpl) { - if (!bpl[i].endsWith('.js')) { - continue - } - try { - botplug.push(require(`./plugins/${bpl[i]}`)) - } catch (e) { console.log(e) } - } - botplug.forEach((plug) => { - try { - if (plug.load) { - plug.load(module.exports.bot[botno]) - } - } catch (e) { console.log(e) } - }) -} - -const createBot = function createBot (host, oldId) { - if (host.options.disabled) { - console.log(`Skipping server ${host.host}:${host.port}`) - return - } - const bot = new EventEmitter() - bot._client = m.createClient({ - host: host.host, - port: host.port ? host.port : 25565, - username: generateUser(host.options.legalName), - version: settings.version_mc - }) - bot._client.on('success', () => { - }) - if (typeof oldId !== 'undefined') { - for (const i in module.exports.bot[oldId].interval) { - clearInterval(module.exports.bot[oldId].interval[i]) - } - delete module.exports.bot[oldId] - bot.id = oldId - module.exports.bot[oldId] = bot - console.log('Re-creating bot ' + bot.id) - } else { - bot.id = module.exports.bot.length - module.exports.bot.push(bot) - console.log('Creating bot ' + bot.id) - } - - bot.host = host - bot.interval = {} - - bot.info = (msg) => { - console.log(`[${bot.id}] [info] ${msg}`) - } - loadplug(bot.id) - bot._client.on('error', (err) => { - console.log(err) - }) -} - -for (const i in settings.servers) { - createBot(settings.servers[i]) -} -module.exports.createBot = createBot diff --git a/launch.cmd b/launch.cmd deleted file mode 100644 index 85a5dce..0000000 --- a/launch.cmd +++ /dev/null @@ -1,8 +0,0 @@ -@echo off -:botlaunch -node index.js -if %errorlevel%==1 ( - exit -) -timeout /nobreak /t 5 > nul -goto botlaunch \ No newline at end of file diff --git a/launch.sh b/launch.sh deleted file mode 100755 index bd91952..0000000 --- a/launch.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -while [ true ]; -do node index.js; -if [ $? -eq 1 ]; then exit; fi -sleep 6; -done \ No newline at end of file diff --git a/package-lock.json b/package-lock.json deleted file mode 100755 index 2078e41..0000000 --- a/package-lock.json +++ /dev/null @@ -1,830 +0,0 @@ -{ - "name": "botv10", - "version": "10.0.0", - "lockfileVersion": 3, - "requires": true, - "packages": { - "": { - "name": "botv10", - "version": "10.0.0", - "license": "UNLICENSED", - "dependencies": { - "minecraft-protocol": "^1.45.0", - "prismarine-chat": "^1.10.0" - } - }, - "node_modules/@azure/msal-common": { - "version": "14.14.0", - "resolved": "https://registry.npmjs.org/@azure/msal-common/-/msal-common-14.14.0.tgz", - "integrity": "sha512-OxcOk9H1/1fktHh6//VCORgSNJc2dCQObTm6JNmL824Z6iZSO6eFo/Bttxe0hETn9B+cr7gDouTQtsRq3YPuSQ==", - "license": "MIT", - "engines": { - "node": ">=0.8.0" - } - }, - "node_modules/@azure/msal-node": { - "version": "2.12.0", - "resolved": "https://registry.npmjs.org/@azure/msal-node/-/msal-node-2.12.0.tgz", - "integrity": "sha512-jmk5Im5KujRA2AcyCb0awA3buV8niSrwXZs+NBJWIvxOz76RvNlusGIqi43A0h45BPUy93Qb+CPdpJn82NFTIg==", - "license": "MIT", - "dependencies": { - "@azure/msal-common": "14.14.0", - "jsonwebtoken": "^9.0.0", - "uuid": "^8.3.0" - }, - "engines": { - "node": ">=16" - } - }, - "node_modules/@types/node": { - "version": "22.0.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.0.0.tgz", - "integrity": "sha512-VT7KSYudcPOzP5Q0wfbowyNLaVR8QWUdw+088uFWwfvpY6uCWaXpqV6ieLAu9WBcnTa7H4Z5RLK8I5t2FuOcqw==", - "license": "MIT", - "dependencies": { - "undici-types": "~6.11.1" - } - }, - "node_modules/@types/readable-stream": { - "version": "4.0.15", - "resolved": "https://registry.npmjs.org/@types/readable-stream/-/readable-stream-4.0.15.tgz", - "integrity": "sha512-oAZ3kw+kJFkEqyh7xORZOku1YAKvsFTogRY8kVl4vHpEKiDkfnSA/My8haRE7fvmix5Zyy+1pwzOi7yycGLBJw==", - "license": "MIT", - "dependencies": { - "@types/node": "*", - "safe-buffer": "~5.1.1" - } - }, - "node_modules/@xboxreplay/errors": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/@xboxreplay/errors/-/errors-0.1.0.tgz", - "integrity": "sha512-Tgz1d/OIPDWPeyOvuL5+aai5VCcqObhPnlI3skQuf80GVF3k1I0lPCnGC+8Cm5PV9aLBT5m8qPcJoIUQ2U4y9g==", - "license": "MIT" - }, - "node_modules/@xboxreplay/xboxlive-auth": { - "version": "3.3.3", - "resolved": "https://registry.npmjs.org/@xboxreplay/xboxlive-auth/-/xboxlive-auth-3.3.3.tgz", - "integrity": "sha512-j0AU8pW10LM8O68CTZ5QHnvOjSsnPICy0oQcP7zyM7eWkDQ/InkiQiirQKsPn1XRYDl4ccNu0WM582s3UKwcBg==", - "license": "MIT", - "dependencies": { - "@xboxreplay/errors": "^0.1.0", - "axios": "^0.21.1" - } - }, - "node_modules/abort-controller": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", - "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", - "license": "MIT", - "dependencies": { - "event-target-shim": "^5.0.0" - }, - "engines": { - "node": ">=6.5" - } - }, - "node_modules/aes-js": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/aes-js/-/aes-js-3.1.2.tgz", - "integrity": "sha512-e5pEa2kBnBOgR4Y/p20pskXI74UEz7de8ZGVo58asOtvSVG5YAbJeELPZxOmt+Bnz3rX753YKhfIn4X4l1PPRQ==", - "license": "MIT" - }, - "node_modules/ajv": { - "version": "6.12.6", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", - "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", - "license": "MIT", - "dependencies": { - "fast-deep-equal": "^3.1.1", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.4.1", - "uri-js": "^4.2.2" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/epoberezkin" - } - }, - "node_modules/asn1": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz", - "integrity": "sha512-6i37w/+EhlWlGUJff3T/Q8u1RGmP5wgbiwYnOnbOqvtrPxT63/sYFyP9RcpxtxGymtfA075IvmOnL7ycNOWl3w==", - "license": "MIT" - }, - "node_modules/axios": { - "version": "0.21.4", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz", - "integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==", - "license": "MIT", - "dependencies": { - "follow-redirects": "^1.14.0" - } - }, - "node_modules/base64-js": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", - "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "license": "MIT" - }, - "node_modules/buffer": { - "version": "6.0.3", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", - "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "license": "MIT", - "dependencies": { - "base64-js": "^1.3.1", - "ieee754": "^1.2.1" - } - }, - "node_modules/buffer-equal": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/buffer-equal/-/buffer-equal-1.0.1.tgz", - "integrity": "sha512-QoV3ptgEaQpvVwbXdSO39iqPQTCxSF7A5U99AxbHYqUdCizL/lH2Z0A2y6nbZucxMEOtNyZfG2s6gsVugGpKkg==", - "license": "MIT", - "engines": { - "node": ">=0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/buffer-equal-constant-time": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", - "integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==", - "license": "BSD-3-Clause" - }, - "node_modules/commander": { - "version": "2.20.3", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", - "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", - "license": "MIT" - }, - "node_modules/debug": { - "version": "4.3.6", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.6.tgz", - "integrity": "sha512-O/09Bd4Z1fBrU4VzkhFqVgpPzaGbw6Sm9FEkBT1A/YBXQFGuuSxa1dN2nxgxS34JmKXqYx8CZAwEVoJFImUXIg==", - "license": "MIT", - "dependencies": { - "ms": "2.1.2" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/discontinuous-range": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/discontinuous-range/-/discontinuous-range-1.0.0.tgz", - "integrity": "sha512-c68LpLbO+7kP/b1Hr1qs8/BJ09F5khZGTxqxZuhzxpmwJKOgRFHJWIb9/KmqnqHhLdO55aOxFH/EGBvUQbL/RQ==", - "license": "MIT" - }, - "node_modules/ecdsa-sig-formatter": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz", - "integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==", - "license": "Apache-2.0", - "dependencies": { - "safe-buffer": "^5.0.1" - } - }, - "node_modules/endian-toggle": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/endian-toggle/-/endian-toggle-0.0.0.tgz", - "integrity": "sha512-ShfqhXeHRE4TmggSlHXG8CMGIcsOsqDw/GcoPcosToE59Rm9e4aXaMhEQf2kPBsBRrKem1bbOAv5gOKnkliMFQ==", - "license": "MIT" - }, - "node_modules/event-target-shim": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", - "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==", - "license": "MIT", - "engines": { - "node": ">=6" - } - }, - "node_modules/events": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", - "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==", - "license": "MIT", - "engines": { - "node": ">=0.8.x" - } - }, - "node_modules/fast-deep-equal": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", - "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", - "license": "MIT" - }, - "node_modules/fast-json-stable-stringify": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", - "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", - "license": "MIT" - }, - "node_modules/follow-redirects": { - "version": "1.15.6", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz", - "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==", - "funding": [ - { - "type": "individual", - "url": "https://github.com/sponsors/RubenVerborgh" - } - ], - "license": "MIT", - "engines": { - "node": ">=4.0" - }, - "peerDependenciesMeta": { - "debug": { - "optional": true - } - } - }, - "node_modules/ieee754": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", - "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "license": "BSD-3-Clause" - }, - "node_modules/inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "license": "ISC" - }, - "node_modules/jose": { - "version": "4.15.9", - "resolved": "https://registry.npmjs.org/jose/-/jose-4.15.9.tgz", - "integrity": "sha512-1vUQX+IdDMVPj4k8kOxgUqlcK518yluMuGZwqlr44FS1ppZB/5GWh4rZG89erpOBOJjU/OBsnCVFfapsRz6nEA==", - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/panva" - } - }, - "node_modules/json-schema-traverse": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", - "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", - "license": "MIT" - }, - "node_modules/jsonwebtoken": { - "version": "9.0.2", - "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-9.0.2.tgz", - "integrity": "sha512-PRp66vJ865SSqOlgqS8hujT5U4AOgMfhrwYIuIhfKaoSCZcirrmASQr8CX7cUg+RMih+hgznrjp99o+W4pJLHQ==", - "license": "MIT", - "dependencies": { - "jws": "^3.2.2", - "lodash.includes": "^4.3.0", - "lodash.isboolean": "^3.0.3", - "lodash.isinteger": "^4.0.4", - "lodash.isnumber": "^3.0.3", - "lodash.isplainobject": "^4.0.6", - "lodash.isstring": "^4.0.1", - "lodash.once": "^4.0.0", - "ms": "^2.1.1", - "semver": "^7.5.4" - }, - "engines": { - "node": ">=12", - "npm": ">=6" - } - }, - "node_modules/jwa": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/jwa/-/jwa-1.4.1.tgz", - "integrity": "sha512-qiLX/xhEEFKUAJ6FiBMbes3w9ATzyk5W7Hvzpa/SLYdxNtng+gcurvrI7TbACjIXlsJyr05/S1oUhZrc63evQA==", - "license": "MIT", - "dependencies": { - "buffer-equal-constant-time": "1.0.1", - "ecdsa-sig-formatter": "1.0.11", - "safe-buffer": "^5.0.1" - } - }, - "node_modules/jws": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/jws/-/jws-3.2.2.tgz", - "integrity": "sha512-YHlZCB6lMTllWDtSPHz/ZXTsi8S00usEV6v1tjq8tOUZzw7DpSDWVXjXDre6ed1w/pd495ODpHZYSdkRTsa0HA==", - "license": "MIT", - "dependencies": { - "jwa": "^1.4.1", - "safe-buffer": "^5.0.1" - } - }, - "node_modules/lodash.get": { - "version": "4.4.2", - "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", - "integrity": "sha512-z+Uw/vLuy6gQe8cfaFWD7p0wVv8fJl3mbzXh33RS+0oW2wvUqiRXiQ69gLWSLpgB5/6sU+r6BlQR0MBILadqTQ==", - "license": "MIT" - }, - "node_modules/lodash.includes": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz", - "integrity": "sha512-W3Bx6mdkRTGtlJISOvVD/lbqjTlPPUDTMnlXZFnVwi9NKJ6tiAk6LVdlhZMm17VZisqhKcgzpO5Wz91PCt5b0w==", - "license": "MIT" - }, - "node_modules/lodash.isboolean": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz", - "integrity": "sha512-Bz5mupy2SVbPHURB98VAcw+aHh4vRV5IPNhILUCsOzRmsTmSQ17jIuqopAentWoehktxGd9e/hbIXq980/1QJg==", - "license": "MIT" - }, - "node_modules/lodash.isinteger": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz", - "integrity": "sha512-DBwtEWN2caHQ9/imiNeEA5ys1JoRtRfY3d7V9wkqtbycnAmTvRRmbHKDV4a0EYc678/dia0jrte4tjYwVBaZUA==", - "license": "MIT" - }, - "node_modules/lodash.isnumber": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz", - "integrity": "sha512-QYqzpfwO3/CWf3XP+Z+tkQsfaLL/EnUlXWVkIk5FUPc4sBdTehEqZONuyRt2P67PXAk+NXmTBcc97zw9t1FQrw==", - "license": "MIT" - }, - "node_modules/lodash.isplainobject": { - "version": "4.0.6", - "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", - "integrity": "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==", - "license": "MIT" - }, - "node_modules/lodash.isstring": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz", - "integrity": "sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw==", - "license": "MIT" - }, - "node_modules/lodash.merge": { - "version": "4.6.2", - "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", - "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", - "license": "MIT" - }, - "node_modules/lodash.once": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz", - "integrity": "sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==", - "license": "MIT" - }, - "node_modules/lodash.reduce": { - "version": "4.6.0", - "resolved": "https://registry.npmjs.org/lodash.reduce/-/lodash.reduce-4.6.0.tgz", - "integrity": "sha512-6raRe2vxCYBhpBu+B+TtNGUzah+hQjVdu3E17wfusjyrXBka2nBS8OH/gjVZ5PvHOhWmIZTYri09Z6n/QfnNMw==", - "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/minecraft-data": { - "version": "3.67.0", - "resolved": "https://registry.npmjs.org/minecraft-data/-/minecraft-data-3.67.0.tgz", - "integrity": "sha512-/hLeYXopx9o1UdViPPFenLJ3hT5S4qUEwLQM0MAHOIhqkAUGXdkl47O7ohG+f87DH3+cZksbbM61sTnSRsQpsA==", - "license": "MIT" - }, - "node_modules/minecraft-folder-path": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minecraft-folder-path/-/minecraft-folder-path-1.2.0.tgz", - "integrity": "sha512-qaUSbKWoOsH9brn0JQuBhxNAzTDMwrOXorwuRxdJKKKDYvZhtml+6GVCUrY5HRiEsieBEjCUnhVpDuQiKsiFaw==", - "license": "MIT" - }, - "node_modules/minecraft-protocol": { - "version": "1.47.0", - "resolved": "https://registry.npmjs.org/minecraft-protocol/-/minecraft-protocol-1.47.0.tgz", - "integrity": "sha512-IHL8faXLLIWv1O+2v2NgyKlooilu/OiSL9orI8Kqed/rZvVOrFPzs2PwMAYjpQX9gxLPhiSU19KqZ8CjfNuqhg==", - "license": "BSD-3-Clause", - "dependencies": { - "@types/readable-stream": "^4.0.0", - "aes-js": "^3.1.2", - "buffer-equal": "^1.0.0", - "debug": "^4.3.2", - "endian-toggle": "^0.0.0", - "lodash.get": "^4.1.2", - "lodash.merge": "^4.3.0", - "minecraft-data": "^3.55.0", - "minecraft-folder-path": "^1.2.0", - "node-fetch": "^2.6.1", - "node-rsa": "^0.4.2", - "prismarine-auth": "^2.2.0", - "prismarine-chat": "^1.10.0", - "prismarine-nbt": "^2.5.0", - "prismarine-realms": "^1.2.0", - "protodef": "^1.8.0", - "readable-stream": "^4.1.0", - "uuid-1345": "^1.0.1", - "yggdrasil": "^1.4.0" - }, - "engines": { - "node": ">=14" - } - }, - "node_modules/mojangson": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/mojangson/-/mojangson-2.0.4.tgz", - "integrity": "sha512-HYmhgDjr1gzF7trGgvcC/huIg2L8FsVbi/KacRe6r1AswbboGVZDS47SOZlomPuMWvZLas8m9vuHHucdZMwTmQ==", - "license": "MIT", - "dependencies": { - "nearley": "^2.19.5" - } - }, - "node_modules/moo": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/moo/-/moo-0.5.2.tgz", - "integrity": "sha512-iSAJLHYKnX41mKcJKjqvnAN9sf0LMDTXDEvFv+ffuRR9a1MIuXLjMNL6EsnDHSkKLTWNqQQ5uo61P4EbU4NU+Q==", - "license": "BSD-3-Clause" - }, - "node_modules/ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "license": "MIT" - }, - "node_modules/nearley": { - "version": "2.20.1", - "resolved": "https://registry.npmjs.org/nearley/-/nearley-2.20.1.tgz", - "integrity": "sha512-+Mc8UaAebFzgV+KpI5n7DasuuQCHA89dmwm7JXw3TV43ukfNQ9DnBH3Mdb2g/I4Fdxc26pwimBWvjIw0UAILSQ==", - "license": "MIT", - "dependencies": { - "commander": "^2.19.0", - "moo": "^0.5.0", - "railroad-diagrams": "^1.0.0", - "randexp": "0.4.6" - }, - "bin": { - "nearley-railroad": "bin/nearley-railroad.js", - "nearley-test": "bin/nearley-test.js", - "nearley-unparse": "bin/nearley-unparse.js", - "nearleyc": "bin/nearleyc.js" - }, - "funding": { - "type": "individual", - "url": "https://nearley.js.org/#give-to-nearley" - } - }, - "node_modules/node-fetch": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", - "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", - "license": "MIT", - "dependencies": { - "whatwg-url": "^5.0.0" - }, - "engines": { - "node": "4.x || >=6.0.0" - }, - "peerDependencies": { - "encoding": "^0.1.0" - }, - "peerDependenciesMeta": { - "encoding": { - "optional": true - } - } - }, - "node_modules/node-rsa": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/node-rsa/-/node-rsa-0.4.2.tgz", - "integrity": "sha512-Bvso6Zi9LY4otIZefYrscsUpo2mUpiAVIEmSZV2q41sP8tHZoert3Yu6zv4f/RXJqMNZQKCtnhDugIuCma23YA==", - "license": "MIT", - "dependencies": { - "asn1": "0.2.3" - } - }, - "node_modules/prismarine-auth": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/prismarine-auth/-/prismarine-auth-2.5.0.tgz", - "integrity": "sha512-CRv/pL6d/T+4cdjWS223PXG+ygHbz40Kef04L59SLMT+axNdAQro23eZZhgiIIu6u7rlvJcZYlIY93gFNtKxXA==", - "license": "MIT", - "dependencies": { - "@azure/msal-node": "^2.0.2", - "@xboxreplay/xboxlive-auth": "^3.3.3", - "debug": "^4.3.3", - "jose": "^4.1.4", - "node-fetch": "^2.6.1", - "smart-buffer": "^4.1.0", - "uuid-1345": "^1.0.2" - } - }, - "node_modules/prismarine-chat": { - "version": "1.10.1", - "resolved": "https://registry.npmjs.org/prismarine-chat/-/prismarine-chat-1.10.1.tgz", - "integrity": "sha512-XukYcuueuhDxzEXG7r8BZyt6jOObrPPB4JESCgb+/XenB9nExoSHF8eTQWWj8faKPLqm1dRQaYwFJlNBlJZJUw==", - "license": "MIT", - "dependencies": { - "mojangson": "^2.0.1", - "prismarine-nbt": "^2.0.0", - "prismarine-registry": "^1.4.0" - } - }, - "node_modules/prismarine-nbt": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/prismarine-nbt/-/prismarine-nbt-2.5.0.tgz", - "integrity": "sha512-F0/8UAa9SDDnAGrBYqZc4nG8h2zj5cE2eAJU5xlDR/IsQQ3moVxkOjE3h3nMv6SbvZrvAcgX7waA/nd9LLHYdA==", - "license": "MIT", - "dependencies": { - "protodef": "^1.9.0" - } - }, - "node_modules/prismarine-realms": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/prismarine-realms/-/prismarine-realms-1.3.2.tgz", - "integrity": "sha512-5apl9Ru8veTj5q2OozRc4GZOuSIcs3yY4UEtALiLKHstBe8bRw8vNlaz4Zla3jsQ8yP/ul1b1IJINTRbocuA6g==", - "license": "MIT", - "dependencies": { - "debug": "^4.3.3", - "node-fetch": "^2.6.1" - } - }, - "node_modules/prismarine-registry": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/prismarine-registry/-/prismarine-registry-1.7.0.tgz", - "integrity": "sha512-yyva0FpWI078nNeMhx8ekVza5uUTYhEv+C+ADu3wUQXiG8qhXkvrf0uzsnhTgZL8BLdsi2axgCEiKw9qSKIuxQ==", - "license": "MIT", - "dependencies": { - "minecraft-data": "^3.0.0", - "prismarine-nbt": "^2.0.0" - } - }, - "node_modules/process": { - "version": "0.11.10", - "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", - "integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==", - "license": "MIT", - "engines": { - "node": ">= 0.6.0" - } - }, - "node_modules/protodef": { - "version": "1.15.0", - "resolved": "https://registry.npmjs.org/protodef/-/protodef-1.15.0.tgz", - "integrity": "sha512-bZ2Omw8dT+DACjJHLrBWZlqN4MlT9g9oSpJDdkUAJOStUzgJp+Zn42FJfPUdwutUxjaxA0PftN0PDlNa2XbneA==", - "license": "MIT", - "dependencies": { - "lodash.get": "^4.4.2", - "lodash.reduce": "^4.6.0", - "protodef-validator": "^1.3.0", - "readable-stream": "^3.0.3" - }, - "engines": { - "node": ">=14" - } - }, - "node_modules/protodef-validator": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/protodef-validator/-/protodef-validator-1.3.1.tgz", - "integrity": "sha512-lZ5FWKZYR9xOjpMw1+EfZRfCjzNRQWPq+Dk+jki47Sikl2EeWEPnTfnJERwnU/EwFq6us+0zqHHzSsmLeYX+Lg==", - "license": "MIT", - "dependencies": { - "ajv": "^6.5.4" - }, - "bin": { - "protodef-validator": "cli.js" - } - }, - "node_modules/protodef/node_modules/readable-stream": { - "version": "3.6.2", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", - "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", - "license": "MIT", - "dependencies": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/punycode": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", - "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", - "license": "MIT", - "engines": { - "node": ">=6" - } - }, - "node_modules/railroad-diagrams": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/railroad-diagrams/-/railroad-diagrams-1.0.0.tgz", - "integrity": "sha512-cz93DjNeLY0idrCNOH6PviZGRN9GJhsdm9hpn1YCS879fj4W+x5IFJhhkRZcwVgMmFF7R82UA/7Oh+R8lLZg6A==", - "license": "CC0-1.0" - }, - "node_modules/randexp": { - "version": "0.4.6", - "resolved": "https://registry.npmjs.org/randexp/-/randexp-0.4.6.tgz", - "integrity": "sha512-80WNmd9DA0tmZrw9qQa62GPPWfuXJknrmVmLcxvq4uZBdYqb1wYoKTmnlGUchvVWe0XiLupYkBoXVOxz3C8DYQ==", - "license": "MIT", - "dependencies": { - "discontinuous-range": "1.0.0", - "ret": "~0.1.10" - }, - "engines": { - "node": ">=0.12" - } - }, - "node_modules/readable-stream": { - "version": "4.5.2", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-4.5.2.tgz", - "integrity": "sha512-yjavECdqeZ3GLXNgRXgeQEdz9fvDDkNKyHnbHRFtOr7/LcfgBcmct7t/ET+HaCTqfh06OzoAxrkN/IfjJBVe+g==", - "license": "MIT", - "dependencies": { - "abort-controller": "^3.0.0", - "buffer": "^6.0.3", - "events": "^3.3.0", - "process": "^0.11.10", - "string_decoder": "^1.3.0" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - } - }, - "node_modules/ret": { - "version": "0.1.15", - "resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz", - "integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==", - "license": "MIT", - "engines": { - "node": ">=0.12" - } - }, - "node_modules/safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "license": "MIT" - }, - "node_modules/semver": { - "version": "7.6.3", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", - "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", - "license": "ISC", - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/smart-buffer": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz", - "integrity": "sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg==", - "license": "MIT", - "engines": { - "node": ">= 6.0.0", - "npm": ">= 3.0.0" - } - }, - "node_modules/string_decoder": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", - "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", - "license": "MIT", - "dependencies": { - "safe-buffer": "~5.2.0" - } - }, - "node_modules/string_decoder/node_modules/safe-buffer": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", - "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "license": "MIT" - }, - "node_modules/tr46": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", - "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", - "license": "MIT" - }, - "node_modules/undici-types": { - "version": "6.11.1", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.11.1.tgz", - "integrity": "sha512-mIDEX2ek50x0OlRgxryxsenE5XaQD4on5U2inY7RApK3SOJpofyw7uW2AyfMKkhAxXIceo2DeWGVGwyvng1GNQ==", - "license": "MIT" - }, - "node_modules/uri-js": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", - "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", - "license": "BSD-2-Clause", - "dependencies": { - "punycode": "^2.1.0" - } - }, - "node_modules/util-deprecate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", - "license": "MIT" - }, - "node_modules/uuid": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", - "license": "MIT", - "bin": { - "uuid": "dist/bin/uuid" - } - }, - "node_modules/uuid-1345": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/uuid-1345/-/uuid-1345-1.0.2.tgz", - "integrity": "sha512-bA5zYZui+3nwAc0s3VdGQGBfbVsJLVX7Np7ch2aqcEWFi5lsAEcmO3+lx3djM1npgpZI8KY2FITZ2uYTnYUYyw==", - "license": "MIT", - "dependencies": { - "macaddress": "^0.5.1" - } - }, - "node_modules/webidl-conversions": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", - "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", - "license": "BSD-2-Clause" - }, - "node_modules/whatwg-url": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", - "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", - "license": "MIT", - "dependencies": { - "tr46": "~0.0.3", - "webidl-conversions": "^3.0.0" - } - }, - "node_modules/yggdrasil": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/yggdrasil/-/yggdrasil-1.7.0.tgz", - "integrity": "sha512-QBIo5fiNd7688G3FqXXYGr36uyrYzczlNuzpWFy2zL3+R+3KT2lF+wFxm51synfA3l3z6IBiGOc1/EVXWCYY1Q==", - "license": "MIT", - "dependencies": { - "node-fetch": "^2.6.1", - "uuid": "^8.2.0" - } - } - } -} diff --git a/package.json b/package.json deleted file mode 100755 index fb310c1..0000000 --- a/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "dependencies": { - "minecraft-protocol": "^1.45.0", - "prismarine-chat": "^1.10.0" - }, - "name": "botv10", - "version": "10.0.0", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "", - "license": "UNLICENSED", - "description": "" -} diff --git a/plugins/!chat.js b/plugins/!chat.js deleted file mode 100755 index 00423d8..0000000 --- a/plugins/!chat.js +++ /dev/null @@ -1,98 +0,0 @@ -const console2 = require('./console.js') -const parse = require('../util/chatparse.js') -const parse1204 = require('../util/chatparse_1204.js') -const messageTypes = [ - '', - 'chat.type.emote', - 'commands.message.display.incoming', - '', - '', - 'chat.type.announcement', - '', - '' -] -module.exports = { - load: (b) => { - b._client.on('profileless_chat', (data) => { - if (data.type === 4) { - const json = parse1204(data.message) - const parsed = parse(json)[1] - const split = parsed.split(': ') - const chatName = split.splice(0, 1)[0] - const username = b.findRealName(chatName) - const uuid = b.findUUID(username) - b.emit('chat', { json, type: 'profileless', uuid, message: split.join(': '), username }) - } else { - b.emit('chat', { - json: { - translate: messageTypes[data.type], - color: data.type === 2 ? 'gray' : 'reset', - with: [ - parse1204(data.name), - parse1204(data.message) - ] - }, - type: 'profileless', - uuid: '00000000-0000-0000-0000-000000000000', - message: parse(parse1204(data.message))[1], - username: parse(parse1204(data.name))[1] - }) - } - }) - - b._client.on('player_chat', (data) => { - if (data.type === 4) { - b.emit('chat', { json: parse1204(data.unsignedChatContent), type: 'player', uuid: data.senderUuid, message: data.plainMessage, username: parse(parse1204(data.networkName))[1] }) - } else { - b.emit('chat', { - json: { - translate: messageTypes[data.type], - color: data.type === 2 ? 'gray' : 'reset', - with: [ - parse1204(data.networkName), - data.plainMessage - ] - }, - type: 'player', - uuid: data.senderUuid, - message: parse(data.plainMessage)[1], - username: parse(parse1204(data.networkName))[1] - }) - } - }) - b._client.on('system_chat', (data) => { - const json = parse1204(data.content) - const parsed = parse(json)[1] - const split = parsed.split(': ') - const chatName = split.splice(0, 1)[0] - const username = b.findRealName(chatName) - const uuid = b.findUUID(username) - b.emit('chat', { json, type: 'system', uuid, message: split.join(': '), username }) - }) - b._client.on('chat', (data) => { // Legacy chat - const json = parse1204(data.message) - const parsed = parse(json)[1] - const split = parsed.split(': ') - const chatName = split.splice(0, 1)[0] - const username = b.findRealName(chatName) - const uuid = b.findUUID(username) - b.emit('chat', { json, type: 'legacy', uuid: data.uuid ? data.uuid : uuid, message: split.join(': '), username }) - }) - b.on('chat', (data) => { - const msg = parse(data.json) - if (msg[1].endsWith('\n\n\n\n\nThe chat has been cleared')) return - if (msg[1].startsWith('Command set: ')) return - b.emit('plainchat', msg[1]) - console2.write(`[${b.id}] [${data.type}] ` + msg[0]) - const fullCommand = data.message - - for (const i in b.prefix) { - if (fullCommand.startsWith(b.prefix[i])) { - const command = fullCommand.slice(b.prefix[i].length) - b.runCommand(data.username, data.uuid, command, b.prefix[i]) - } - } - }) - }, - parse -} diff --git a/plugins/cloop.js b/plugins/cloop.js deleted file mode 100755 index f67fb46..0000000 --- a/plugins/cloop.js +++ /dev/null @@ -1,23 +0,0 @@ -module.exports = { - load: (b) => { - b.cloops = [] - b.addCloop = function (command, rate) { - b.cloops.push({ - command, - rate, - interval: setInterval(() => { b.ccq.push(command) }, rate) - }) - b.ccq.push(command) - } - b.removeCloop = function (index) { - clearInterval(b.cloops[index].interval) - b.cloops.splice(index, 1) - } - b.clearCloops = function () { - for (const i in b.cloops) { - clearInterval(b.cloops[i].interval) - } - b.cloops = [] - } - } -} diff --git a/plugins/command.js b/plugins/command.js deleted file mode 100755 index e8b07fb..0000000 --- a/plugins/command.js +++ /dev/null @@ -1,181 +0,0 @@ -const fs = require('fs') -const Command = require('../util/Command.js') -const hashcheck = require('../util/hashcheck.js') -const settings = require('../settings.json') -const {getMessage} = require('../util/lang.js') -const cmds = Object.create(null) -const bpl = fs.readdirSync('./plugins/commands') -for (const i in bpl) { // Built-in loadCMD - if (!bpl[i].endsWith('.js')) { - continue - } - try { - const commandName = bpl[i].split('.js')[0] - cmds[commandName] = require(`./commands/${bpl[i]}`) - if (cmds[commandName].level === undefined) { - cmds[commandName].level = 0 - } - console.log('Loaded command ' + commandName) - if (cmds[commandName].aliases) { - for (const j in cmds[commandName].aliases) { - cmds[cmds[commandName].aliases[j]] = { - execute: cmds[commandName].execute, - desc: 'Alias to ' + commandName, - usage: cmds[commandName].usage, - level: cmds[commandName].level, - hidden: true, - consoleIndex: cmds[commandName].consoleIndex - } - } - } - } catch (e) { console.log(e) } -} - -const sortHelp = function sortHelp (c1, c2) { - const level1 = cmds[c1.with[0]].level ? cmds[c1.with[0]].level : 0 - const level2 = cmds[c2.with[0]].level ? cmds[c2.with[0]].level : 0 - return level1 - level2 -} -module.exports = { - load: (b) => { - b.prefix = settings.prefix - b.lastCmd = 0 - b.runCommand = (name, uuid, text, prefix) => { - if (uuid === '00000000-0000-0000-0000-000000000000') return - if (Date.now() - b.lastCmd <= 1000) return - b.lastCmd = Date.now() - const cmd = text.split(' ') - const lang = settings.defaultLang - const verify = hashcheck(cmd) - if (verify > 0) { - text = cmd.slice(0, cmd.length - 1).join(' ') - } - if (cmds[cmd[0].toLowerCase()]) { - const command = cmds[cmd[0].toLowerCase()] - if (command.level !== undefined && command.level > verify) { - b.tellraw(uuid, { - text: getMessage(lang, 'command.disallowed.perms') - }) - b.tellraw(uuid, { - text: getMessage(lang, 'command.disallowed.perms.yourLevel', [verify + '']) - }) - b.tellraw(uuid, { - text: getMessage(lang, 'command.disallowed.perms.cmdLevel', [command.level + '']) - }) - return - } - try { - cmds[cmd[0].toLowerCase()].execute(new Command(uuid, name, 'nick N/A', text, prefix, b, verify)) - } catch (e) { - console.log(e) - b.tellraw(uuid, { - text: getMessage(lang, 'command.error'), - color: 'red', - hoverEvent: { - action: 'show_text', - value: { - text: e.stack - } - } - }) - } - } - } - b.printHelp = (uuid, prefix, lang) => { - const commandList = [] - for (const i in cmds) { - if (cmds[i].hidden) continue - let cmdColor - switch (cmds[i].level) { - case 0: - cmdColor = 'green' - break - case 1: - cmdColor = 'red' - break - case 2: - cmdColor = 'dark_red' - break - case 3: - cmdColor = 'dark_gray' - break - default: - cmdColor = 'gray' - } - commandList.push( - { - translate: '%s ', - color: cmdColor, - with: [ - i - ] - } - ) - } - b.tellraw(uuid, { - translate: '%s %s', - with: [ - getMessage(lang, 'command.help.cmdList'), - commandList.sort(sortHelp) - ] - }) - } - b.printCmdHelp = (uuid, cmd, lang, color) => { - if (!cmds[cmd]) { - b.tellraw(uuid, { text: getMessage(lang, 'command.help.noCommand') }) - return - } - let usage = getMessage(lang, `command.${cmd}.usage`).split('||') - let desc = getMessage(lang, `command.${cmd}.desc`) - if (cmds[cmd].usage) { - usage = cmds[cmd].usage.split('||') - } - if (cmds[cmd].desc) { - desc = cmds[cmd].desc - } - // b.tellraw(uuid,{"text":getMessage(lang,"command.help.commandInfo",[cmd,usage,desc])}); - for (const i in usage) { - b.tellraw(uuid, { - translate: getMessage(lang, 'command.help.commandUsage'), - color: color.secondary, - with: [ - { - text: cmd, - color: color.primary - }, - { - text: usage[i], - color: color.primary - } - ] - }) - } - b.tellraw(uuid, { - translate: getMessage(lang, 'command.help.commandDesc'), - color: color.secondary, - with: [ - { - text: desc, - color: color.primary - } - ] - }) - const permsN = getMessage(lang, 'command.help.permsNormal') - const permsT = getMessage(lang, 'command.help.permsTrusted') - const permsO = getMessage(lang, 'command.help.permsOwner') - const permsC = getMessage(lang, 'command.help.permsConsole') - const rPerms = cmds[cmd].level ? cmds[cmd].level : 0 - b.tellraw(uuid, { - translate: getMessage(lang, 'command.help.commandPerms'), - color: color.secondary, - with: [ - { - text: [permsN, permsT, permsO, permsC][rPerms], - color: color.primary - } - ] - }) - } - }, - cmds -} diff --git a/plugins/commandblock.js b/plugins/commandblock.js deleted file mode 100755 index b489fa7..0000000 --- a/plugins/commandblock.js +++ /dev/null @@ -1,103 +0,0 @@ -const uuidToInt = require('../util/uuidtoint.js') -module.exports = { - cs: 4, - cs_v: 6, - load: function (b) { - b.interval.commandFill = setInterval(() => { if (b.sc_tasks.cc) b.sc_tasks.cc.failed = 1 }, 60000) - b.ccq = [] - b.blocknoX = 0 - b.blocknoZ = 0 - b.ccStarted = 0 - b.blocknoY = 0 - b.pos = { x: 0, y: 0, z: 0, correct: 0 } - - b.advanceccq = function () { - if (b.ccq[0] && b.ccq[0].length !== 0) { - b._client.write('update_command_block', { - command: b.ccq[0], - location: { - x: b.commandPos.x1 + b.blocknoX, - y: b.commandPos.y1 + b.blocknoY, - z: b.commandPos.z1 + b.blocknoZ - }, - mode: 2, - flags: 1 - }) - b._client.write('update_command_block', { - command: b.ccq[0], - location: { - x: b.commandPos.x1 + b.blocknoX, - y: b.commandPos.y1 + b.blocknoY, - z: b.commandPos.z1 + b.blocknoZ - }, - mode: 2, - flags: 5 - }) - b.blocknoX++ - if (b.blocknoX === module.exports.cs) { - b.blocknoY++ - b.blocknoX = 0 - if (b.blocknoY === module.exports.cs_v) { - b.blocknoZ++ - b.blocknoY = 0 - if (b.blocknoZ === module.exports.cs) { - b.blocknoZ = 0 - } - } - } - } - b.ccq.splice(0, 1) - } - b._client.on('login', () => { - b.add_sc_task('cc', '/fill ~ 55 ~ ~3 60 ~3 command_block{CustomName:\'{"translate":"%s %s","with":[{"translate":"entity.minecraft.ender_dragon"},{"translate":"language.region"}],"color":"#FFAAEE"}\'}', true, true) - b.add_sc_task('cc_size', '/gamerule commandModificationBlockLimit 32767', true, false, true) - }) - b.on('ccstart', () => { - setTimeout(() => { b.interval.ccqi = setInterval(b.advanceccq, 3) }, 1000) // 1 Second and 3 Milliseconds - b.ccStarted = true - }) - b.on('chat', (data) => { - if (data.json.translate === 'commands.fill.failed' || (data.json.extra && data.json.extra[0] && data.json.extra[0].translate === 'commands.fill.failed') || - data.json.translate === 'commands.fill.success' || (data.json.extra && data.json.extra[0] && data.json.extra[0].translate === 'commands.fill.success')) { - if (!b.ccStarted) { - b.emit('ccstart') - } - b.sc_tasks.cc.failed = 0 - b.sc_tasks.cc_size.failed = 0 - } else if (data.json.translate === 'commands.fill.toobig' || (data.json.extra && data.json.extra[0] && data.json.extra[0].translate === 'commands.fill.toobig')) { - b.sc_tasks.cc_size.failed = 1 - } - }) - b._client.on('position', function (a) { - if (!b.ccStarted) { - b.original_pos = { x: a.x, y: a.y, z: a.z } - b.pos = { x: a.x, y: a.y, z: a.z, correct: 1 } - } else { - b.pos = { x: a.x, y: a.y, z: a.z, correct: 1 } - if (a.x !== b.original_pos.x || a.z !== b.original_pos.z) { - b.original_pos = { x: a.x, y: a.y, z: a.z } - b.pos.correct = 0 - b.sc_tasks.cc.failed = 1 - } - } - - b.commandPos = { - x1: Math.floor(a.x), - z1: Math.floor(a.z), - y1: 55 - } - b._client.write('teleport_confirm', { teleportId: a.teleportId }) - }) - b.tellraw = (uuid, message) => { - let finalname = '' - if (uuid === '@a') { - finalname = '@a' - } else if (uuid.match(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/)) { - finalname = `@a[nbt={UUID:[I;${uuidToInt(uuid)}]}]` - } else { - finalname = uuid - } - b.ccq.push(`/minecraft:tellraw ${finalname} ${JSON.stringify(message)}`) - } - } -} diff --git a/plugins/commands/about.js b/plugins/commands/about.js deleted file mode 100644 index 80ccd0e..0000000 --- a/plugins/commands/about.js +++ /dev/null @@ -1,100 +0,0 @@ -const version = require('../../version.json') -const {getMessage} = require('../../util/lang.js') -const cp = require('child_process') -module.exports = { - execute: function (c) { - c.reply({ - translate: getMessage(c.lang, 'command.about.author'), - color: c.colors.secondary, - with: [ - { - text: version.botName, - color: c.colors.primary - } - ] - }) - c.reply({ text: '' }) - const botVersion = version.botVersion - let gitCommit - let gitBranch - try { - gitCommit = cp.execSync('git rev-parse --short HEAD').toString('UTF-8').split('\n')[0] - gitBranch = cp.execSync('git rev-parse --abbrev-ref HEAD').toString('UTF-8').split('\n')[0] - } catch (e) { - gitCommit = false - gitBranch = false - } - if (gitCommit) { - c.reply({ - translate: getMessage(c.lang, 'command.about.version'), - color: c.colors.secondary, - with: [ - [ - { - text: botVersion, - color: c.colors.primary - }, - { - translate: ' (%s - %s)', - color: c.colors.secondary, - with: [ - { - text: gitCommit, - color: c.colors.primary - }, - { - text: gitBranch, - color: c.colors.primary - } - ] - } - ] - ] - }) - } else { - c.reply({ - translate: getMessage(c.lang, 'command.about.version'), - color: c.colors.secondary, - with: [ - { - text: botVersion, - color: c.colors.primary - } - ] - }) - } - c.reply({ text: '' }) - c.reply({ - translate: getMessage(c.lang, 'command.about.sourceCode'), - color: c.colors.secondary, - with: [ - { - text: version.sourceURL, - color: c.colors.primary, - clickEvent: { - action: 'open_url', - value: version.sourceURL - } - } - ] - }) - c.reply({ text: '' }) - c.reply({ - translate: getMessage(c.lang, 'command.about.serverinfo'), - color: c.colors.secondary, - with: [ - { - translate: '"%s"', - color: c.colors.secondary, - with: [ - { - text: 'serverinfo', - color: c.colors.primary - } - ] - } - ] - }) - }, - aliases: ['info'] -} diff --git a/plugins/commands/cb.js b/plugins/commands/cb.js deleted file mode 100644 index c089a84..0000000 --- a/plugins/commands/cb.js +++ /dev/null @@ -1,7 +0,0 @@ -module.exports = { - execute: (c) => { - c.bot.ccq.push(c.args.join(' ')) - }, - consoleIndex: true, - aliases: ['commandblock', 'cmdblock'] -} diff --git a/plugins/commands/cloop.js b/plugins/commands/cloop.js deleted file mode 100644 index 3d93eeb..0000000 --- a/plugins/commands/cloop.js +++ /dev/null @@ -1,90 +0,0 @@ -const {getMessage} = require('../../util/lang.js') -module.exports = { - execute: (c) => { - const subcmd = c.args.splice(0, 1)[0] - switch (subcmd) { - case 'add': { - const rate = +(c.args.splice(0, 1)[0]) - const command = c.args.join(' ') - if (rate < 20) { - c.reply({ - text: getMessage(c.lang, 'command.cloop.error.tooShort') - }) - } - c.bot.addCloop(command, rate) - c.reply({ - translate: getMessage(c.lang, 'command.cloop.success.add'), - color: c.colors.secondary, - with: [ - { - text: command, - color: c.colors.primary - }, - { - text: rate + '', - color: c.colors.primary - } - ] - }) - break - } - case 'remove': { - const index = +c.args[0] - c.bot.removeCloop(c.args[0]) - c.reply({ - translate: getMessage(c.lang, 'command.cloop.success.remove'), - color: c.colors.secondary, - with: [ - { - text: index + '', - color: c.colors.primary - } - ] - }) - break - } - case 'list': - for (const i in c.bot.cloops) { - c.reply({ - translate: getMessage(c.lang, 'command.cloop.list'), - color: c.colors.secondary, - with: [ - { - text: i, - color: c.colors.primary - }, - { - text: c.bot.cloops[i].command, - color: c.colors.primary - }, - { - text: c.bot.cloops[i].rate + '', - color: c.colors.primary - } - ] - }) - } - break - case 'clear': - c.bot.clearCloops() - c.reply({ - text: getMessage(c.lang, 'command.cloop.success.clear'), - color: c.colors.secondary - }) - break - default: - c.reply({ - translate: getMessage(c.lang, 'command.cloop.error.subcommand'), - color: c.colors.secondary, - with: [ - { - text: `${c.prefix}help cloop`, - color: c.colors.primary - } - ] - }) - } - }, - consoleIndex: true, - level: 1 -} diff --git a/plugins/commands/eval.js b/plugins/commands/eval.js deleted file mode 100644 index 8ed1fa9..0000000 --- a/plugins/commands/eval.js +++ /dev/null @@ -1,11 +0,0 @@ -const index = require('../../index.js') // Not used in the code, but may be used by users of the command -module.exports = { - execute: (c) => { - try { - console.log(eval(c.args.join(' '))) - } catch (e) { - console.error(e) - } - }, - level: 3 -} diff --git a/plugins/commands/help.js b/plugins/commands/help.js deleted file mode 100644 index dc48e31..0000000 --- a/plugins/commands/help.js +++ /dev/null @@ -1,12 +0,0 @@ -module.exports = { - execute: (c) => { - if (c.args.length > 0) { - c.bot.printCmdHelp(c.uuid, c.args[0], c.lang, c.colors) - } else { - c.bot.printHelp(c.uuid, c.prefix, c.lang, c.colors) - } - }, - aliases: [ - 'heko' // Parker2991 request - ] -} diff --git a/plugins/commands/logoff.js b/plugins/commands/logoff.js deleted file mode 100644 index e05cae0..0000000 --- a/plugins/commands/logoff.js +++ /dev/null @@ -1,7 +0,0 @@ -module.exports = { - execute: (c) => { - c.bot._client.end() - }, - consoleIndex: true, - level: 2 -} diff --git a/plugins/commands/netmsg.js b/plugins/commands/netmsg.js deleted file mode 100644 index b3acbac..0000000 --- a/plugins/commands/netmsg.js +++ /dev/null @@ -1,35 +0,0 @@ -const { bot } = require('../../index.js') -module.exports = { - execute: (c) => { - const json = { - translate: '[%s] %s: %s', - with: [ - { - translate: '%s:%s', - with: [ - { - text: c.host, - color: c.colors.primary - }, - { - text: c.port + '', - color: c.colors.primary - } - ], - color: c.colors.secondary - }, - { - text: c.username, - color: c.colors.primary - }, - { - text: c.args.join(' ') - } - ], - color: 'white' - } - for (const i in bot) { - bot[i].tellraw('@a', json) - } - } -} diff --git a/plugins/commands/refill.js b/plugins/commands/refill.js deleted file mode 100644 index b626b05..0000000 --- a/plugins/commands/refill.js +++ /dev/null @@ -1,7 +0,0 @@ -module.exports = { - execute: (c) => { - c.bot.chat('/fill ~ 55 ~ ~3 60 ~3 command_block{CustomName:\'{"translate":"%s %s","with":[{"translate":"entity.minecraft.ender_dragon"},{"translate":"language.region"}],"color":"#FFAAEE"}\'}') - }, - consoleIndex: true, - aliases: ['refillcore', 'rc'] -} diff --git a/plugins/commands/restart.js b/plugins/commands/restart.js deleted file mode 100644 index 5f64d6d..0000000 --- a/plugins/commands/restart.js +++ /dev/null @@ -1,7 +0,0 @@ -module.exports = { - execute: (c) => { - process.exit(1) - }, - aliases: ['reboot'], - level: 2 -} diff --git a/plugins/commands/say.js b/plugins/commands/say.js deleted file mode 100644 index e6bc74f..0000000 --- a/plugins/commands/say.js +++ /dev/null @@ -1,8 +0,0 @@ -module.exports = { - execute: (c) => { - if (c.args[0].startsWith('/') && c.verify < 1) return - c.bot.chat(c.args.join(' ')) - }, - consoleIndex: true, - aliases: ['echo'] -} diff --git a/plugins/commands/serverinfo.js b/plugins/commands/serverinfo.js deleted file mode 100755 index 10c5899..0000000 --- a/plugins/commands/serverinfo.js +++ /dev/null @@ -1,97 +0,0 @@ -const os = require('os') -const cp = require('child_process') -const version = require('../../version.json') -const {getMessage,formatTime} = require('../../util/lang.js') -const fs = require('fs') -const gr = function (l, text, value, color) { - if (!color) color = 'white' - return { - translate: '%s: %s', - color: color.primary, - with: [ - { - text, - color: color.secondary - }, - { - text: value, - color: color.primary - } - ], - hoverEvent: { - action: 'show_text', - contents: { - text: getMessage(l, 'copyText') - } - }, - clickEvent: { - action: 'copy_to_clipboard', - value - } - } -} - -const os2 = function (o2, l) { - switch (o2) { - case 'win32': - return `${os.version()} (${os.release})` - case 'android': - return getMessage(l, 'command.serverinfo.os.android') - case 'linux': - return getMessage(l, 'command.serverinfo.os.linux', [os.release()]) - default: - return o2 - } -} -module.exports = { - execute: function (c) { - c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.os'), os2(process.platform, c.lang), c.colors)) - if (os.cpus()[0]) c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.processor'), os.cpus()[0].model, c.colors)) - c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.arch'), os.machine(), c.colors)) - c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.osUsername'), `${os.userInfo().username} (${os.userInfo().uid})`, c.colors)) - c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.hostName'), os.hostname(), c.colors)) - c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.workingDir'), process.cwd(), c.colors)) - c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.runTime'), formatTime(process.uptime() * 1000, c.lang), c.colors)) - c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.upTime'), formatTime(os.uptime() * 1000, c.lang), c.colors)) - c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.nodeVersion'), process.version, c.colors)) - if (process.platform === 'linux' || process.platform === 'freebsd') { - try { - const osrelease = fs.readFileSync('/etc/os-release').toString('UTF-8').split('\n') - const osrelease2 = {} - for (const i in osrelease) { - if (!osrelease[i].includes('=')) continue - let osrvalue = osrelease[i].split('=')[1] - if (osrvalue.startsWith('"') && osrvalue.endsWith('"')) { osrvalue = osrvalue.slice(1, osrvalue.length - 1) }; - osrelease2[osrelease[i].split('=')[0]] = osrvalue - } - - if (osrelease2.PRETTY_NAME) { - c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.osRelease'), osrelease2.PRETTY_NAME, c.colors)) - } - } catch (e) { - c.reply({ text: getMessage(c.lang, 'command.serverinfo.osRelease.missing') }) - } - } else if (process.platform === 'android') { - const androidVersion = cp.execSync('getprop ro.build.version.release').toString('UTF-8').split('\n')[0] - c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.os.android.version'), androidVersion, c.colors)) - const dModel = cp.execSync('getprop ro.product.model').toString('UTF-8').split('\n')[0] - const dBrand = cp.execSync('getprop ro.product.brand').toString('UTF-8').split('\n')[0] - c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.os.android.model'), dBrand + ' ' + dModel, c.colors)) - } - c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.botName'), version.botName, c.colors)) - let botVersion = version.botVersion - let gitCommit - let gitBranch - try { - gitCommit = cp.execSync('git rev-parse --short HEAD').toString('UTF-8').split('\n')[0] - gitBranch = cp.execSync('git rev-parse --abbrev-ref HEAD').toString('UTF-8').split('\n')[0] - } catch (e) { - gitCommit = false - gitBranch = false - } - if (gitCommit) { - botVersion += ` (${gitCommit} - ${gitBranch})` - } - c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.botVer'), botVersion, c.colors)) - } -} diff --git a/plugins/commands/stop.js b/plugins/commands/stop.js deleted file mode 100644 index 441c345..0000000 --- a/plugins/commands/stop.js +++ /dev/null @@ -1,7 +0,0 @@ -module.exports = { - execute: (c) => { - process.exit(0) - }, - aliases: ['exit'], - level: 2 -} diff --git a/plugins/commands/template.js b/plugins/commands/template.js deleted file mode 100644 index 375f1f7..0000000 --- a/plugins/commands/template.js +++ /dev/null @@ -1,42 +0,0 @@ -module.exports = { - execute: (c) => { - // Blank template - /* - c.send(text, user?): Send text to all ("/tellraw @a") - c.reply(text): Send text to command sender - c.uuid: Unique identifier (UUID for Minecraft, Discord ID for Discord) - c.username: Username of sender - c.nickname: Nickname of sender when applicable - c.command: Command string - c.args: Arguments of command (above without the first section, and split at every space) - c.prefix: Prefix being used to send the command (when applicable) - c.bot: Bot that received the command. Will be different type based on where it was received - c.type: Type of bot receiving the command ("minecraft", "console", "discord") - c.lang: The language the player has selected, or the default if none - c.colors: The color palette the player has selected, or the default if none - */ - }, - /* - Command description and usage have been moved to the message files. The format for a basic command is: - "command.(name).usage": " [optional]", - "command.(name).desc": "Insert description here...", - replacing (name) with the name of the new command. - Some more complex commands may have messages of their own, which should be placed there too. - First, insert the following line near the top of the command's file (not in the execute function): - const {getMessage} = require('../../util/lang.js') - Then, to get a specific message: - getMessage(c.lang,"(message key)",[(arguments, in an array (optional))]) - For example, this will show the "about" command's redirection to "serverinfo": - getMessage(c.lang,"command.about.serverinfo") - The with array can be used to add information to a message. For example: - getMessage(lang,"command.help.commandInfo",["cmd","usage","desc"]) - shows the "help" command's formatting for command information, with some strings as items. - That message would render as (in en-US): - cmdusage - desc - Extra information is inserted wherever there is a "%s" or a "%n$s", with n being the index of the item in the array. - */ - hidden: true, // To show the command on the help command list, remove this line (optional) - consoleIndex: true, // When run from console, the second argument will be a bot ID (optional) - aliases: ['example', 'testing'], // Other command names that will work the same (optional) - level: 0 // Permission level required to run this command (optional) -} diff --git a/plugins/commands/tpr.js b/plugins/commands/tpr.js deleted file mode 100755 index ffd7bf0..0000000 --- a/plugins/commands/tpr.js +++ /dev/null @@ -1,43 +0,0 @@ -const {getMessage} = require('../../util/lang.js') -module.exports = { - execute: function (c) { - let uuid - if (c.type === 'console') { - uuid = c.bot._client.uuid - } else { - uuid = c.uuid - } - const originalPos = { - x: Math.floor(Math.random() * 2000000) - 1000000, - y: 100, - z: Math.floor(Math.random() * 2000000) - 1000000 - } - c.reply( - { - translate: getMessage(c.lang, 'command.tpr.success'), - color: c.colors.secondary, - with: [ - { - text: c.username, - color: c.colors.primary - }, - { - text: originalPos.x.toString(), - color: c.colors.primary - }, - { - text: originalPos.y.toString(), - color: c.colors.primary - }, - { - text: originalPos.z.toString(), - color: c.colors.primary - } - ] - } - ) - c.bot.ccq.push(`/essentials:tp ${uuid} ${originalPos.x}.0 ${originalPos.y} ${originalPos.z}.0`) - }, - consoleIndex: true, - aliases: ['rtp'] -} diff --git a/plugins/commands/verify.js b/plugins/commands/verify.js deleted file mode 100644 index f1941a2..0000000 --- a/plugins/commands/verify.js +++ /dev/null @@ -1,11 +0,0 @@ -module.exports = { - execute: (c) => { - c.reply({ - text: c.verify + '' - }) - c.reply({ - text: c.command - }) - }, - level: 1 -} diff --git a/plugins/console.js b/plugins/console.js deleted file mode 100644 index 367871c..0000000 --- a/plugins/console.js +++ /dev/null @@ -1,50 +0,0 @@ -const readln = require('readline') -const index = require('../index.js') -const ConsoleCommand = require('../util/ConsoleCommand.js') -const newercommands = require('./command.js').cmds -const rl = readln.createInterface({ - input: process.stdin, - output: process.stdout, - prompt: '\x1b[0m\x1b[38;5;15m> ' -}) -rl.on('line', (l) => { - try { - if (newercommands[l.split(' ')[0].toLowerCase()]) { - if (newercommands[l.split(' ')[0].toLowerCase()].consoleIndex) { - const tmpcmd = l.split(' ') - const index2 = tmpcmd.splice(1, 1)[0] - if (index2 === '*') { - for (let i = 0; i < index.bot.length; i++) { - const cmd = new ConsoleCommand(tmpcmd.join(' '), i) - newercommands[l.split(' ')[0].toLowerCase()].execute(cmd) - } - } else { - const cmd = new ConsoleCommand(tmpcmd.join(' '), +index2) - newercommands[l.split(' ')[0].toLowerCase()].execute(cmd) - } - } else { - const cmd = new ConsoleCommand(l, -2) - newercommands[l.split(' ')[0].toLowerCase()].execute(cmd) - } - } - } catch (e) { - console.log(e) - } - rl.prompt(false) -}) -rl.prompt() -function consoleWrite (text) { - readln.cursorTo(process.stdout, 0) - readln.clearLine(process.stdout, 0) - process.stdout.write(text + '\n') - rl.prompt(true) -} -module.exports = { - load: (b) => { - b.info = (msg) => { - consoleWrite(`[${b.id}] [info] ${msg}`) - } - }, - rl, - write: consoleWrite -} diff --git a/plugins/cq.js b/plugins/cq.js deleted file mode 100755 index 4cdbae5..0000000 --- a/plugins/cq.js +++ /dev/null @@ -1,19 +0,0 @@ -module.exports = { - load: (b) => { - b._client.on('login', () => { - b.interval.chatQueue = setInterval(() => { - if (b.chatqueue.length !== 0) { - b._client.chat(b.chatqueue[0]) - b.chatqueue.splice(0, 1) - } - }, 150) - }) - b.chatqueue = [] - b.chat = function chat (msg) { - if (msg.length === 0) return - msg.match(/.{1,250}/g).forEach(element => { - b.chatqueue.push(element) - }) - } - } -} diff --git a/plugins/player.js b/plugins/player.js deleted file mode 100644 index c18d37b..0000000 --- a/plugins/player.js +++ /dev/null @@ -1,46 +0,0 @@ -const parse = require('../util/chatparse.js') -const parse1204 = require('../util/chatparse_1204.js') -module.exports = { - load: (b) => { - b.players = {} - b._client.on('player_info', (data) => { - const buffer2 = {} - for (const i in data.data) { - let uuid - if (data.data[i].uuid) { - uuid = data.data[i].uuid - } else if (data.data[i].UUID) { - uuid = data.data[i].UUID - } - if (data.data[i].player && data.data[i].player.name !== undefined) { - buffer2[uuid] = { realName: data.data[i].player.name, displayName: parse(parse1204(data.data[i].displayName))[1] } - } else if (data.data[i].name !== undefined) { - buffer2[uuid] = { realName: data.data[i].name, displayName: parse(parse1204(data.data[i].displayName))[1] } - } else if (data.data[i].displayName !== undefined) { - buffer2[uuid] = { displayName: parse(parse1204(data.data[i].displayName))[1] } - } - } - for (const uuid in buffer2) { - if (!b.players[uuid]) b.players[uuid] = { displayName: '', realName: '' } - if (buffer2[uuid].displayName) b.players[uuid].displayName = buffer2[uuid].displayName - if (buffer2[uuid].realName) b.players[uuid].realName = buffer2[uuid].realName - } - }) - b.findUUID = (name) => { - for (const i in b.players) { - if (b.players[i].realName === name) { - return i - } - } - return '00000000-0000-0000-0000-000000000000' - } - b.findRealName = (name) => { - for (const i in b.players) { - if (b.players[i].displayName === name) { - return b.players[i].realName - } - } - return 'Geometrical Dominator' - } - } -} diff --git a/plugins/rejoin.js b/plugins/rejoin.js deleted file mode 100755 index 8c9e56b..0000000 --- a/plugins/rejoin.js +++ /dev/null @@ -1,15 +0,0 @@ -const index = require('../index.js') -module.exports = { - load: (b) => { - b._client.on('end', () => { - b.info('bot ' + b.id + ' disconnected') - for (const i in b.interval) { - clearInterval(b.interval[i]) - } - setTimeout(() => { - b.info('Re-connecting bot ' + b.id) - index.createBot(b.host, b.id) - }, 5000) - }) - } -} diff --git a/plugins/selfcare.js b/plugins/selfcare.js deleted file mode 100755 index c83dad1..0000000 --- a/plugins/selfcare.js +++ /dev/null @@ -1,66 +0,0 @@ -class SCTask { - constructor (failTask, chatCommand, startFailed = false) { - /* - * failed: Whether to run this task - * failTask: Command to run when failed is true - * chatCommand: Whether to run failTask in chat rather than in command block - */ - this.failed = startFailed - this.failTask = failTask - this.chatCommand = chatCommand - } -} -module.exports = { - load: (b) => { - b.sc_tasks = {} - b.interval.sc = setInterval(() => { - for (const i in b.sc_tasks) { - if (b.sc_tasks[i].failed) { - if (b.sc_tasks[i].chatCommand) { - b.chat(b.sc_tasks[i].failTask) - } else { - b.ccq.push(b.sc_tasks[i].failTask) // Does not automatically reset - } - } - } - }, 1000) - b.add_sc_task = (name, failTask, chatCommand, startFailed) => { - b.sc_tasks[name] = new SCTask(failTask, chatCommand, startFailed) - } - - // Selfcare tasks - - // Operator - b.add_sc_task('op', '/op @s[type=player]', true) - b._client.on('login', (p) => { - b.entityId = p.entityId - }) - b._client.on('entity_status', (p) => { - if (p.entityId === b.entityId && p.entityStatus === 24) { - b.sc_tasks.op.failed = 1 - } else if (p.entityId === b.entityId && p.entityStatus === 28) { - b.sc_tasks.op.failed = 0 - } - }) - - // Commandspy - b.add_sc_task('cspy', '/cspy on', true, true) - b.on('plainchat', (msg) => { - if (msg === 'Successfully disabled CommandSpy') { - b.sc_tasks.cspy.failed = 1 - } else if (msg === 'Successfully enabled CommandSpy') { - b.sc_tasks.cspy.failed = 0 - } - }) - - // Gamemode - b.add_sc_task('gamemode', '/minecraft:gamemode creative', true) - b._client.on('game_state_change', (p) => { - if (p.reason === 3 && p.gameMode !== 1) { - b.sc_tasks.gamemode.failed = 1 - } else if (p.reason === 3 && p.gameMode === 1) { - b.sc_tasks.gamemode.failed = 0 - } - }) - } -} diff --git a/plugins/testing.js b/plugins/testing.js deleted file mode 100755 index f886c5e..0000000 --- a/plugins/testing.js +++ /dev/null @@ -1,5 +0,0 @@ -module.exports = { - load: (b) => { - - } -} diff --git a/secret_example.json b/secret_example.json deleted file mode 100644 index 61a3ce8..0000000 --- a/secret_example.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "keyTrusted": "Insert trusted level key here...", - "keyOwner": "Insert owner level key here..." -} diff --git a/settings_example.json b/settings_example.json deleted file mode 100755 index 5a393ab..0000000 --- a/settings_example.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "secret":"C:\\Users\\Username\\Documents\\botvX\\secret.json", - "name": "Minecraft Bot", - "version_mc": "1.20.4", - "defaultLang": "en-US", - "colors": { - "primary": "#FFCCEE", - "secondary": "#FF99DD" - }, - "prefix":[ - "bot:", - "\"" - ], - "servers":[ - { - "host": "kaboom.pw", - "port": 25565, - "options":{ - "name": "kaboom" - } - } - ] -} diff --git a/util/Command.js b/util/Command.js deleted file mode 100644 index fd8e2da..0000000 --- a/util/Command.js +++ /dev/null @@ -1,24 +0,0 @@ -// HOW TO WRITE CLASS JS -const settings = require('../settings.json') -class Command { - constructor (uuid, user, nick, cmd, prefix, bot, verify, lang = settings.defaultLang) { - this.send = (text, uuid) => { bot.tellraw(uuid || '@a', text) } - this.reply = text => bot.tellraw(uuid, text) - this.uuid = uuid - this.username = user - this.nickname = nick - this.command = cmd - this.prefix = prefix - this.bot = bot - this.type = 'minecraft' - this.index = bot.id - this.args = cmd.split(' ').slice(1) - this.verify = verify - this.host = bot.host.host - this.port = bot.host.port - this.lang = lang - this.colors = settings.colors - } -} - -module.exports = Command diff --git a/util/ConsoleCommand.js b/util/ConsoleCommand.js deleted file mode 100644 index a724f0e..0000000 --- a/util/ConsoleCommand.js +++ /dev/null @@ -1,60 +0,0 @@ -// HOW TO WRITE CLASS JS -const index = require('../index.js') -const { cmds } = require('../plugins/command.js') -const parse = require('../util/chatparse.js') -const settings = require('../settings.json') -const {getMessage} = require('../util/lang.js') -const lang = settings.defaultLang -class ConsoleCommand { - constructor (cmd, index2) { - this.send = () => {} // not needed for console - this.reply = text => process.stdout.write(parse(text)[0] + '\n') - this.uuid = 'dde5a2a6-ebdd-4bbb-8eac-f75b10c10446_console' // hard-coded because uuid does not exist at console - this.username = 'Owner' - this.nickname = 'Console' - this.command = cmd - this.prefix = '' // prefix does not exist at console - this.bot = index2 >= 0 - ? index.bot[index2] - : { - printHelp: () => { - const helpCmds = [] - for (const i in cmds) { - // if(cmds[i].hidden) continue; - helpCmds.push(i) - } - console.log(getMessage(lang, 'command.help.cmdList'), helpCmds.join(' ')) - }, - printCmdHelp: (uuid, cmd) => { - let usage = getMessage(lang, `command.${cmd}.usage`).split('||') - let desc = getMessage(lang, `command.${cmd}.desc`) - if (cmds[cmd].usage) { - usage = cmds[cmd].usage.split('||') - } - if (cmds[cmd].desc) { - desc = cmds[cmd].desc - } - for (const i in usage) { - console.log(getMessage(lang, 'command.help.commandUsage', [cmd, usage[i]])) - } - console.log(getMessage(lang, 'command.help.commandDesc', [desc])) - const permsN = getMessage(lang, 'command.help.permsNormal') - const permsT = getMessage(lang, 'command.help.permsTrusted') - const permsO = getMessage(lang, 'command.help.permsOwner') - const permsC = getMessage(lang, 'command.help.permsConsole') - const rPerms = cmds[cmd].level ? cmds[cmd].level : 0 - console.log(getMessage(lang, 'command.help.commandPerms', [[permsN, permsT, permsO, permsC][rPerms]])) - } - } // bot does not exist at console - this.type = 'console' - this.index = index2 - this.args = cmd.split(' ').slice(1) - this.verify = 3 - this.host = '' - this.port = '3' // :3 - this.lang = settings.defaultLang - this.colors = settings.colors - } -} - -module.exports = ConsoleCommand diff --git a/util/chatparse.js b/util/chatparse.js deleted file mode 100644 index d9a5e60..0000000 --- a/util/chatparse.js +++ /dev/null @@ -1,135 +0,0 @@ -const _lang = require('minecraft-data')('1.20.2').language -const lang = Object.create(null) // Without constructor function -for (const i in _lang) { - lang[i] = _lang[i] -} -const consoleColors = { - dark_red: '\x1B[0m\x1B[38;2;170;0;0m', - red: '\x1B[0m\x1B[38;2;255;85;85m', - dark_green: '\x1B[0m\x1B[38;2;0;170;0m', - green: '\x1B[0m\x1B[38;2;85;255;85m', - gold: '\x1B[0m\x1B[38;2;255;170;0m', - yellow: '\x1B[0m\x1B[38;2;255;255;85m', - dark_blue: '\x1B[0m\x1B[38;2;0;0;170m', - blue: '\x1B[0m\x1B[38;2;85;85;255m', - dark_purple: '\x1B[0m\x1B[38;2;170;0;170m', - light_purple: '\x1B[0m\x1B[38;2;255;85;255m', - dark_aqua: '\x1B[0m\x1B[38;2;0;170;170m', - aqua: '\x1B[0m\x1B[38;2;85;255;255m', - black: '\x1B[0m\x1B[48;2;220;220;220m\x1B[38;2;0;0;0m', - gray: '\x1B[0m\x1B[38;2;170;170;170m', - dark_gray: '\x1B[0m\x1B[38;2;85;85;85m', - white: '\x1B[0m\x1B[38;2;255;255;255m', - reset: '\x1B[0m\x1B[38;2;255;255;255m' -} -const hexColorParser = (color) => { - let out = '\x1B[0m' - const redChannel = Number('0x' + color.slice(1, 3)) - const greenChannel = Number('0x' + color.slice(3, 5)) - const blueChannel = Number('0x' + color.slice(5, 7)) - if (redChannel < 96 && greenChannel < 96 && blueChannel < 96) { - out += '\x1B[48;2;220;220;220m' - } - return out + `\x1B[38;2;${redChannel};${greenChannel};${blueChannel}m` -} -const processColor = (col, rcol) => { - const out = ['', ''] - if (col === 'reset') { - out[0] = rcol[0] - } else if (col.startsWith('#')) { - out[0] = hexColorParser(col) - } else { - out[0] = consoleColors[col] - } - return out -} -const parse = function (_data, l = 0, resetColor = [consoleColors.reset]) { - if (l >= 12) { - return ['', '', ''] - } - let data - if (typeof _data === 'string') { - data = { text: _data, color: 'reset' } - } else if (typeof _data === 'number') { - data = { text: _data + '', color: 'reset' } - } else if (_data.constructor === Array) { - data = { extra: _data, color: 'reset' } - } else { - data = _data - } - let nkt = false - const out = ['', '', ''] // console plain minecraft - if (data['']) { - data.text = data[''] - nkt = true - } - if (data.color) { - if (data.color === 'reset') { - out[0] += resetColor[0] - } else if (data.color.startsWith('#')) { - out[0] += hexColorParser(data.color) - } else { - out[0] += consoleColors[data.color] - } - } else { - out[0] += resetColor[0] - } - if (data.text) { - let _text = data.text - if (typeof _text === 'number') { - _text = _text.toString() - } - if (nkt) { - out[0] += resetColor[0] - out[2] += resetColor[1] - } - out[0] += _text.replaceAll('\x1b', '').replaceAll('\x0e', '') // Remove escape codes and [SO] from console format - out[1] += _text - out[2] += _text - } - if (data.translate) { - let trans = data.translate.replace(/%%/g, '\ue123').replaceAll('\x1b', '').replaceAll('\x0e', '') // Remove escape codes from console format - let trans2 = data.translate.replace(/%%/g, '\ue123') - let trans3 = data.translate.replace(/%%/g, '\ue123') - if (lang[trans] !== undefined) { - trans = lang[trans].replace(/%%/g, '\ue123') - trans2 = lang[trans2].replace(/%%/g, '\ue123') - trans3 = lang[trans3].replace(/%%/g, '\ue123') - } - for (const i in data.with) { - const j2 = parse(data.with[i], l + 1, data.color ? processColor(data.color, resetColor) : resetColor) - trans = trans.replace(/%s/, j2[0].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) - trans2 = trans2.replace(/%s/, j2[1].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) - trans3 = trans3.replace(/%s/, j2[2].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) - trans = trans.replaceAll(`%${+i + 1}$s`, j2[0].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) - trans2 = trans2.replaceAll(`%${+i + 1}$s`, j2[1].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) - trans3 = trans3.replaceAll(`%${+i + 1}$s`, j2[2].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) - } - out[0] += trans.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s') - out[1] += trans2.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s') - out[2] += trans3.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s') - } - if (data.extra) { - for (const i in data.extra) { - const parsed = parse(data.extra[i], l, data.color ? processColor(data.color, resetColor) : resetColor) - out[0] += parsed[0] - out[1] += parsed[1] - out[2] += parsed[2] - } - } - out[0] += resetColor[0] - return out -} -const parse2 = function (_data, l, resetColor) { - try { - return parse(_data) - } catch (e) { - console.error(e) - return [ - '\x1B[0m\x1B[38;2;255;85;85mAn error occured while parsing a message. See console for more information.\nJSON that caused the error: ' + JSON.stringify(_data), - 'An error occured while parsing a message. See console for more information. JSON that caused the error: ' + JSON.stringify(_data), - '§cAn error occured while parsing a message. See console for more information. JSON that caused the error: ' + JSON.stringify(_data) - ] - } -} -module.exports = parse2 diff --git a/util/chatparse_1204.js b/util/chatparse_1204.js deleted file mode 100644 index 3add56e..0000000 --- a/util/chatparse_1204.js +++ /dev/null @@ -1,11 +0,0 @@ -const { processNbtMessage } = require('prismarine-chat') -const parse = function (data) { - if (typeof data.type === 'string') { - return JSON.parse(processNbtMessage(data)) - } else if (typeof data === 'string') { - return JSON.parse(data) - } else { - return data - } -} -module.exports = parse diff --git a/util/hashcheck.js b/util/hashcheck.js deleted file mode 100644 index 0414d2a..0000000 --- a/util/hashcheck.js +++ /dev/null @@ -1,19 +0,0 @@ -const crypto = require('crypto') -const settings = require('../settings.json') -const secret = require(settings.secret) -module.exports = function (cmd) { - const cmdWithoutHash = cmd.slice(0, cmd.length - 1).join(' ') - const _dateString = Date.now().toString() - const dateString = _dateString.slice(0, _dateString.length - 4) - const hashTrusted = 'babyboom:' + secret.keyTrusted + ':' + cmdWithoutHash + ':' + dateString - const hashOwner = 'babyboom:' + secret.keyOwner + ':' + cmdWithoutHash + ':' + dateString - const validhashT = crypto.createHash('sha256').update(hashTrusted).digest('hex') - const validhashO = crypto.createHash('sha256').update(hashOwner).digest('hex') - if (cmd[cmd.length - 1] === validhashT) { - return 1 - } - if (cmd[cmd.length - 1] === validhashO) { - return 2 - } - return 0 -} diff --git a/util/lang.js b/util/lang.js deleted file mode 100644 index 6b0d2fe..0000000 --- a/util/lang.js +++ /dev/null @@ -1,59 +0,0 @@ -const fs = require('fs') -const languages = {} -const loadplug = (botno) => { - const bpl = fs.readdirSync('util/lang') - for (const i in bpl) { - if (!bpl[i].endsWith('.json')) { - continue - } - try { - languages[bpl[i].split('.')[0]] = require(`./lang/${bpl[i]}`) - } catch (e) { console.log(e) } - } -} -loadplug() -const getMessage = function (l, msg, with2) { - let message = msg.replace(/%%/g, '\ue123') - if (languages[l] && languages[l][message] !== undefined) { - message = languages[l][message].replace(/%%/g, '\ue123') - } else if (languages[l] && languages['en-US'][message] !== undefined) { - message = languages['en-US'][message].replace(/%%/g, '\ue123') - } - for (const i in with2) { - message = message.replace(/%s/, with2[i].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) - message = message.replaceAll(`%${+i + 1}$s`, with2[i].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) - } - return message.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s') -} -module.exports = { - getMessage, - formatTime: function (time, language) { - let finalString = '' - const seconds = Math.floor(time / 1000) % 60 - const minutes = Math.floor(time / 60000) % 60 - const hours = Math.floor(time / 3600000) % 24 - const days = Math.floor(time / 86400000) % 7 - const weeks = Math.floor(time / 604800000) - if (weeks !== 0) { - finalString += weeks; - finalString += `${weeks === 1 ? getMessage(language, "time.week") : getMessage(language, "time.weekPlural")}` - } - if (days !== 0) { - finalString += days; - finalString += `${days === 1 ? getMessage(language, "time.day") : getMessage(language, "time.dayPlural")}` - } - if (hours !== 0) { - finalString += hours; - finalString += `${hours === 1 ? getMessage(language, "time.hour") : getMessage(language, "time.hourPlural")}` - } - if (minutes !== 0) { - finalString += minutes; - finalString += `${minutes === 1 ? getMessage(language, "time.minute") : getMessage(language, "time.minutePlural")}` - } - if (seconds !== 0) { - finalString += seconds; - finalString += `${seconds === 1 ? getMessage(language, "time.second") : getMessage(language, "time.secondPlural")}` - } - return finalString - } -} diff --git a/util/lang/en-US.json b/util/lang/en-US.json deleted file mode 100644 index 75aa02f..0000000 --- a/util/lang/en-US.json +++ /dev/null @@ -1,86 +0,0 @@ -{ - "time.week": " week ", - "time.weekPlural": " weeks ", - "time.day": " day ", - "time.dayPlural": " days ", - "time.hour": " hour ", - "time.hourPlural": " hours ", - "time.minute": " minute ", - "time.minutePlural": " minutes ", - "time.second": " second ", - "time.secondPlural": " seconds ", - "command.about.usage": "", - "command.about.desc": "About the bot", - "command.cb.usage": " ", - "command.cb.desc": "Run a command in a command block", - "command.cloop.usage": " add || remove || list|| clear", - "command.cloop.desc": "Manage command loops", - "command.eval.usage": " ", - "command.eval.desc": "Run JavaScript code", - "command.help.usage": " [cmd]", - "command.help.desc": "Shows command help", - "command.logoff.usage": "", - "command.logoff.desc": "Disconnect and reconnect the bot from a server", - "command.netmsg.usage": " ", - "command.netmsg.desc": "Send a message to all servers the bot is connected to", - "command.refill.usage": "", - "command.refill.desc": "Refill core", - "command.say.usage": " ", - "command.say.desc": "Sends a message to chat", - "command.serverinfo.usage": "", - "command.serverinfo.desc": "Get system/bot info", - "command.stop.usage": "", - "command.stop.desc": "Restart bot", - "command.template.usage": " [optional]", - "command.template.desc": "Does nothing", - "command.tpr.desc": "Teleport to a random location", - "command.tpr.usage": "", - "command.verify.usage": " [args...]", - "command.verify.desc": "Check the hashing system", - "command.about.author": "%s - a Minecraft bot made by 77c8f4699b732c11 / a5a06d596f15c7db", - "command.about.version": "Version %s", - "command.about.sourceCode": "Source code: %s", - "command.about.serverinfo": "To view system information, run the command %s.", - "command.cloop.error.tooShort": "Command loops must have a rate above 20ms.", - "command.cloop.error.subcommand": "Unknown subcommand, please do %s", - "command.cloop.success.add": "Added command loop with command %s and rate %s", - "command.cloop.success.remove": "Removed command loop %s", - "command.cloop.success.clear": "Cleared all command loops", - "command.cloop.list": "%s: Command: %s Rate: %s", - "command.help.cmdList": "Commands:", - "command.help.commandInfo": "%s%s - %s", - "command.help.commandUsage": "Usage - %s%s", - "command.help.commandDesc": "Description - %s", - "command.help.commandPerms": "Required permissions - %s", - "command.help.permsNormal": "Normal", - "command.help.permsTrusted": "Trusted", - "command.help.permsOwner": "Owner", - "command.help.permsConsole": "Console", - "command.help.noCommand": "Command does not exist", - "command.serverinfo.os.android": "Android", - "command.serverinfo.os.freebsd": "FreeBSD", - "command.serverinfo.os.linux": "Linux %s", - "command.serverinfo.os.macos": "macOS", - "command.serverinfo.os.macos_old": "OS X", - "command.serverinfo.os": "Operating system", - "command.serverinfo.processor": "CPU", - "command.serverinfo.arch": "Architecture", - "command.serverinfo.osUsername": "Username", - "command.serverinfo.hostName": "Hostname", - "command.serverinfo.workingDir": "Working directory", - "command.serverinfo.runTime": "Bot uptime", - "command.serverinfo.upTime": "System uptime", - "command.serverinfo.nodeVersion": "Node.js version", - "command.serverinfo.osRelease": "Linux release", - "command.serverinfo.osRelease.missing": "/etc/os-release does not exist. Information may be limited.", - "command.serverinfo.os.android.version": "Android version", - "command.serverinfo.os.android.model": "Device model", - "command.serverinfo.botName": "Bot name", - "command.serverinfo.botVer": "Bot version", - "command.tpr.success": "Teleporting %s to %s, %s, %s", - "command.error": "An error occured (check console for more info)", - "command.disallowed.perms": "You do not have permission to run this command. If you do have permission, please make sure you put the command hash at the end, or ran the command through your client's hashing system.", - "command.disallowed.perms.yourLevel": "Your permission level: %s", - "command.disallowed.perms.cmdLevel": "Command requires: %s", - "copyText": "Click to copy!" -} diff --git a/util/lang/en-UW.json b/util/lang/en-UW.json deleted file mode 100644 index 25e081e..0000000 --- a/util/lang/en-UW.json +++ /dev/null @@ -1,86 +0,0 @@ -{ - "time.week": " week ", - "time.weekPlural": " weeks ", - "time.day": " day ", - "time.dayPlural": " days ", - "time.hour": " houw ", - "time.hourPlural": " houws ", - "time.minute": " minyute ", - "time.minutePlural": " minyutes ", - "time.second": " second ", - "time.secondPlural": " seconds ", - "command.about.usage": "", - "command.about.desc": "About the bot", - "command.cb.usage": " ", - "command.cb.desc": "Wun a command in a command bwock", - "command.cloop.usage": " add || remove || list|| clear", - "command.cloop.desc": "Manage command woops", - "command.eval.usage": " ", - "command.eval.desc": "Wun JavaScwipt code", - "command.help.usage": " [cmd]", - "command.help.desc": "Shows command hewp", - "command.logoff.usage": "", - "command.logoff.desc": "Disconnyect and weconnyect the bot fwom a sewvew", - "command.netmsg.usage": " ", - "command.netmsg.desc": "Send a message to aww sewvews the bot is connyected to", - "command.refill.usage": "", - "command.refill.desc": "Wefiww cowe", - "command.say.usage": " ", - "command.say.desc": "Sends a message to chat", - "command.serverinfo.usage": "", - "command.serverinfo.desc": "Get system/bot info", - "command.stop.usage": "", - "command.stop.desc": "Westawt bot", - "command.template.usage": " [optionyaw]", - "command.template.desc": "Does nyothing", - "command.tpr.desc": "Tewepowt to a wandom wocation", - "command.tpr.usage": "", - "command.verify.usage": " [awgs...]", - "command.verify.desc": "Check the hashing system", - "command.about.author": "%s - a Minyecwaft bot made by 77c8f4699b732c11 / a5a06d596f15c7db", - "command.about.version": "Vewsion %s", - "command.about.sourceCode": "Souwce code: %s", - "command.about.serverinfo": "To view system infowmation, wun the command %s.", - "command.cloop.error.tooShort": "Command woops must have a wate above 20ms.", - "command.cloop.error.subcommand": "Unknyown subcommand, pwease do %s", - "command.cloop.success.add": "Added command woop with command %s and wate %s", - "command.cloop.success.remove": "Wemoved command woop %s", - "command.cloop.success.clear": "Cweawed aww command woops", - "command.cloop.list": "%s: Command: %s Rate: %s", - "command.help.cmdList": "Commands:", - "command.help.commandInfo": "%s%s - %s", - "command.help.commandUsage": "Usage - %s%s", - "command.help.commandDesc": "Descwiption - %s", - "command.help.commandPerms": "Wequiwed pewmissions - %s", - "command.help.permsNormal": "Nyowmaw", - "command.help.permsTrusted": "Twusted", - "command.help.permsOwner": "Ownyew", - "command.help.permsConsole": "Consowe", - "command.help.noCommand": "Command does nyot exist", - "command.serverinfo.os.android": "Andwoid", - "command.serverinfo.os.freebsd": "FweeBSD", - "command.serverinfo.os.linux": "Winyux %s", - "command.serverinfo.os.macos": "macOS", - "command.serverinfo.os.macos_old": "OS X", - "command.serverinfo.os": "Opewating system", - "command.serverinfo.processor": "CPU", - "command.serverinfo.arch": "Awchitectuwe", - "command.serverinfo.osUsername": "Usewnyame", - "command.serverinfo.hostName": "Hostnyame", - "command.serverinfo.workingDir": "Wowking diwectowy", - "command.serverinfo.runTime": "Bot uptime", - "command.serverinfo.upTime": "System uptime", - "command.serverinfo.nodeVersion": "Nyode.js vewsion", - "command.serverinfo.osRelease": "Winyux wewease", - "command.serverinfo.osRelease.missing": "/etc/os-release does nyot exist. Infowmation may be wimited.", - "command.serverinfo.os.android.version": "Andwoid vewsion", - "command.serverinfo.os.android.model": "Device modew", - "command.serverinfo.botName": "Bot nyame", - "command.serverinfo.botVer": "Bot vewsion", - "command.tpr.success": "Tewepowting %s to %s, %s, %s", - "command.error": "An ewwow occuwed (check consowe fow mowe info)", - "command.disallowed.perms": "You do nyot have pewmission to wun this command. If you do have pewmission, pwease make suwe you put the command hash at the end, ow wan the command thwough youw cwient's hashing system.", - "command.disallowed.perms.yourLevel": "Youw pewmission wevew: %s", - "command.disallowed.perms.cmdLevel": "Command wequiwes: %s", - "copyText": "Cwick to copy!" -} diff --git a/util/textformat.js b/util/textformat.js deleted file mode 100644 index 89bb3a7..0000000 --- a/util/textformat.js +++ /dev/null @@ -1,17 +0,0 @@ -const settings = require('../settings.json') -module.exports = function (text) { - return JSON.stringify({ - translate: '[%s] %s', - color: '#FFAAFF', - with: [ - { - text: settings.name, - color: 'light_purple' - }, - { - text, - color: 'white' - } - ] - }) -} diff --git a/util/usergen.js b/util/usergen.js deleted file mode 100644 index ce845c3..0000000 --- a/util/usergen.js +++ /dev/null @@ -1,38 +0,0 @@ -const rsg = function (count) { - let output = '' - for (let i = 0; i < count; i++) { - const type = Math.floor(Math.random() * 6) - switch (type) { - case 0: - output += ' ' - break - case 1: - output += '§§' - break - case 2: - output += '§ ' - break - case 3: - case 4: - case 5:{ // Make this case more likely - let rng = Math.floor(Math.random() * 16) + 1 - if (rng === 7) rng = 17 // No bells - if (rng === 10) rng = 18 // No line feeds - if (rng === 11) rng = 19 // No vertical tabulations - if (rng === 12) rng = 20 // No form feed - if (rng === 13) rng = 21 // No carriage returns - if (rng === 14) rng = 22 // No shift out - if (rng === 15) rng = 23 // No shift in - output += `§${String.fromCharCode(rng)}` - } - } - } - return output -} -module.exports = function (legal) { - if (legal) { - return Math.floor(Math.random() * 1000000).toString() - } else { - return rsg(6 + Math.floor(Math.random() * 3)) - } -} diff --git a/util/uuidtoint.js b/util/uuidtoint.js deleted file mode 100644 index 4807ce8..0000000 --- a/util/uuidtoint.js +++ /dev/null @@ -1,5 +0,0 @@ -module.exports = function (uuid) { - const splitUUID = uuid.replace(/[^0-9a-f]/g, '').replace(/.{1,8}/g, a => { return '0x' + a }).match(/.{1,10}/g) - const numUUID = [+splitUUID[0] << 0, +splitUUID[1] << 0, +splitUUID[2] << 0, +splitUUID[3] << 0] - return numUUID -} diff --git a/version.json b/version.json deleted file mode 100644 index 4ad5b1a..0000000 --- a/version.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "botName": "botvX Dev", - "botVersion": "10.0.0-beta.1", - "sourceURL": "https://code.chipmunk.land/7cc5c4f330d47060/botvX" -} From b5da5fe50c77b62c9b5d44108494dbd83e67b518 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 30 Jul 2024 05:56:23 -0400 Subject: [PATCH 231/362] Re-add everything --- LICENSE | 9 + README.md | 42 ++ index.js | 72 +++ launch.cmd | 8 + launch.sh | 6 + package-lock.json | 830 +++++++++++++++++++++++++++++++++ package.json | 15 + plugins/!chat.js | 98 ++++ plugins/cloop.js | 23 + plugins/command.js | 181 +++++++ plugins/commandblock.js | 103 ++++ plugins/commands/about.js | 100 ++++ plugins/commands/cb.js | 7 + plugins/commands/cloop.js | 90 ++++ plugins/commands/eval.js | 11 + plugins/commands/help.js | 12 + plugins/commands/logoff.js | 7 + plugins/commands/netmsg.js | 35 ++ plugins/commands/refill.js | 7 + plugins/commands/restart.js | 7 + plugins/commands/say.js | 8 + plugins/commands/serverinfo.js | 97 ++++ plugins/commands/stop.js | 7 + plugins/commands/template.js | 42 ++ plugins/commands/tpr.js | 43 ++ plugins/commands/verify.js | 11 + plugins/console.js | 50 ++ plugins/cq.js | 19 + plugins/player.js | 46 ++ plugins/rejoin.js | 15 + plugins/selfcare.js | 66 +++ plugins/testing.js | 5 + secret_example.json | 4 + settings_example.json | 23 + util/Command.js | 24 + util/ConsoleCommand.js | 60 +++ util/chatparse.js | 135 ++++++ util/chatparse_1204.js | 11 + util/hashcheck.js | 19 + util/lang.js | 59 +++ util/lang/en-US.json | 86 ++++ util/lang/en-UW.json | 86 ++++ util/textformat.js | 17 + util/usergen.js | 38 ++ util/uuidtoint.js | 5 + version.json | 5 + 46 files changed, 2644 insertions(+) create mode 100644 LICENSE create mode 100644 README.md create mode 100755 index.js create mode 100644 launch.cmd create mode 100755 launch.sh create mode 100755 package-lock.json create mode 100755 package.json create mode 100755 plugins/!chat.js create mode 100755 plugins/cloop.js create mode 100755 plugins/command.js create mode 100755 plugins/commandblock.js create mode 100644 plugins/commands/about.js create mode 100644 plugins/commands/cb.js create mode 100644 plugins/commands/cloop.js create mode 100644 plugins/commands/eval.js create mode 100644 plugins/commands/help.js create mode 100644 plugins/commands/logoff.js create mode 100644 plugins/commands/netmsg.js create mode 100644 plugins/commands/refill.js create mode 100644 plugins/commands/restart.js create mode 100644 plugins/commands/say.js create mode 100755 plugins/commands/serverinfo.js create mode 100644 plugins/commands/stop.js create mode 100644 plugins/commands/template.js create mode 100755 plugins/commands/tpr.js create mode 100644 plugins/commands/verify.js create mode 100644 plugins/console.js create mode 100755 plugins/cq.js create mode 100644 plugins/player.js create mode 100755 plugins/rejoin.js create mode 100755 plugins/selfcare.js create mode 100755 plugins/testing.js create mode 100644 secret_example.json create mode 100755 settings_example.json create mode 100644 util/Command.js create mode 100644 util/ConsoleCommand.js create mode 100644 util/chatparse.js create mode 100644 util/chatparse_1204.js create mode 100644 util/hashcheck.js create mode 100644 util/lang.js create mode 100644 util/lang/en-US.json create mode 100644 util/lang/en-UW.json create mode 100644 util/textformat.js create mode 100644 util/usergen.js create mode 100644 util/uuidtoint.js create mode 100644 version.json diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..15549d6 --- /dev/null +++ b/LICENSE @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) 2024 7cc5c4f330d47060 + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..a9e6395 --- /dev/null +++ b/README.md @@ -0,0 +1,42 @@ +# botvX + +## What is it? + +botvX is a Minecraft bot for [Kaboom](https://kaboom.pw/) and its clones. It has many of the features that you would expect in a modern Kaboom bot: + +- commands (obviously) +- a self care system +- a command core, to run commands quickly +- a hashing system, to enable trusted users to securely run certain commands in chat + +## What does "botvX" mean? + +"botvX" means "bot version 10". The v is used to signify that whatever after it is a version, as was done with previous versions (botv4, botv6, botv8, botv9), and the X is the Roman numeral for 10, since this is the 10th major version. + +## How to install? + +1. Install [Node.js](https://nodejs.org/) for your operating system. +2. Download the latest release, or alternatively, download the latest development version using git clone https://code.chipmunk.land/7cc5c4f330d47060/botvX/. +3. Extract the files if necessary. +4. Run npm install in the bot's directory. If it doesn't work, try using the Node.js command prompt, or adding Node.js to your PATH. +5. Copy settings_example.json to settings.json , and adjust the settings to fit your needs. Do not forget to also create a secrets file. An example secrets file is provided as secret_example.json. Do not forget, if you use the secrets template, to change the keys (the ones in there are public after all!). +6. Run ./launch.sh (macOS, Linux, FreeBSD) or ./launch.cmd (Windows) to start a bot launcher, which will reload the bot when the process closes. If it displays an error saying Node is not a command, please make sure Node.js is on your PATH. + +## Command list + +| Name | Usage | Description | +|-|-|-| +| about | | About the bot | +| cb | \ | Run a command in a command block | +| cloop | add , remove , list, clear | Manage command loops | +| eval | \ | Run JavaScript code (must run through console)| +| help | [cmd] | Shows command help | +| logoff | | Disconnect and reconnect the bot from a server | +| netmsg | \ | Send a message to all servers the bot is connected to | +| refill | | Refill core | +| say | \ | Sends a message to chat | +| serverinfo | | Get system/bot info, similar to Kaboom's serverinfo command | +| stop | | Restart bot | +| template | | Used in development, does nothing | +| tpr | | Teleport to a random location | +| verify | | Check the hashing system | diff --git a/index.js b/index.js new file mode 100755 index 0000000..a69c8d2 --- /dev/null +++ b/index.js @@ -0,0 +1,72 @@ +const m = require('minecraft-protocol') +const settings = require('./settings.json') +const generateUser = require('./util/usergen.js') +const EventEmitter = require('node:events') +const fs = require('fs') + +module.exports.bot = [] + +const loadplug = (botno) => { + const botplug = [] + const bpl = fs.readdirSync('plugins') + for (const i in bpl) { + if (!bpl[i].endsWith('.js')) { + continue + } + try { + botplug.push(require(`./plugins/${bpl[i]}`)) + } catch (e) { console.log(e) } + } + botplug.forEach((plug) => { + try { + if (plug.load) { + plug.load(module.exports.bot[botno]) + } + } catch (e) { console.log(e) } + }) +} + +const createBot = function createBot (host, oldId) { + if (host.options.disabled) { + console.log(`Skipping server ${host.host}:${host.port}`) + return + } + const bot = new EventEmitter() + bot._client = m.createClient({ + host: host.host, + port: host.port ? host.port : 25565, + username: generateUser(host.options.legalName), + version: settings.version_mc + }) + bot._client.on('success', () => { + }) + if (typeof oldId !== 'undefined') { + for (const i in module.exports.bot[oldId].interval) { + clearInterval(module.exports.bot[oldId].interval[i]) + } + delete module.exports.bot[oldId] + bot.id = oldId + module.exports.bot[oldId] = bot + console.log('Re-creating bot ' + bot.id) + } else { + bot.id = module.exports.bot.length + module.exports.bot.push(bot) + console.log('Creating bot ' + bot.id) + } + + bot.host = host + bot.interval = {} + + bot.info = (msg) => { + console.log(`[${bot.id}] [info] ${msg}`) + } + loadplug(bot.id) + bot._client.on('error', (err) => { + console.log(err) + }) +} + +for (const i in settings.servers) { + createBot(settings.servers[i]) +} +module.exports.createBot = createBot diff --git a/launch.cmd b/launch.cmd new file mode 100644 index 0000000..85a5dce --- /dev/null +++ b/launch.cmd @@ -0,0 +1,8 @@ +@echo off +:botlaunch +node index.js +if %errorlevel%==1 ( + exit +) +timeout /nobreak /t 5 > nul +goto botlaunch \ No newline at end of file diff --git a/launch.sh b/launch.sh new file mode 100755 index 0000000..bd91952 --- /dev/null +++ b/launch.sh @@ -0,0 +1,6 @@ +#!/bin/bash +while [ true ]; +do node index.js; +if [ $? -eq 1 ]; then exit; fi +sleep 6; +done \ No newline at end of file diff --git a/package-lock.json b/package-lock.json new file mode 100755 index 0000000..2078e41 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,830 @@ +{ + "name": "botv10", + "version": "10.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "botv10", + "version": "10.0.0", + "license": "UNLICENSED", + "dependencies": { + "minecraft-protocol": "^1.45.0", + "prismarine-chat": "^1.10.0" + } + }, + "node_modules/@azure/msal-common": { + "version": "14.14.0", + "resolved": "https://registry.npmjs.org/@azure/msal-common/-/msal-common-14.14.0.tgz", + "integrity": "sha512-OxcOk9H1/1fktHh6//VCORgSNJc2dCQObTm6JNmL824Z6iZSO6eFo/Bttxe0hETn9B+cr7gDouTQtsRq3YPuSQ==", + "license": "MIT", + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/@azure/msal-node": { + "version": "2.12.0", + "resolved": "https://registry.npmjs.org/@azure/msal-node/-/msal-node-2.12.0.tgz", + "integrity": "sha512-jmk5Im5KujRA2AcyCb0awA3buV8niSrwXZs+NBJWIvxOz76RvNlusGIqi43A0h45BPUy93Qb+CPdpJn82NFTIg==", + "license": "MIT", + "dependencies": { + "@azure/msal-common": "14.14.0", + "jsonwebtoken": "^9.0.0", + "uuid": "^8.3.0" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/@types/node": { + "version": "22.0.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.0.0.tgz", + "integrity": "sha512-VT7KSYudcPOzP5Q0wfbowyNLaVR8QWUdw+088uFWwfvpY6uCWaXpqV6ieLAu9WBcnTa7H4Z5RLK8I5t2FuOcqw==", + "license": "MIT", + "dependencies": { + "undici-types": "~6.11.1" + } + }, + "node_modules/@types/readable-stream": { + "version": "4.0.15", + "resolved": "https://registry.npmjs.org/@types/readable-stream/-/readable-stream-4.0.15.tgz", + "integrity": "sha512-oAZ3kw+kJFkEqyh7xORZOku1YAKvsFTogRY8kVl4vHpEKiDkfnSA/My8haRE7fvmix5Zyy+1pwzOi7yycGLBJw==", + "license": "MIT", + "dependencies": { + "@types/node": "*", + "safe-buffer": "~5.1.1" + } + }, + "node_modules/@xboxreplay/errors": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/@xboxreplay/errors/-/errors-0.1.0.tgz", + "integrity": "sha512-Tgz1d/OIPDWPeyOvuL5+aai5VCcqObhPnlI3skQuf80GVF3k1I0lPCnGC+8Cm5PV9aLBT5m8qPcJoIUQ2U4y9g==", + "license": "MIT" + }, + "node_modules/@xboxreplay/xboxlive-auth": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/@xboxreplay/xboxlive-auth/-/xboxlive-auth-3.3.3.tgz", + "integrity": "sha512-j0AU8pW10LM8O68CTZ5QHnvOjSsnPICy0oQcP7zyM7eWkDQ/InkiQiirQKsPn1XRYDl4ccNu0WM582s3UKwcBg==", + "license": "MIT", + "dependencies": { + "@xboxreplay/errors": "^0.1.0", + "axios": "^0.21.1" + } + }, + "node_modules/abort-controller": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", + "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", + "license": "MIT", + "dependencies": { + "event-target-shim": "^5.0.0" + }, + "engines": { + "node": ">=6.5" + } + }, + "node_modules/aes-js": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/aes-js/-/aes-js-3.1.2.tgz", + "integrity": "sha512-e5pEa2kBnBOgR4Y/p20pskXI74UEz7de8ZGVo58asOtvSVG5YAbJeELPZxOmt+Bnz3rX753YKhfIn4X4l1PPRQ==", + "license": "MIT" + }, + "node_modules/ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/asn1": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz", + "integrity": "sha512-6i37w/+EhlWlGUJff3T/Q8u1RGmP5wgbiwYnOnbOqvtrPxT63/sYFyP9RcpxtxGymtfA075IvmOnL7ycNOWl3w==", + "license": "MIT" + }, + "node_modules/axios": { + "version": "0.21.4", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz", + "integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==", + "license": "MIT", + "dependencies": { + "follow-redirects": "^1.14.0" + } + }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/buffer": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", + "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" + } + }, + "node_modules/buffer-equal": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/buffer-equal/-/buffer-equal-1.0.1.tgz", + "integrity": "sha512-QoV3ptgEaQpvVwbXdSO39iqPQTCxSF7A5U99AxbHYqUdCizL/lH2Z0A2y6nbZucxMEOtNyZfG2s6gsVugGpKkg==", + "license": "MIT", + "engines": { + "node": ">=0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/buffer-equal-constant-time": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", + "integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==", + "license": "BSD-3-Clause" + }, + "node_modules/commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "license": "MIT" + }, + "node_modules/debug": { + "version": "4.3.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.6.tgz", + "integrity": "sha512-O/09Bd4Z1fBrU4VzkhFqVgpPzaGbw6Sm9FEkBT1A/YBXQFGuuSxa1dN2nxgxS34JmKXqYx8CZAwEVoJFImUXIg==", + "license": "MIT", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/discontinuous-range": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/discontinuous-range/-/discontinuous-range-1.0.0.tgz", + "integrity": "sha512-c68LpLbO+7kP/b1Hr1qs8/BJ09F5khZGTxqxZuhzxpmwJKOgRFHJWIb9/KmqnqHhLdO55aOxFH/EGBvUQbL/RQ==", + "license": "MIT" + }, + "node_modules/ecdsa-sig-formatter": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz", + "integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==", + "license": "Apache-2.0", + "dependencies": { + "safe-buffer": "^5.0.1" + } + }, + "node_modules/endian-toggle": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/endian-toggle/-/endian-toggle-0.0.0.tgz", + "integrity": "sha512-ShfqhXeHRE4TmggSlHXG8CMGIcsOsqDw/GcoPcosToE59Rm9e4aXaMhEQf2kPBsBRrKem1bbOAv5gOKnkliMFQ==", + "license": "MIT" + }, + "node_modules/event-target-shim": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", + "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/events": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", + "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==", + "license": "MIT", + "engines": { + "node": ">=0.8.x" + } + }, + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "license": "MIT" + }, + "node_modules/fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "license": "MIT" + }, + "node_modules/follow-redirects": { + "version": "1.15.6", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz", + "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "license": "MIT", + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, + "node_modules/ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "BSD-3-Clause" + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "license": "ISC" + }, + "node_modules/jose": { + "version": "4.15.9", + "resolved": "https://registry.npmjs.org/jose/-/jose-4.15.9.tgz", + "integrity": "sha512-1vUQX+IdDMVPj4k8kOxgUqlcK518yluMuGZwqlr44FS1ppZB/5GWh4rZG89erpOBOJjU/OBsnCVFfapsRz6nEA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/panva" + } + }, + "node_modules/json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "license": "MIT" + }, + "node_modules/jsonwebtoken": { + "version": "9.0.2", + "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-9.0.2.tgz", + "integrity": "sha512-PRp66vJ865SSqOlgqS8hujT5U4AOgMfhrwYIuIhfKaoSCZcirrmASQr8CX7cUg+RMih+hgznrjp99o+W4pJLHQ==", + "license": "MIT", + "dependencies": { + "jws": "^3.2.2", + "lodash.includes": "^4.3.0", + "lodash.isboolean": "^3.0.3", + "lodash.isinteger": "^4.0.4", + "lodash.isnumber": "^3.0.3", + "lodash.isplainobject": "^4.0.6", + "lodash.isstring": "^4.0.1", + "lodash.once": "^4.0.0", + "ms": "^2.1.1", + "semver": "^7.5.4" + }, + "engines": { + "node": ">=12", + "npm": ">=6" + } + }, + "node_modules/jwa": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/jwa/-/jwa-1.4.1.tgz", + "integrity": "sha512-qiLX/xhEEFKUAJ6FiBMbes3w9ATzyk5W7Hvzpa/SLYdxNtng+gcurvrI7TbACjIXlsJyr05/S1oUhZrc63evQA==", + "license": "MIT", + "dependencies": { + "buffer-equal-constant-time": "1.0.1", + "ecdsa-sig-formatter": "1.0.11", + "safe-buffer": "^5.0.1" + } + }, + "node_modules/jws": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/jws/-/jws-3.2.2.tgz", + "integrity": "sha512-YHlZCB6lMTllWDtSPHz/ZXTsi8S00usEV6v1tjq8tOUZzw7DpSDWVXjXDre6ed1w/pd495ODpHZYSdkRTsa0HA==", + "license": "MIT", + "dependencies": { + "jwa": "^1.4.1", + "safe-buffer": "^5.0.1" + } + }, + "node_modules/lodash.get": { + "version": "4.4.2", + "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", + "integrity": "sha512-z+Uw/vLuy6gQe8cfaFWD7p0wVv8fJl3mbzXh33RS+0oW2wvUqiRXiQ69gLWSLpgB5/6sU+r6BlQR0MBILadqTQ==", + "license": "MIT" + }, + "node_modules/lodash.includes": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz", + "integrity": "sha512-W3Bx6mdkRTGtlJISOvVD/lbqjTlPPUDTMnlXZFnVwi9NKJ6tiAk6LVdlhZMm17VZisqhKcgzpO5Wz91PCt5b0w==", + "license": "MIT" + }, + "node_modules/lodash.isboolean": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz", + "integrity": "sha512-Bz5mupy2SVbPHURB98VAcw+aHh4vRV5IPNhILUCsOzRmsTmSQ17jIuqopAentWoehktxGd9e/hbIXq980/1QJg==", + "license": "MIT" + }, + "node_modules/lodash.isinteger": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz", + "integrity": "sha512-DBwtEWN2caHQ9/imiNeEA5ys1JoRtRfY3d7V9wkqtbycnAmTvRRmbHKDV4a0EYc678/dia0jrte4tjYwVBaZUA==", + "license": "MIT" + }, + "node_modules/lodash.isnumber": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz", + "integrity": "sha512-QYqzpfwO3/CWf3XP+Z+tkQsfaLL/EnUlXWVkIk5FUPc4sBdTehEqZONuyRt2P67PXAk+NXmTBcc97zw9t1FQrw==", + "license": "MIT" + }, + "node_modules/lodash.isplainobject": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", + "integrity": "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==", + "license": "MIT" + }, + "node_modules/lodash.isstring": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz", + "integrity": "sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw==", + "license": "MIT" + }, + "node_modules/lodash.merge": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", + "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", + "license": "MIT" + }, + "node_modules/lodash.once": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz", + "integrity": "sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==", + "license": "MIT" + }, + "node_modules/lodash.reduce": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/lodash.reduce/-/lodash.reduce-4.6.0.tgz", + "integrity": "sha512-6raRe2vxCYBhpBu+B+TtNGUzah+hQjVdu3E17wfusjyrXBka2nBS8OH/gjVZ5PvHOhWmIZTYri09Z6n/QfnNMw==", + "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/minecraft-data": { + "version": "3.67.0", + "resolved": "https://registry.npmjs.org/minecraft-data/-/minecraft-data-3.67.0.tgz", + "integrity": "sha512-/hLeYXopx9o1UdViPPFenLJ3hT5S4qUEwLQM0MAHOIhqkAUGXdkl47O7ohG+f87DH3+cZksbbM61sTnSRsQpsA==", + "license": "MIT" + }, + "node_modules/minecraft-folder-path": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minecraft-folder-path/-/minecraft-folder-path-1.2.0.tgz", + "integrity": "sha512-qaUSbKWoOsH9brn0JQuBhxNAzTDMwrOXorwuRxdJKKKDYvZhtml+6GVCUrY5HRiEsieBEjCUnhVpDuQiKsiFaw==", + "license": "MIT" + }, + "node_modules/minecraft-protocol": { + "version": "1.47.0", + "resolved": "https://registry.npmjs.org/minecraft-protocol/-/minecraft-protocol-1.47.0.tgz", + "integrity": "sha512-IHL8faXLLIWv1O+2v2NgyKlooilu/OiSL9orI8Kqed/rZvVOrFPzs2PwMAYjpQX9gxLPhiSU19KqZ8CjfNuqhg==", + "license": "BSD-3-Clause", + "dependencies": { + "@types/readable-stream": "^4.0.0", + "aes-js": "^3.1.2", + "buffer-equal": "^1.0.0", + "debug": "^4.3.2", + "endian-toggle": "^0.0.0", + "lodash.get": "^4.1.2", + "lodash.merge": "^4.3.0", + "minecraft-data": "^3.55.0", + "minecraft-folder-path": "^1.2.0", + "node-fetch": "^2.6.1", + "node-rsa": "^0.4.2", + "prismarine-auth": "^2.2.0", + "prismarine-chat": "^1.10.0", + "prismarine-nbt": "^2.5.0", + "prismarine-realms": "^1.2.0", + "protodef": "^1.8.0", + "readable-stream": "^4.1.0", + "uuid-1345": "^1.0.1", + "yggdrasil": "^1.4.0" + }, + "engines": { + "node": ">=14" + } + }, + "node_modules/mojangson": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/mojangson/-/mojangson-2.0.4.tgz", + "integrity": "sha512-HYmhgDjr1gzF7trGgvcC/huIg2L8FsVbi/KacRe6r1AswbboGVZDS47SOZlomPuMWvZLas8m9vuHHucdZMwTmQ==", + "license": "MIT", + "dependencies": { + "nearley": "^2.19.5" + } + }, + "node_modules/moo": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/moo/-/moo-0.5.2.tgz", + "integrity": "sha512-iSAJLHYKnX41mKcJKjqvnAN9sf0LMDTXDEvFv+ffuRR9a1MIuXLjMNL6EsnDHSkKLTWNqQQ5uo61P4EbU4NU+Q==", + "license": "BSD-3-Clause" + }, + "node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "license": "MIT" + }, + "node_modules/nearley": { + "version": "2.20.1", + "resolved": "https://registry.npmjs.org/nearley/-/nearley-2.20.1.tgz", + "integrity": "sha512-+Mc8UaAebFzgV+KpI5n7DasuuQCHA89dmwm7JXw3TV43ukfNQ9DnBH3Mdb2g/I4Fdxc26pwimBWvjIw0UAILSQ==", + "license": "MIT", + "dependencies": { + "commander": "^2.19.0", + "moo": "^0.5.0", + "railroad-diagrams": "^1.0.0", + "randexp": "0.4.6" + }, + "bin": { + "nearley-railroad": "bin/nearley-railroad.js", + "nearley-test": "bin/nearley-test.js", + "nearley-unparse": "bin/nearley-unparse.js", + "nearleyc": "bin/nearleyc.js" + }, + "funding": { + "type": "individual", + "url": "https://nearley.js.org/#give-to-nearley" + } + }, + "node_modules/node-fetch": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", + "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "license": "MIT", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, + "node_modules/node-rsa": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/node-rsa/-/node-rsa-0.4.2.tgz", + "integrity": "sha512-Bvso6Zi9LY4otIZefYrscsUpo2mUpiAVIEmSZV2q41sP8tHZoert3Yu6zv4f/RXJqMNZQKCtnhDugIuCma23YA==", + "license": "MIT", + "dependencies": { + "asn1": "0.2.3" + } + }, + "node_modules/prismarine-auth": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/prismarine-auth/-/prismarine-auth-2.5.0.tgz", + "integrity": "sha512-CRv/pL6d/T+4cdjWS223PXG+ygHbz40Kef04L59SLMT+axNdAQro23eZZhgiIIu6u7rlvJcZYlIY93gFNtKxXA==", + "license": "MIT", + "dependencies": { + "@azure/msal-node": "^2.0.2", + "@xboxreplay/xboxlive-auth": "^3.3.3", + "debug": "^4.3.3", + "jose": "^4.1.4", + "node-fetch": "^2.6.1", + "smart-buffer": "^4.1.0", + "uuid-1345": "^1.0.2" + } + }, + "node_modules/prismarine-chat": { + "version": "1.10.1", + "resolved": "https://registry.npmjs.org/prismarine-chat/-/prismarine-chat-1.10.1.tgz", + "integrity": "sha512-XukYcuueuhDxzEXG7r8BZyt6jOObrPPB4JESCgb+/XenB9nExoSHF8eTQWWj8faKPLqm1dRQaYwFJlNBlJZJUw==", + "license": "MIT", + "dependencies": { + "mojangson": "^2.0.1", + "prismarine-nbt": "^2.0.0", + "prismarine-registry": "^1.4.0" + } + }, + "node_modules/prismarine-nbt": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/prismarine-nbt/-/prismarine-nbt-2.5.0.tgz", + "integrity": "sha512-F0/8UAa9SDDnAGrBYqZc4nG8h2zj5cE2eAJU5xlDR/IsQQ3moVxkOjE3h3nMv6SbvZrvAcgX7waA/nd9LLHYdA==", + "license": "MIT", + "dependencies": { + "protodef": "^1.9.0" + } + }, + "node_modules/prismarine-realms": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/prismarine-realms/-/prismarine-realms-1.3.2.tgz", + "integrity": "sha512-5apl9Ru8veTj5q2OozRc4GZOuSIcs3yY4UEtALiLKHstBe8bRw8vNlaz4Zla3jsQ8yP/ul1b1IJINTRbocuA6g==", + "license": "MIT", + "dependencies": { + "debug": "^4.3.3", + "node-fetch": "^2.6.1" + } + }, + "node_modules/prismarine-registry": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/prismarine-registry/-/prismarine-registry-1.7.0.tgz", + "integrity": "sha512-yyva0FpWI078nNeMhx8ekVza5uUTYhEv+C+ADu3wUQXiG8qhXkvrf0uzsnhTgZL8BLdsi2axgCEiKw9qSKIuxQ==", + "license": "MIT", + "dependencies": { + "minecraft-data": "^3.0.0", + "prismarine-nbt": "^2.0.0" + } + }, + "node_modules/process": { + "version": "0.11.10", + "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", + "integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==", + "license": "MIT", + "engines": { + "node": ">= 0.6.0" + } + }, + "node_modules/protodef": { + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/protodef/-/protodef-1.15.0.tgz", + "integrity": "sha512-bZ2Omw8dT+DACjJHLrBWZlqN4MlT9g9oSpJDdkUAJOStUzgJp+Zn42FJfPUdwutUxjaxA0PftN0PDlNa2XbneA==", + "license": "MIT", + "dependencies": { + "lodash.get": "^4.4.2", + "lodash.reduce": "^4.6.0", + "protodef-validator": "^1.3.0", + "readable-stream": "^3.0.3" + }, + "engines": { + "node": ">=14" + } + }, + "node_modules/protodef-validator": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/protodef-validator/-/protodef-validator-1.3.1.tgz", + "integrity": "sha512-lZ5FWKZYR9xOjpMw1+EfZRfCjzNRQWPq+Dk+jki47Sikl2EeWEPnTfnJERwnU/EwFq6us+0zqHHzSsmLeYX+Lg==", + "license": "MIT", + "dependencies": { + "ajv": "^6.5.4" + }, + "bin": { + "protodef-validator": "cli.js" + } + }, + "node_modules/protodef/node_modules/readable-stream": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", + "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", + "license": "MIT", + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/punycode": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/railroad-diagrams": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/railroad-diagrams/-/railroad-diagrams-1.0.0.tgz", + "integrity": "sha512-cz93DjNeLY0idrCNOH6PviZGRN9GJhsdm9hpn1YCS879fj4W+x5IFJhhkRZcwVgMmFF7R82UA/7Oh+R8lLZg6A==", + "license": "CC0-1.0" + }, + "node_modules/randexp": { + "version": "0.4.6", + "resolved": "https://registry.npmjs.org/randexp/-/randexp-0.4.6.tgz", + "integrity": "sha512-80WNmd9DA0tmZrw9qQa62GPPWfuXJknrmVmLcxvq4uZBdYqb1wYoKTmnlGUchvVWe0XiLupYkBoXVOxz3C8DYQ==", + "license": "MIT", + "dependencies": { + "discontinuous-range": "1.0.0", + "ret": "~0.1.10" + }, + "engines": { + "node": ">=0.12" + } + }, + "node_modules/readable-stream": { + "version": "4.5.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-4.5.2.tgz", + "integrity": "sha512-yjavECdqeZ3GLXNgRXgeQEdz9fvDDkNKyHnbHRFtOr7/LcfgBcmct7t/ET+HaCTqfh06OzoAxrkN/IfjJBVe+g==", + "license": "MIT", + "dependencies": { + "abort-controller": "^3.0.0", + "buffer": "^6.0.3", + "events": "^3.3.0", + "process": "^0.11.10", + "string_decoder": "^1.3.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + } + }, + "node_modules/ret": { + "version": "0.1.15", + "resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz", + "integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==", + "license": "MIT", + "engines": { + "node": ">=0.12" + } + }, + "node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "license": "MIT" + }, + "node_modules/semver": { + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/smart-buffer": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz", + "integrity": "sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg==", + "license": "MIT", + "engines": { + "node": ">= 6.0.0", + "npm": ">= 3.0.0" + } + }, + "node_modules/string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "license": "MIT", + "dependencies": { + "safe-buffer": "~5.2.0" + } + }, + "node_modules/string_decoder/node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", + "license": "MIT" + }, + "node_modules/undici-types": { + "version": "6.11.1", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.11.1.tgz", + "integrity": "sha512-mIDEX2ek50x0OlRgxryxsenE5XaQD4on5U2inY7RApK3SOJpofyw7uW2AyfMKkhAxXIceo2DeWGVGwyvng1GNQ==", + "license": "MIT" + }, + "node_modules/uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "license": "BSD-2-Clause", + "dependencies": { + "punycode": "^2.1.0" + } + }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", + "license": "MIT" + }, + "node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "license": "MIT", + "bin": { + "uuid": "dist/bin/uuid" + } + }, + "node_modules/uuid-1345": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/uuid-1345/-/uuid-1345-1.0.2.tgz", + "integrity": "sha512-bA5zYZui+3nwAc0s3VdGQGBfbVsJLVX7Np7ch2aqcEWFi5lsAEcmO3+lx3djM1npgpZI8KY2FITZ2uYTnYUYyw==", + "license": "MIT", + "dependencies": { + "macaddress": "^0.5.1" + } + }, + "node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", + "license": "BSD-2-Clause" + }, + "node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "license": "MIT", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, + "node_modules/yggdrasil": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/yggdrasil/-/yggdrasil-1.7.0.tgz", + "integrity": "sha512-QBIo5fiNd7688G3FqXXYGr36uyrYzczlNuzpWFy2zL3+R+3KT2lF+wFxm51synfA3l3z6IBiGOc1/EVXWCYY1Q==", + "license": "MIT", + "dependencies": { + "node-fetch": "^2.6.1", + "uuid": "^8.2.0" + } + } + } +} diff --git a/package.json b/package.json new file mode 100755 index 0000000..fb310c1 --- /dev/null +++ b/package.json @@ -0,0 +1,15 @@ +{ + "dependencies": { + "minecraft-protocol": "^1.45.0", + "prismarine-chat": "^1.10.0" + }, + "name": "botv10", + "version": "10.0.0", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "UNLICENSED", + "description": "" +} diff --git a/plugins/!chat.js b/plugins/!chat.js new file mode 100755 index 0000000..00423d8 --- /dev/null +++ b/plugins/!chat.js @@ -0,0 +1,98 @@ +const console2 = require('./console.js') +const parse = require('../util/chatparse.js') +const parse1204 = require('../util/chatparse_1204.js') +const messageTypes = [ + '', + 'chat.type.emote', + 'commands.message.display.incoming', + '', + '', + 'chat.type.announcement', + '', + '' +] +module.exports = { + load: (b) => { + b._client.on('profileless_chat', (data) => { + if (data.type === 4) { + const json = parse1204(data.message) + const parsed = parse(json)[1] + const split = parsed.split(': ') + const chatName = split.splice(0, 1)[0] + const username = b.findRealName(chatName) + const uuid = b.findUUID(username) + b.emit('chat', { json, type: 'profileless', uuid, message: split.join(': '), username }) + } else { + b.emit('chat', { + json: { + translate: messageTypes[data.type], + color: data.type === 2 ? 'gray' : 'reset', + with: [ + parse1204(data.name), + parse1204(data.message) + ] + }, + type: 'profileless', + uuid: '00000000-0000-0000-0000-000000000000', + message: parse(parse1204(data.message))[1], + username: parse(parse1204(data.name))[1] + }) + } + }) + + b._client.on('player_chat', (data) => { + if (data.type === 4) { + b.emit('chat', { json: parse1204(data.unsignedChatContent), type: 'player', uuid: data.senderUuid, message: data.plainMessage, username: parse(parse1204(data.networkName))[1] }) + } else { + b.emit('chat', { + json: { + translate: messageTypes[data.type], + color: data.type === 2 ? 'gray' : 'reset', + with: [ + parse1204(data.networkName), + data.plainMessage + ] + }, + type: 'player', + uuid: data.senderUuid, + message: parse(data.plainMessage)[1], + username: parse(parse1204(data.networkName))[1] + }) + } + }) + b._client.on('system_chat', (data) => { + const json = parse1204(data.content) + const parsed = parse(json)[1] + const split = parsed.split(': ') + const chatName = split.splice(0, 1)[0] + const username = b.findRealName(chatName) + const uuid = b.findUUID(username) + b.emit('chat', { json, type: 'system', uuid, message: split.join(': '), username }) + }) + b._client.on('chat', (data) => { // Legacy chat + const json = parse1204(data.message) + const parsed = parse(json)[1] + const split = parsed.split(': ') + const chatName = split.splice(0, 1)[0] + const username = b.findRealName(chatName) + const uuid = b.findUUID(username) + b.emit('chat', { json, type: 'legacy', uuid: data.uuid ? data.uuid : uuid, message: split.join(': '), username }) + }) + b.on('chat', (data) => { + const msg = parse(data.json) + if (msg[1].endsWith('\n\n\n\n\nThe chat has been cleared')) return + if (msg[1].startsWith('Command set: ')) return + b.emit('plainchat', msg[1]) + console2.write(`[${b.id}] [${data.type}] ` + msg[0]) + const fullCommand = data.message + + for (const i in b.prefix) { + if (fullCommand.startsWith(b.prefix[i])) { + const command = fullCommand.slice(b.prefix[i].length) + b.runCommand(data.username, data.uuid, command, b.prefix[i]) + } + } + }) + }, + parse +} diff --git a/plugins/cloop.js b/plugins/cloop.js new file mode 100755 index 0000000..f67fb46 --- /dev/null +++ b/plugins/cloop.js @@ -0,0 +1,23 @@ +module.exports = { + load: (b) => { + b.cloops = [] + b.addCloop = function (command, rate) { + b.cloops.push({ + command, + rate, + interval: setInterval(() => { b.ccq.push(command) }, rate) + }) + b.ccq.push(command) + } + b.removeCloop = function (index) { + clearInterval(b.cloops[index].interval) + b.cloops.splice(index, 1) + } + b.clearCloops = function () { + for (const i in b.cloops) { + clearInterval(b.cloops[i].interval) + } + b.cloops = [] + } + } +} diff --git a/plugins/command.js b/plugins/command.js new file mode 100755 index 0000000..e8b07fb --- /dev/null +++ b/plugins/command.js @@ -0,0 +1,181 @@ +const fs = require('fs') +const Command = require('../util/Command.js') +const hashcheck = require('../util/hashcheck.js') +const settings = require('../settings.json') +const {getMessage} = require('../util/lang.js') +const cmds = Object.create(null) +const bpl = fs.readdirSync('./plugins/commands') +for (const i in bpl) { // Built-in loadCMD + if (!bpl[i].endsWith('.js')) { + continue + } + try { + const commandName = bpl[i].split('.js')[0] + cmds[commandName] = require(`./commands/${bpl[i]}`) + if (cmds[commandName].level === undefined) { + cmds[commandName].level = 0 + } + console.log('Loaded command ' + commandName) + if (cmds[commandName].aliases) { + for (const j in cmds[commandName].aliases) { + cmds[cmds[commandName].aliases[j]] = { + execute: cmds[commandName].execute, + desc: 'Alias to ' + commandName, + usage: cmds[commandName].usage, + level: cmds[commandName].level, + hidden: true, + consoleIndex: cmds[commandName].consoleIndex + } + } + } + } catch (e) { console.log(e) } +} + +const sortHelp = function sortHelp (c1, c2) { + const level1 = cmds[c1.with[0]].level ? cmds[c1.with[0]].level : 0 + const level2 = cmds[c2.with[0]].level ? cmds[c2.with[0]].level : 0 + return level1 - level2 +} +module.exports = { + load: (b) => { + b.prefix = settings.prefix + b.lastCmd = 0 + b.runCommand = (name, uuid, text, prefix) => { + if (uuid === '00000000-0000-0000-0000-000000000000') return + if (Date.now() - b.lastCmd <= 1000) return + b.lastCmd = Date.now() + const cmd = text.split(' ') + const lang = settings.defaultLang + const verify = hashcheck(cmd) + if (verify > 0) { + text = cmd.slice(0, cmd.length - 1).join(' ') + } + if (cmds[cmd[0].toLowerCase()]) { + const command = cmds[cmd[0].toLowerCase()] + if (command.level !== undefined && command.level > verify) { + b.tellraw(uuid, { + text: getMessage(lang, 'command.disallowed.perms') + }) + b.tellraw(uuid, { + text: getMessage(lang, 'command.disallowed.perms.yourLevel', [verify + '']) + }) + b.tellraw(uuid, { + text: getMessage(lang, 'command.disallowed.perms.cmdLevel', [command.level + '']) + }) + return + } + try { + cmds[cmd[0].toLowerCase()].execute(new Command(uuid, name, 'nick N/A', text, prefix, b, verify)) + } catch (e) { + console.log(e) + b.tellraw(uuid, { + text: getMessage(lang, 'command.error'), + color: 'red', + hoverEvent: { + action: 'show_text', + value: { + text: e.stack + } + } + }) + } + } + } + b.printHelp = (uuid, prefix, lang) => { + const commandList = [] + for (const i in cmds) { + if (cmds[i].hidden) continue + let cmdColor + switch (cmds[i].level) { + case 0: + cmdColor = 'green' + break + case 1: + cmdColor = 'red' + break + case 2: + cmdColor = 'dark_red' + break + case 3: + cmdColor = 'dark_gray' + break + default: + cmdColor = 'gray' + } + commandList.push( + { + translate: '%s ', + color: cmdColor, + with: [ + i + ] + } + ) + } + b.tellraw(uuid, { + translate: '%s %s', + with: [ + getMessage(lang, 'command.help.cmdList'), + commandList.sort(sortHelp) + ] + }) + } + b.printCmdHelp = (uuid, cmd, lang, color) => { + if (!cmds[cmd]) { + b.tellraw(uuid, { text: getMessage(lang, 'command.help.noCommand') }) + return + } + let usage = getMessage(lang, `command.${cmd}.usage`).split('||') + let desc = getMessage(lang, `command.${cmd}.desc`) + if (cmds[cmd].usage) { + usage = cmds[cmd].usage.split('||') + } + if (cmds[cmd].desc) { + desc = cmds[cmd].desc + } + // b.tellraw(uuid,{"text":getMessage(lang,"command.help.commandInfo",[cmd,usage,desc])}); + for (const i in usage) { + b.tellraw(uuid, { + translate: getMessage(lang, 'command.help.commandUsage'), + color: color.secondary, + with: [ + { + text: cmd, + color: color.primary + }, + { + text: usage[i], + color: color.primary + } + ] + }) + } + b.tellraw(uuid, { + translate: getMessage(lang, 'command.help.commandDesc'), + color: color.secondary, + with: [ + { + text: desc, + color: color.primary + } + ] + }) + const permsN = getMessage(lang, 'command.help.permsNormal') + const permsT = getMessage(lang, 'command.help.permsTrusted') + const permsO = getMessage(lang, 'command.help.permsOwner') + const permsC = getMessage(lang, 'command.help.permsConsole') + const rPerms = cmds[cmd].level ? cmds[cmd].level : 0 + b.tellraw(uuid, { + translate: getMessage(lang, 'command.help.commandPerms'), + color: color.secondary, + with: [ + { + text: [permsN, permsT, permsO, permsC][rPerms], + color: color.primary + } + ] + }) + } + }, + cmds +} diff --git a/plugins/commandblock.js b/plugins/commandblock.js new file mode 100755 index 0000000..b489fa7 --- /dev/null +++ b/plugins/commandblock.js @@ -0,0 +1,103 @@ +const uuidToInt = require('../util/uuidtoint.js') +module.exports = { + cs: 4, + cs_v: 6, + load: function (b) { + b.interval.commandFill = setInterval(() => { if (b.sc_tasks.cc) b.sc_tasks.cc.failed = 1 }, 60000) + b.ccq = [] + b.blocknoX = 0 + b.blocknoZ = 0 + b.ccStarted = 0 + b.blocknoY = 0 + b.pos = { x: 0, y: 0, z: 0, correct: 0 } + + b.advanceccq = function () { + if (b.ccq[0] && b.ccq[0].length !== 0) { + b._client.write('update_command_block', { + command: b.ccq[0], + location: { + x: b.commandPos.x1 + b.blocknoX, + y: b.commandPos.y1 + b.blocknoY, + z: b.commandPos.z1 + b.blocknoZ + }, + mode: 2, + flags: 1 + }) + b._client.write('update_command_block', { + command: b.ccq[0], + location: { + x: b.commandPos.x1 + b.blocknoX, + y: b.commandPos.y1 + b.blocknoY, + z: b.commandPos.z1 + b.blocknoZ + }, + mode: 2, + flags: 5 + }) + b.blocknoX++ + if (b.blocknoX === module.exports.cs) { + b.blocknoY++ + b.blocknoX = 0 + if (b.blocknoY === module.exports.cs_v) { + b.blocknoZ++ + b.blocknoY = 0 + if (b.blocknoZ === module.exports.cs) { + b.blocknoZ = 0 + } + } + } + } + b.ccq.splice(0, 1) + } + b._client.on('login', () => { + b.add_sc_task('cc', '/fill ~ 55 ~ ~3 60 ~3 command_block{CustomName:\'{"translate":"%s %s","with":[{"translate":"entity.minecraft.ender_dragon"},{"translate":"language.region"}],"color":"#FFAAEE"}\'}', true, true) + b.add_sc_task('cc_size', '/gamerule commandModificationBlockLimit 32767', true, false, true) + }) + b.on('ccstart', () => { + setTimeout(() => { b.interval.ccqi = setInterval(b.advanceccq, 3) }, 1000) // 1 Second and 3 Milliseconds + b.ccStarted = true + }) + b.on('chat', (data) => { + if (data.json.translate === 'commands.fill.failed' || (data.json.extra && data.json.extra[0] && data.json.extra[0].translate === 'commands.fill.failed') || + data.json.translate === 'commands.fill.success' || (data.json.extra && data.json.extra[0] && data.json.extra[0].translate === 'commands.fill.success')) { + if (!b.ccStarted) { + b.emit('ccstart') + } + b.sc_tasks.cc.failed = 0 + b.sc_tasks.cc_size.failed = 0 + } else if (data.json.translate === 'commands.fill.toobig' || (data.json.extra && data.json.extra[0] && data.json.extra[0].translate === 'commands.fill.toobig')) { + b.sc_tasks.cc_size.failed = 1 + } + }) + b._client.on('position', function (a) { + if (!b.ccStarted) { + b.original_pos = { x: a.x, y: a.y, z: a.z } + b.pos = { x: a.x, y: a.y, z: a.z, correct: 1 } + } else { + b.pos = { x: a.x, y: a.y, z: a.z, correct: 1 } + if (a.x !== b.original_pos.x || a.z !== b.original_pos.z) { + b.original_pos = { x: a.x, y: a.y, z: a.z } + b.pos.correct = 0 + b.sc_tasks.cc.failed = 1 + } + } + + b.commandPos = { + x1: Math.floor(a.x), + z1: Math.floor(a.z), + y1: 55 + } + b._client.write('teleport_confirm', { teleportId: a.teleportId }) + }) + b.tellraw = (uuid, message) => { + let finalname = '' + if (uuid === '@a') { + finalname = '@a' + } else if (uuid.match(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/)) { + finalname = `@a[nbt={UUID:[I;${uuidToInt(uuid)}]}]` + } else { + finalname = uuid + } + b.ccq.push(`/minecraft:tellraw ${finalname} ${JSON.stringify(message)}`) + } + } +} diff --git a/plugins/commands/about.js b/plugins/commands/about.js new file mode 100644 index 0000000..80ccd0e --- /dev/null +++ b/plugins/commands/about.js @@ -0,0 +1,100 @@ +const version = require('../../version.json') +const {getMessage} = require('../../util/lang.js') +const cp = require('child_process') +module.exports = { + execute: function (c) { + c.reply({ + translate: getMessage(c.lang, 'command.about.author'), + color: c.colors.secondary, + with: [ + { + text: version.botName, + color: c.colors.primary + } + ] + }) + c.reply({ text: '' }) + const botVersion = version.botVersion + let gitCommit + let gitBranch + try { + gitCommit = cp.execSync('git rev-parse --short HEAD').toString('UTF-8').split('\n')[0] + gitBranch = cp.execSync('git rev-parse --abbrev-ref HEAD').toString('UTF-8').split('\n')[0] + } catch (e) { + gitCommit = false + gitBranch = false + } + if (gitCommit) { + c.reply({ + translate: getMessage(c.lang, 'command.about.version'), + color: c.colors.secondary, + with: [ + [ + { + text: botVersion, + color: c.colors.primary + }, + { + translate: ' (%s - %s)', + color: c.colors.secondary, + with: [ + { + text: gitCommit, + color: c.colors.primary + }, + { + text: gitBranch, + color: c.colors.primary + } + ] + } + ] + ] + }) + } else { + c.reply({ + translate: getMessage(c.lang, 'command.about.version'), + color: c.colors.secondary, + with: [ + { + text: botVersion, + color: c.colors.primary + } + ] + }) + } + c.reply({ text: '' }) + c.reply({ + translate: getMessage(c.lang, 'command.about.sourceCode'), + color: c.colors.secondary, + with: [ + { + text: version.sourceURL, + color: c.colors.primary, + clickEvent: { + action: 'open_url', + value: version.sourceURL + } + } + ] + }) + c.reply({ text: '' }) + c.reply({ + translate: getMessage(c.lang, 'command.about.serverinfo'), + color: c.colors.secondary, + with: [ + { + translate: '"%s"', + color: c.colors.secondary, + with: [ + { + text: 'serverinfo', + color: c.colors.primary + } + ] + } + ] + }) + }, + aliases: ['info'] +} diff --git a/plugins/commands/cb.js b/plugins/commands/cb.js new file mode 100644 index 0000000..c089a84 --- /dev/null +++ b/plugins/commands/cb.js @@ -0,0 +1,7 @@ +module.exports = { + execute: (c) => { + c.bot.ccq.push(c.args.join(' ')) + }, + consoleIndex: true, + aliases: ['commandblock', 'cmdblock'] +} diff --git a/plugins/commands/cloop.js b/plugins/commands/cloop.js new file mode 100644 index 0000000..3d93eeb --- /dev/null +++ b/plugins/commands/cloop.js @@ -0,0 +1,90 @@ +const {getMessage} = require('../../util/lang.js') +module.exports = { + execute: (c) => { + const subcmd = c.args.splice(0, 1)[0] + switch (subcmd) { + case 'add': { + const rate = +(c.args.splice(0, 1)[0]) + const command = c.args.join(' ') + if (rate < 20) { + c.reply({ + text: getMessage(c.lang, 'command.cloop.error.tooShort') + }) + } + c.bot.addCloop(command, rate) + c.reply({ + translate: getMessage(c.lang, 'command.cloop.success.add'), + color: c.colors.secondary, + with: [ + { + text: command, + color: c.colors.primary + }, + { + text: rate + '', + color: c.colors.primary + } + ] + }) + break + } + case 'remove': { + const index = +c.args[0] + c.bot.removeCloop(c.args[0]) + c.reply({ + translate: getMessage(c.lang, 'command.cloop.success.remove'), + color: c.colors.secondary, + with: [ + { + text: index + '', + color: c.colors.primary + } + ] + }) + break + } + case 'list': + for (const i in c.bot.cloops) { + c.reply({ + translate: getMessage(c.lang, 'command.cloop.list'), + color: c.colors.secondary, + with: [ + { + text: i, + color: c.colors.primary + }, + { + text: c.bot.cloops[i].command, + color: c.colors.primary + }, + { + text: c.bot.cloops[i].rate + '', + color: c.colors.primary + } + ] + }) + } + break + case 'clear': + c.bot.clearCloops() + c.reply({ + text: getMessage(c.lang, 'command.cloop.success.clear'), + color: c.colors.secondary + }) + break + default: + c.reply({ + translate: getMessage(c.lang, 'command.cloop.error.subcommand'), + color: c.colors.secondary, + with: [ + { + text: `${c.prefix}help cloop`, + color: c.colors.primary + } + ] + }) + } + }, + consoleIndex: true, + level: 1 +} diff --git a/plugins/commands/eval.js b/plugins/commands/eval.js new file mode 100644 index 0000000..8ed1fa9 --- /dev/null +++ b/plugins/commands/eval.js @@ -0,0 +1,11 @@ +const index = require('../../index.js') // Not used in the code, but may be used by users of the command +module.exports = { + execute: (c) => { + try { + console.log(eval(c.args.join(' '))) + } catch (e) { + console.error(e) + } + }, + level: 3 +} diff --git a/plugins/commands/help.js b/plugins/commands/help.js new file mode 100644 index 0000000..dc48e31 --- /dev/null +++ b/plugins/commands/help.js @@ -0,0 +1,12 @@ +module.exports = { + execute: (c) => { + if (c.args.length > 0) { + c.bot.printCmdHelp(c.uuid, c.args[0], c.lang, c.colors) + } else { + c.bot.printHelp(c.uuid, c.prefix, c.lang, c.colors) + } + }, + aliases: [ + 'heko' // Parker2991 request + ] +} diff --git a/plugins/commands/logoff.js b/plugins/commands/logoff.js new file mode 100644 index 0000000..e05cae0 --- /dev/null +++ b/plugins/commands/logoff.js @@ -0,0 +1,7 @@ +module.exports = { + execute: (c) => { + c.bot._client.end() + }, + consoleIndex: true, + level: 2 +} diff --git a/plugins/commands/netmsg.js b/plugins/commands/netmsg.js new file mode 100644 index 0000000..b3acbac --- /dev/null +++ b/plugins/commands/netmsg.js @@ -0,0 +1,35 @@ +const { bot } = require('../../index.js') +module.exports = { + execute: (c) => { + const json = { + translate: '[%s] %s: %s', + with: [ + { + translate: '%s:%s', + with: [ + { + text: c.host, + color: c.colors.primary + }, + { + text: c.port + '', + color: c.colors.primary + } + ], + color: c.colors.secondary + }, + { + text: c.username, + color: c.colors.primary + }, + { + text: c.args.join(' ') + } + ], + color: 'white' + } + for (const i in bot) { + bot[i].tellraw('@a', json) + } + } +} diff --git a/plugins/commands/refill.js b/plugins/commands/refill.js new file mode 100644 index 0000000..b626b05 --- /dev/null +++ b/plugins/commands/refill.js @@ -0,0 +1,7 @@ +module.exports = { + execute: (c) => { + c.bot.chat('/fill ~ 55 ~ ~3 60 ~3 command_block{CustomName:\'{"translate":"%s %s","with":[{"translate":"entity.minecraft.ender_dragon"},{"translate":"language.region"}],"color":"#FFAAEE"}\'}') + }, + consoleIndex: true, + aliases: ['refillcore', 'rc'] +} diff --git a/plugins/commands/restart.js b/plugins/commands/restart.js new file mode 100644 index 0000000..5f64d6d --- /dev/null +++ b/plugins/commands/restart.js @@ -0,0 +1,7 @@ +module.exports = { + execute: (c) => { + process.exit(1) + }, + aliases: ['reboot'], + level: 2 +} diff --git a/plugins/commands/say.js b/plugins/commands/say.js new file mode 100644 index 0000000..e6bc74f --- /dev/null +++ b/plugins/commands/say.js @@ -0,0 +1,8 @@ +module.exports = { + execute: (c) => { + if (c.args[0].startsWith('/') && c.verify < 1) return + c.bot.chat(c.args.join(' ')) + }, + consoleIndex: true, + aliases: ['echo'] +} diff --git a/plugins/commands/serverinfo.js b/plugins/commands/serverinfo.js new file mode 100755 index 0000000..10c5899 --- /dev/null +++ b/plugins/commands/serverinfo.js @@ -0,0 +1,97 @@ +const os = require('os') +const cp = require('child_process') +const version = require('../../version.json') +const {getMessage,formatTime} = require('../../util/lang.js') +const fs = require('fs') +const gr = function (l, text, value, color) { + if (!color) color = 'white' + return { + translate: '%s: %s', + color: color.primary, + with: [ + { + text, + color: color.secondary + }, + { + text: value, + color: color.primary + } + ], + hoverEvent: { + action: 'show_text', + contents: { + text: getMessage(l, 'copyText') + } + }, + clickEvent: { + action: 'copy_to_clipboard', + value + } + } +} + +const os2 = function (o2, l) { + switch (o2) { + case 'win32': + return `${os.version()} (${os.release})` + case 'android': + return getMessage(l, 'command.serverinfo.os.android') + case 'linux': + return getMessage(l, 'command.serverinfo.os.linux', [os.release()]) + default: + return o2 + } +} +module.exports = { + execute: function (c) { + c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.os'), os2(process.platform, c.lang), c.colors)) + if (os.cpus()[0]) c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.processor'), os.cpus()[0].model, c.colors)) + c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.arch'), os.machine(), c.colors)) + c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.osUsername'), `${os.userInfo().username} (${os.userInfo().uid})`, c.colors)) + c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.hostName'), os.hostname(), c.colors)) + c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.workingDir'), process.cwd(), c.colors)) + c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.runTime'), formatTime(process.uptime() * 1000, c.lang), c.colors)) + c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.upTime'), formatTime(os.uptime() * 1000, c.lang), c.colors)) + c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.nodeVersion'), process.version, c.colors)) + if (process.platform === 'linux' || process.platform === 'freebsd') { + try { + const osrelease = fs.readFileSync('/etc/os-release').toString('UTF-8').split('\n') + const osrelease2 = {} + for (const i in osrelease) { + if (!osrelease[i].includes('=')) continue + let osrvalue = osrelease[i].split('=')[1] + if (osrvalue.startsWith('"') && osrvalue.endsWith('"')) { osrvalue = osrvalue.slice(1, osrvalue.length - 1) }; + osrelease2[osrelease[i].split('=')[0]] = osrvalue + } + + if (osrelease2.PRETTY_NAME) { + c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.osRelease'), osrelease2.PRETTY_NAME, c.colors)) + } + } catch (e) { + c.reply({ text: getMessage(c.lang, 'command.serverinfo.osRelease.missing') }) + } + } else if (process.platform === 'android') { + const androidVersion = cp.execSync('getprop ro.build.version.release').toString('UTF-8').split('\n')[0] + c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.os.android.version'), androidVersion, c.colors)) + const dModel = cp.execSync('getprop ro.product.model').toString('UTF-8').split('\n')[0] + const dBrand = cp.execSync('getprop ro.product.brand').toString('UTF-8').split('\n')[0] + c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.os.android.model'), dBrand + ' ' + dModel, c.colors)) + } + c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.botName'), version.botName, c.colors)) + let botVersion = version.botVersion + let gitCommit + let gitBranch + try { + gitCommit = cp.execSync('git rev-parse --short HEAD').toString('UTF-8').split('\n')[0] + gitBranch = cp.execSync('git rev-parse --abbrev-ref HEAD').toString('UTF-8').split('\n')[0] + } catch (e) { + gitCommit = false + gitBranch = false + } + if (gitCommit) { + botVersion += ` (${gitCommit} - ${gitBranch})` + } + c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.botVer'), botVersion, c.colors)) + } +} diff --git a/plugins/commands/stop.js b/plugins/commands/stop.js new file mode 100644 index 0000000..441c345 --- /dev/null +++ b/plugins/commands/stop.js @@ -0,0 +1,7 @@ +module.exports = { + execute: (c) => { + process.exit(0) + }, + aliases: ['exit'], + level: 2 +} diff --git a/plugins/commands/template.js b/plugins/commands/template.js new file mode 100644 index 0000000..375f1f7 --- /dev/null +++ b/plugins/commands/template.js @@ -0,0 +1,42 @@ +module.exports = { + execute: (c) => { + // Blank template + /* + c.send(text, user?): Send text to all ("/tellraw @a") + c.reply(text): Send text to command sender + c.uuid: Unique identifier (UUID for Minecraft, Discord ID for Discord) + c.username: Username of sender + c.nickname: Nickname of sender when applicable + c.command: Command string + c.args: Arguments of command (above without the first section, and split at every space) + c.prefix: Prefix being used to send the command (when applicable) + c.bot: Bot that received the command. Will be different type based on where it was received + c.type: Type of bot receiving the command ("minecraft", "console", "discord") + c.lang: The language the player has selected, or the default if none + c.colors: The color palette the player has selected, or the default if none + */ + }, + /* + Command description and usage have been moved to the message files. The format for a basic command is: + "command.(name).usage": " [optional]", + "command.(name).desc": "Insert description here...", + replacing (name) with the name of the new command. + Some more complex commands may have messages of their own, which should be placed there too. + First, insert the following line near the top of the command's file (not in the execute function): + const {getMessage} = require('../../util/lang.js') + Then, to get a specific message: + getMessage(c.lang,"(message key)",[(arguments, in an array (optional))]) + For example, this will show the "about" command's redirection to "serverinfo": + getMessage(c.lang,"command.about.serverinfo") + The with array can be used to add information to a message. For example: + getMessage(lang,"command.help.commandInfo",["cmd","usage","desc"]) + shows the "help" command's formatting for command information, with some strings as items. + That message would render as (in en-US): + cmdusage - desc + Extra information is inserted wherever there is a "%s" or a "%n$s", with n being the index of the item in the array. + */ + hidden: true, // To show the command on the help command list, remove this line (optional) + consoleIndex: true, // When run from console, the second argument will be a bot ID (optional) + aliases: ['example', 'testing'], // Other command names that will work the same (optional) + level: 0 // Permission level required to run this command (optional) +} diff --git a/plugins/commands/tpr.js b/plugins/commands/tpr.js new file mode 100755 index 0000000..ffd7bf0 --- /dev/null +++ b/plugins/commands/tpr.js @@ -0,0 +1,43 @@ +const {getMessage} = require('../../util/lang.js') +module.exports = { + execute: function (c) { + let uuid + if (c.type === 'console') { + uuid = c.bot._client.uuid + } else { + uuid = c.uuid + } + const originalPos = { + x: Math.floor(Math.random() * 2000000) - 1000000, + y: 100, + z: Math.floor(Math.random() * 2000000) - 1000000 + } + c.reply( + { + translate: getMessage(c.lang, 'command.tpr.success'), + color: c.colors.secondary, + with: [ + { + text: c.username, + color: c.colors.primary + }, + { + text: originalPos.x.toString(), + color: c.colors.primary + }, + { + text: originalPos.y.toString(), + color: c.colors.primary + }, + { + text: originalPos.z.toString(), + color: c.colors.primary + } + ] + } + ) + c.bot.ccq.push(`/essentials:tp ${uuid} ${originalPos.x}.0 ${originalPos.y} ${originalPos.z}.0`) + }, + consoleIndex: true, + aliases: ['rtp'] +} diff --git a/plugins/commands/verify.js b/plugins/commands/verify.js new file mode 100644 index 0000000..f1941a2 --- /dev/null +++ b/plugins/commands/verify.js @@ -0,0 +1,11 @@ +module.exports = { + execute: (c) => { + c.reply({ + text: c.verify + '' + }) + c.reply({ + text: c.command + }) + }, + level: 1 +} diff --git a/plugins/console.js b/plugins/console.js new file mode 100644 index 0000000..367871c --- /dev/null +++ b/plugins/console.js @@ -0,0 +1,50 @@ +const readln = require('readline') +const index = require('../index.js') +const ConsoleCommand = require('../util/ConsoleCommand.js') +const newercommands = require('./command.js').cmds +const rl = readln.createInterface({ + input: process.stdin, + output: process.stdout, + prompt: '\x1b[0m\x1b[38;5;15m> ' +}) +rl.on('line', (l) => { + try { + if (newercommands[l.split(' ')[0].toLowerCase()]) { + if (newercommands[l.split(' ')[0].toLowerCase()].consoleIndex) { + const tmpcmd = l.split(' ') + const index2 = tmpcmd.splice(1, 1)[0] + if (index2 === '*') { + for (let i = 0; i < index.bot.length; i++) { + const cmd = new ConsoleCommand(tmpcmd.join(' '), i) + newercommands[l.split(' ')[0].toLowerCase()].execute(cmd) + } + } else { + const cmd = new ConsoleCommand(tmpcmd.join(' '), +index2) + newercommands[l.split(' ')[0].toLowerCase()].execute(cmd) + } + } else { + const cmd = new ConsoleCommand(l, -2) + newercommands[l.split(' ')[0].toLowerCase()].execute(cmd) + } + } + } catch (e) { + console.log(e) + } + rl.prompt(false) +}) +rl.prompt() +function consoleWrite (text) { + readln.cursorTo(process.stdout, 0) + readln.clearLine(process.stdout, 0) + process.stdout.write(text + '\n') + rl.prompt(true) +} +module.exports = { + load: (b) => { + b.info = (msg) => { + consoleWrite(`[${b.id}] [info] ${msg}`) + } + }, + rl, + write: consoleWrite +} diff --git a/plugins/cq.js b/plugins/cq.js new file mode 100755 index 0000000..4cdbae5 --- /dev/null +++ b/plugins/cq.js @@ -0,0 +1,19 @@ +module.exports = { + load: (b) => { + b._client.on('login', () => { + b.interval.chatQueue = setInterval(() => { + if (b.chatqueue.length !== 0) { + b._client.chat(b.chatqueue[0]) + b.chatqueue.splice(0, 1) + } + }, 150) + }) + b.chatqueue = [] + b.chat = function chat (msg) { + if (msg.length === 0) return + msg.match(/.{1,250}/g).forEach(element => { + b.chatqueue.push(element) + }) + } + } +} diff --git a/plugins/player.js b/plugins/player.js new file mode 100644 index 0000000..c18d37b --- /dev/null +++ b/plugins/player.js @@ -0,0 +1,46 @@ +const parse = require('../util/chatparse.js') +const parse1204 = require('../util/chatparse_1204.js') +module.exports = { + load: (b) => { + b.players = {} + b._client.on('player_info', (data) => { + const buffer2 = {} + for (const i in data.data) { + let uuid + if (data.data[i].uuid) { + uuid = data.data[i].uuid + } else if (data.data[i].UUID) { + uuid = data.data[i].UUID + } + if (data.data[i].player && data.data[i].player.name !== undefined) { + buffer2[uuid] = { realName: data.data[i].player.name, displayName: parse(parse1204(data.data[i].displayName))[1] } + } else if (data.data[i].name !== undefined) { + buffer2[uuid] = { realName: data.data[i].name, displayName: parse(parse1204(data.data[i].displayName))[1] } + } else if (data.data[i].displayName !== undefined) { + buffer2[uuid] = { displayName: parse(parse1204(data.data[i].displayName))[1] } + } + } + for (const uuid in buffer2) { + if (!b.players[uuid]) b.players[uuid] = { displayName: '', realName: '' } + if (buffer2[uuid].displayName) b.players[uuid].displayName = buffer2[uuid].displayName + if (buffer2[uuid].realName) b.players[uuid].realName = buffer2[uuid].realName + } + }) + b.findUUID = (name) => { + for (const i in b.players) { + if (b.players[i].realName === name) { + return i + } + } + return '00000000-0000-0000-0000-000000000000' + } + b.findRealName = (name) => { + for (const i in b.players) { + if (b.players[i].displayName === name) { + return b.players[i].realName + } + } + return 'Geometrical Dominator' + } + } +} diff --git a/plugins/rejoin.js b/plugins/rejoin.js new file mode 100755 index 0000000..8c9e56b --- /dev/null +++ b/plugins/rejoin.js @@ -0,0 +1,15 @@ +const index = require('../index.js') +module.exports = { + load: (b) => { + b._client.on('end', () => { + b.info('bot ' + b.id + ' disconnected') + for (const i in b.interval) { + clearInterval(b.interval[i]) + } + setTimeout(() => { + b.info('Re-connecting bot ' + b.id) + index.createBot(b.host, b.id) + }, 5000) + }) + } +} diff --git a/plugins/selfcare.js b/plugins/selfcare.js new file mode 100755 index 0000000..c83dad1 --- /dev/null +++ b/plugins/selfcare.js @@ -0,0 +1,66 @@ +class SCTask { + constructor (failTask, chatCommand, startFailed = false) { + /* + * failed: Whether to run this task + * failTask: Command to run when failed is true + * chatCommand: Whether to run failTask in chat rather than in command block + */ + this.failed = startFailed + this.failTask = failTask + this.chatCommand = chatCommand + } +} +module.exports = { + load: (b) => { + b.sc_tasks = {} + b.interval.sc = setInterval(() => { + for (const i in b.sc_tasks) { + if (b.sc_tasks[i].failed) { + if (b.sc_tasks[i].chatCommand) { + b.chat(b.sc_tasks[i].failTask) + } else { + b.ccq.push(b.sc_tasks[i].failTask) // Does not automatically reset + } + } + } + }, 1000) + b.add_sc_task = (name, failTask, chatCommand, startFailed) => { + b.sc_tasks[name] = new SCTask(failTask, chatCommand, startFailed) + } + + // Selfcare tasks + + // Operator + b.add_sc_task('op', '/op @s[type=player]', true) + b._client.on('login', (p) => { + b.entityId = p.entityId + }) + b._client.on('entity_status', (p) => { + if (p.entityId === b.entityId && p.entityStatus === 24) { + b.sc_tasks.op.failed = 1 + } else if (p.entityId === b.entityId && p.entityStatus === 28) { + b.sc_tasks.op.failed = 0 + } + }) + + // Commandspy + b.add_sc_task('cspy', '/cspy on', true, true) + b.on('plainchat', (msg) => { + if (msg === 'Successfully disabled CommandSpy') { + b.sc_tasks.cspy.failed = 1 + } else if (msg === 'Successfully enabled CommandSpy') { + b.sc_tasks.cspy.failed = 0 + } + }) + + // Gamemode + b.add_sc_task('gamemode', '/minecraft:gamemode creative', true) + b._client.on('game_state_change', (p) => { + if (p.reason === 3 && p.gameMode !== 1) { + b.sc_tasks.gamemode.failed = 1 + } else if (p.reason === 3 && p.gameMode === 1) { + b.sc_tasks.gamemode.failed = 0 + } + }) + } +} diff --git a/plugins/testing.js b/plugins/testing.js new file mode 100755 index 0000000..f886c5e --- /dev/null +++ b/plugins/testing.js @@ -0,0 +1,5 @@ +module.exports = { + load: (b) => { + + } +} diff --git a/secret_example.json b/secret_example.json new file mode 100644 index 0000000..61a3ce8 --- /dev/null +++ b/secret_example.json @@ -0,0 +1,4 @@ +{ + "keyTrusted": "Insert trusted level key here...", + "keyOwner": "Insert owner level key here..." +} diff --git a/settings_example.json b/settings_example.json new file mode 100755 index 0000000..5a393ab --- /dev/null +++ b/settings_example.json @@ -0,0 +1,23 @@ +{ + "secret":"C:\\Users\\Username\\Documents\\botvX\\secret.json", + "name": "Minecraft Bot", + "version_mc": "1.20.4", + "defaultLang": "en-US", + "colors": { + "primary": "#FFCCEE", + "secondary": "#FF99DD" + }, + "prefix":[ + "bot:", + "\"" + ], + "servers":[ + { + "host": "kaboom.pw", + "port": 25565, + "options":{ + "name": "kaboom" + } + } + ] +} diff --git a/util/Command.js b/util/Command.js new file mode 100644 index 0000000..fd8e2da --- /dev/null +++ b/util/Command.js @@ -0,0 +1,24 @@ +// HOW TO WRITE CLASS JS +const settings = require('../settings.json') +class Command { + constructor (uuid, user, nick, cmd, prefix, bot, verify, lang = settings.defaultLang) { + this.send = (text, uuid) => { bot.tellraw(uuid || '@a', text) } + this.reply = text => bot.tellraw(uuid, text) + this.uuid = uuid + this.username = user + this.nickname = nick + this.command = cmd + this.prefix = prefix + this.bot = bot + this.type = 'minecraft' + this.index = bot.id + this.args = cmd.split(' ').slice(1) + this.verify = verify + this.host = bot.host.host + this.port = bot.host.port + this.lang = lang + this.colors = settings.colors + } +} + +module.exports = Command diff --git a/util/ConsoleCommand.js b/util/ConsoleCommand.js new file mode 100644 index 0000000..a724f0e --- /dev/null +++ b/util/ConsoleCommand.js @@ -0,0 +1,60 @@ +// HOW TO WRITE CLASS JS +const index = require('../index.js') +const { cmds } = require('../plugins/command.js') +const parse = require('../util/chatparse.js') +const settings = require('../settings.json') +const {getMessage} = require('../util/lang.js') +const lang = settings.defaultLang +class ConsoleCommand { + constructor (cmd, index2) { + this.send = () => {} // not needed for console + this.reply = text => process.stdout.write(parse(text)[0] + '\n') + this.uuid = 'dde5a2a6-ebdd-4bbb-8eac-f75b10c10446_console' // hard-coded because uuid does not exist at console + this.username = 'Owner' + this.nickname = 'Console' + this.command = cmd + this.prefix = '' // prefix does not exist at console + this.bot = index2 >= 0 + ? index.bot[index2] + : { + printHelp: () => { + const helpCmds = [] + for (const i in cmds) { + // if(cmds[i].hidden) continue; + helpCmds.push(i) + } + console.log(getMessage(lang, 'command.help.cmdList'), helpCmds.join(' ')) + }, + printCmdHelp: (uuid, cmd) => { + let usage = getMessage(lang, `command.${cmd}.usage`).split('||') + let desc = getMessage(lang, `command.${cmd}.desc`) + if (cmds[cmd].usage) { + usage = cmds[cmd].usage.split('||') + } + if (cmds[cmd].desc) { + desc = cmds[cmd].desc + } + for (const i in usage) { + console.log(getMessage(lang, 'command.help.commandUsage', [cmd, usage[i]])) + } + console.log(getMessage(lang, 'command.help.commandDesc', [desc])) + const permsN = getMessage(lang, 'command.help.permsNormal') + const permsT = getMessage(lang, 'command.help.permsTrusted') + const permsO = getMessage(lang, 'command.help.permsOwner') + const permsC = getMessage(lang, 'command.help.permsConsole') + const rPerms = cmds[cmd].level ? cmds[cmd].level : 0 + console.log(getMessage(lang, 'command.help.commandPerms', [[permsN, permsT, permsO, permsC][rPerms]])) + } + } // bot does not exist at console + this.type = 'console' + this.index = index2 + this.args = cmd.split(' ').slice(1) + this.verify = 3 + this.host = '' + this.port = '3' // :3 + this.lang = settings.defaultLang + this.colors = settings.colors + } +} + +module.exports = ConsoleCommand diff --git a/util/chatparse.js b/util/chatparse.js new file mode 100644 index 0000000..d9a5e60 --- /dev/null +++ b/util/chatparse.js @@ -0,0 +1,135 @@ +const _lang = require('minecraft-data')('1.20.2').language +const lang = Object.create(null) // Without constructor function +for (const i in _lang) { + lang[i] = _lang[i] +} +const consoleColors = { + dark_red: '\x1B[0m\x1B[38;2;170;0;0m', + red: '\x1B[0m\x1B[38;2;255;85;85m', + dark_green: '\x1B[0m\x1B[38;2;0;170;0m', + green: '\x1B[0m\x1B[38;2;85;255;85m', + gold: '\x1B[0m\x1B[38;2;255;170;0m', + yellow: '\x1B[0m\x1B[38;2;255;255;85m', + dark_blue: '\x1B[0m\x1B[38;2;0;0;170m', + blue: '\x1B[0m\x1B[38;2;85;85;255m', + dark_purple: '\x1B[0m\x1B[38;2;170;0;170m', + light_purple: '\x1B[0m\x1B[38;2;255;85;255m', + dark_aqua: '\x1B[0m\x1B[38;2;0;170;170m', + aqua: '\x1B[0m\x1B[38;2;85;255;255m', + black: '\x1B[0m\x1B[48;2;220;220;220m\x1B[38;2;0;0;0m', + gray: '\x1B[0m\x1B[38;2;170;170;170m', + dark_gray: '\x1B[0m\x1B[38;2;85;85;85m', + white: '\x1B[0m\x1B[38;2;255;255;255m', + reset: '\x1B[0m\x1B[38;2;255;255;255m' +} +const hexColorParser = (color) => { + let out = '\x1B[0m' + const redChannel = Number('0x' + color.slice(1, 3)) + const greenChannel = Number('0x' + color.slice(3, 5)) + const blueChannel = Number('0x' + color.slice(5, 7)) + if (redChannel < 96 && greenChannel < 96 && blueChannel < 96) { + out += '\x1B[48;2;220;220;220m' + } + return out + `\x1B[38;2;${redChannel};${greenChannel};${blueChannel}m` +} +const processColor = (col, rcol) => { + const out = ['', ''] + if (col === 'reset') { + out[0] = rcol[0] + } else if (col.startsWith('#')) { + out[0] = hexColorParser(col) + } else { + out[0] = consoleColors[col] + } + return out +} +const parse = function (_data, l = 0, resetColor = [consoleColors.reset]) { + if (l >= 12) { + return ['', '', ''] + } + let data + if (typeof _data === 'string') { + data = { text: _data, color: 'reset' } + } else if (typeof _data === 'number') { + data = { text: _data + '', color: 'reset' } + } else if (_data.constructor === Array) { + data = { extra: _data, color: 'reset' } + } else { + data = _data + } + let nkt = false + const out = ['', '', ''] // console plain minecraft + if (data['']) { + data.text = data[''] + nkt = true + } + if (data.color) { + if (data.color === 'reset') { + out[0] += resetColor[0] + } else if (data.color.startsWith('#')) { + out[0] += hexColorParser(data.color) + } else { + out[0] += consoleColors[data.color] + } + } else { + out[0] += resetColor[0] + } + if (data.text) { + let _text = data.text + if (typeof _text === 'number') { + _text = _text.toString() + } + if (nkt) { + out[0] += resetColor[0] + out[2] += resetColor[1] + } + out[0] += _text.replaceAll('\x1b', '').replaceAll('\x0e', '') // Remove escape codes and [SO] from console format + out[1] += _text + out[2] += _text + } + if (data.translate) { + let trans = data.translate.replace(/%%/g, '\ue123').replaceAll('\x1b', '').replaceAll('\x0e', '') // Remove escape codes from console format + let trans2 = data.translate.replace(/%%/g, '\ue123') + let trans3 = data.translate.replace(/%%/g, '\ue123') + if (lang[trans] !== undefined) { + trans = lang[trans].replace(/%%/g, '\ue123') + trans2 = lang[trans2].replace(/%%/g, '\ue123') + trans3 = lang[trans3].replace(/%%/g, '\ue123') + } + for (const i in data.with) { + const j2 = parse(data.with[i], l + 1, data.color ? processColor(data.color, resetColor) : resetColor) + trans = trans.replace(/%s/, j2[0].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + trans2 = trans2.replace(/%s/, j2[1].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + trans3 = trans3.replace(/%s/, j2[2].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + trans = trans.replaceAll(`%${+i + 1}$s`, j2[0].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + trans2 = trans2.replaceAll(`%${+i + 1}$s`, j2[1].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + trans3 = trans3.replaceAll(`%${+i + 1}$s`, j2[2].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + } + out[0] += trans.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s') + out[1] += trans2.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s') + out[2] += trans3.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s') + } + if (data.extra) { + for (const i in data.extra) { + const parsed = parse(data.extra[i], l, data.color ? processColor(data.color, resetColor) : resetColor) + out[0] += parsed[0] + out[1] += parsed[1] + out[2] += parsed[2] + } + } + out[0] += resetColor[0] + return out +} +const parse2 = function (_data, l, resetColor) { + try { + return parse(_data) + } catch (e) { + console.error(e) + return [ + '\x1B[0m\x1B[38;2;255;85;85mAn error occured while parsing a message. See console for more information.\nJSON that caused the error: ' + JSON.stringify(_data), + 'An error occured while parsing a message. See console for more information. JSON that caused the error: ' + JSON.stringify(_data), + '§cAn error occured while parsing a message. See console for more information. JSON that caused the error: ' + JSON.stringify(_data) + ] + } +} +module.exports = parse2 diff --git a/util/chatparse_1204.js b/util/chatparse_1204.js new file mode 100644 index 0000000..3add56e --- /dev/null +++ b/util/chatparse_1204.js @@ -0,0 +1,11 @@ +const { processNbtMessage } = require('prismarine-chat') +const parse = function (data) { + if (typeof data.type === 'string') { + return JSON.parse(processNbtMessage(data)) + } else if (typeof data === 'string') { + return JSON.parse(data) + } else { + return data + } +} +module.exports = parse diff --git a/util/hashcheck.js b/util/hashcheck.js new file mode 100644 index 0000000..0414d2a --- /dev/null +++ b/util/hashcheck.js @@ -0,0 +1,19 @@ +const crypto = require('crypto') +const settings = require('../settings.json') +const secret = require(settings.secret) +module.exports = function (cmd) { + const cmdWithoutHash = cmd.slice(0, cmd.length - 1).join(' ') + const _dateString = Date.now().toString() + const dateString = _dateString.slice(0, _dateString.length - 4) + const hashTrusted = 'babyboom:' + secret.keyTrusted + ':' + cmdWithoutHash + ':' + dateString + const hashOwner = 'babyboom:' + secret.keyOwner + ':' + cmdWithoutHash + ':' + dateString + const validhashT = crypto.createHash('sha256').update(hashTrusted).digest('hex') + const validhashO = crypto.createHash('sha256').update(hashOwner).digest('hex') + if (cmd[cmd.length - 1] === validhashT) { + return 1 + } + if (cmd[cmd.length - 1] === validhashO) { + return 2 + } + return 0 +} diff --git a/util/lang.js b/util/lang.js new file mode 100644 index 0000000..6b0d2fe --- /dev/null +++ b/util/lang.js @@ -0,0 +1,59 @@ +const fs = require('fs') +const languages = {} +const loadplug = (botno) => { + const bpl = fs.readdirSync('util/lang') + for (const i in bpl) { + if (!bpl[i].endsWith('.json')) { + continue + } + try { + languages[bpl[i].split('.')[0]] = require(`./lang/${bpl[i]}`) + } catch (e) { console.log(e) } + } +} +loadplug() +const getMessage = function (l, msg, with2) { + let message = msg.replace(/%%/g, '\ue123') + if (languages[l] && languages[l][message] !== undefined) { + message = languages[l][message].replace(/%%/g, '\ue123') + } else if (languages[l] && languages['en-US'][message] !== undefined) { + message = languages['en-US'][message].replace(/%%/g, '\ue123') + } + for (const i in with2) { + message = message.replace(/%s/, with2[i].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + message = message.replaceAll(`%${+i + 1}$s`, with2[i].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + } + return message.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s') +} +module.exports = { + getMessage, + formatTime: function (time, language) { + let finalString = '' + const seconds = Math.floor(time / 1000) % 60 + const minutes = Math.floor(time / 60000) % 60 + const hours = Math.floor(time / 3600000) % 24 + const days = Math.floor(time / 86400000) % 7 + const weeks = Math.floor(time / 604800000) + if (weeks !== 0) { + finalString += weeks; + finalString += `${weeks === 1 ? getMessage(language, "time.week") : getMessage(language, "time.weekPlural")}` + } + if (days !== 0) { + finalString += days; + finalString += `${days === 1 ? getMessage(language, "time.day") : getMessage(language, "time.dayPlural")}` + } + if (hours !== 0) { + finalString += hours; + finalString += `${hours === 1 ? getMessage(language, "time.hour") : getMessage(language, "time.hourPlural")}` + } + if (minutes !== 0) { + finalString += minutes; + finalString += `${minutes === 1 ? getMessage(language, "time.minute") : getMessage(language, "time.minutePlural")}` + } + if (seconds !== 0) { + finalString += seconds; + finalString += `${seconds === 1 ? getMessage(language, "time.second") : getMessage(language, "time.secondPlural")}` + } + return finalString + } +} diff --git a/util/lang/en-US.json b/util/lang/en-US.json new file mode 100644 index 0000000..75aa02f --- /dev/null +++ b/util/lang/en-US.json @@ -0,0 +1,86 @@ +{ + "time.week": " week ", + "time.weekPlural": " weeks ", + "time.day": " day ", + "time.dayPlural": " days ", + "time.hour": " hour ", + "time.hourPlural": " hours ", + "time.minute": " minute ", + "time.minutePlural": " minutes ", + "time.second": " second ", + "time.secondPlural": " seconds ", + "command.about.usage": "", + "command.about.desc": "About the bot", + "command.cb.usage": " ", + "command.cb.desc": "Run a command in a command block", + "command.cloop.usage": " add || remove || list|| clear", + "command.cloop.desc": "Manage command loops", + "command.eval.usage": " ", + "command.eval.desc": "Run JavaScript code", + "command.help.usage": " [cmd]", + "command.help.desc": "Shows command help", + "command.logoff.usage": "", + "command.logoff.desc": "Disconnect and reconnect the bot from a server", + "command.netmsg.usage": " ", + "command.netmsg.desc": "Send a message to all servers the bot is connected to", + "command.refill.usage": "", + "command.refill.desc": "Refill core", + "command.say.usage": " ", + "command.say.desc": "Sends a message to chat", + "command.serverinfo.usage": "", + "command.serverinfo.desc": "Get system/bot info", + "command.stop.usage": "", + "command.stop.desc": "Restart bot", + "command.template.usage": " [optional]", + "command.template.desc": "Does nothing", + "command.tpr.desc": "Teleport to a random location", + "command.tpr.usage": "", + "command.verify.usage": " [args...]", + "command.verify.desc": "Check the hashing system", + "command.about.author": "%s - a Minecraft bot made by 77c8f4699b732c11 / a5a06d596f15c7db", + "command.about.version": "Version %s", + "command.about.sourceCode": "Source code: %s", + "command.about.serverinfo": "To view system information, run the command %s.", + "command.cloop.error.tooShort": "Command loops must have a rate above 20ms.", + "command.cloop.error.subcommand": "Unknown subcommand, please do %s", + "command.cloop.success.add": "Added command loop with command %s and rate %s", + "command.cloop.success.remove": "Removed command loop %s", + "command.cloop.success.clear": "Cleared all command loops", + "command.cloop.list": "%s: Command: %s Rate: %s", + "command.help.cmdList": "Commands:", + "command.help.commandInfo": "%s%s - %s", + "command.help.commandUsage": "Usage - %s%s", + "command.help.commandDesc": "Description - %s", + "command.help.commandPerms": "Required permissions - %s", + "command.help.permsNormal": "Normal", + "command.help.permsTrusted": "Trusted", + "command.help.permsOwner": "Owner", + "command.help.permsConsole": "Console", + "command.help.noCommand": "Command does not exist", + "command.serverinfo.os.android": "Android", + "command.serverinfo.os.freebsd": "FreeBSD", + "command.serverinfo.os.linux": "Linux %s", + "command.serverinfo.os.macos": "macOS", + "command.serverinfo.os.macos_old": "OS X", + "command.serverinfo.os": "Operating system", + "command.serverinfo.processor": "CPU", + "command.serverinfo.arch": "Architecture", + "command.serverinfo.osUsername": "Username", + "command.serverinfo.hostName": "Hostname", + "command.serverinfo.workingDir": "Working directory", + "command.serverinfo.runTime": "Bot uptime", + "command.serverinfo.upTime": "System uptime", + "command.serverinfo.nodeVersion": "Node.js version", + "command.serverinfo.osRelease": "Linux release", + "command.serverinfo.osRelease.missing": "/etc/os-release does not exist. Information may be limited.", + "command.serverinfo.os.android.version": "Android version", + "command.serverinfo.os.android.model": "Device model", + "command.serverinfo.botName": "Bot name", + "command.serverinfo.botVer": "Bot version", + "command.tpr.success": "Teleporting %s to %s, %s, %s", + "command.error": "An error occured (check console for more info)", + "command.disallowed.perms": "You do not have permission to run this command. If you do have permission, please make sure you put the command hash at the end, or ran the command through your client's hashing system.", + "command.disallowed.perms.yourLevel": "Your permission level: %s", + "command.disallowed.perms.cmdLevel": "Command requires: %s", + "copyText": "Click to copy!" +} diff --git a/util/lang/en-UW.json b/util/lang/en-UW.json new file mode 100644 index 0000000..25e081e --- /dev/null +++ b/util/lang/en-UW.json @@ -0,0 +1,86 @@ +{ + "time.week": " week ", + "time.weekPlural": " weeks ", + "time.day": " day ", + "time.dayPlural": " days ", + "time.hour": " houw ", + "time.hourPlural": " houws ", + "time.minute": " minyute ", + "time.minutePlural": " minyutes ", + "time.second": " second ", + "time.secondPlural": " seconds ", + "command.about.usage": "", + "command.about.desc": "About the bot", + "command.cb.usage": " ", + "command.cb.desc": "Wun a command in a command bwock", + "command.cloop.usage": " add || remove || list|| clear", + "command.cloop.desc": "Manage command woops", + "command.eval.usage": " ", + "command.eval.desc": "Wun JavaScwipt code", + "command.help.usage": " [cmd]", + "command.help.desc": "Shows command hewp", + "command.logoff.usage": "", + "command.logoff.desc": "Disconnyect and weconnyect the bot fwom a sewvew", + "command.netmsg.usage": " ", + "command.netmsg.desc": "Send a message to aww sewvews the bot is connyected to", + "command.refill.usage": "", + "command.refill.desc": "Wefiww cowe", + "command.say.usage": " ", + "command.say.desc": "Sends a message to chat", + "command.serverinfo.usage": "", + "command.serverinfo.desc": "Get system/bot info", + "command.stop.usage": "", + "command.stop.desc": "Westawt bot", + "command.template.usage": " [optionyaw]", + "command.template.desc": "Does nyothing", + "command.tpr.desc": "Tewepowt to a wandom wocation", + "command.tpr.usage": "", + "command.verify.usage": " [awgs...]", + "command.verify.desc": "Check the hashing system", + "command.about.author": "%s - a Minyecwaft bot made by 77c8f4699b732c11 / a5a06d596f15c7db", + "command.about.version": "Vewsion %s", + "command.about.sourceCode": "Souwce code: %s", + "command.about.serverinfo": "To view system infowmation, wun the command %s.", + "command.cloop.error.tooShort": "Command woops must have a wate above 20ms.", + "command.cloop.error.subcommand": "Unknyown subcommand, pwease do %s", + "command.cloop.success.add": "Added command woop with command %s and wate %s", + "command.cloop.success.remove": "Wemoved command woop %s", + "command.cloop.success.clear": "Cweawed aww command woops", + "command.cloop.list": "%s: Command: %s Rate: %s", + "command.help.cmdList": "Commands:", + "command.help.commandInfo": "%s%s - %s", + "command.help.commandUsage": "Usage - %s%s", + "command.help.commandDesc": "Descwiption - %s", + "command.help.commandPerms": "Wequiwed pewmissions - %s", + "command.help.permsNormal": "Nyowmaw", + "command.help.permsTrusted": "Twusted", + "command.help.permsOwner": "Ownyew", + "command.help.permsConsole": "Consowe", + "command.help.noCommand": "Command does nyot exist", + "command.serverinfo.os.android": "Andwoid", + "command.serverinfo.os.freebsd": "FweeBSD", + "command.serverinfo.os.linux": "Winyux %s", + "command.serverinfo.os.macos": "macOS", + "command.serverinfo.os.macos_old": "OS X", + "command.serverinfo.os": "Opewating system", + "command.serverinfo.processor": "CPU", + "command.serverinfo.arch": "Awchitectuwe", + "command.serverinfo.osUsername": "Usewnyame", + "command.serverinfo.hostName": "Hostnyame", + "command.serverinfo.workingDir": "Wowking diwectowy", + "command.serverinfo.runTime": "Bot uptime", + "command.serverinfo.upTime": "System uptime", + "command.serverinfo.nodeVersion": "Nyode.js vewsion", + "command.serverinfo.osRelease": "Winyux wewease", + "command.serverinfo.osRelease.missing": "/etc/os-release does nyot exist. Infowmation may be wimited.", + "command.serverinfo.os.android.version": "Andwoid vewsion", + "command.serverinfo.os.android.model": "Device modew", + "command.serverinfo.botName": "Bot nyame", + "command.serverinfo.botVer": "Bot vewsion", + "command.tpr.success": "Tewepowting %s to %s, %s, %s", + "command.error": "An ewwow occuwed (check consowe fow mowe info)", + "command.disallowed.perms": "You do nyot have pewmission to wun this command. If you do have pewmission, pwease make suwe you put the command hash at the end, ow wan the command thwough youw cwient's hashing system.", + "command.disallowed.perms.yourLevel": "Youw pewmission wevew: %s", + "command.disallowed.perms.cmdLevel": "Command wequiwes: %s", + "copyText": "Cwick to copy!" +} diff --git a/util/textformat.js b/util/textformat.js new file mode 100644 index 0000000..89bb3a7 --- /dev/null +++ b/util/textformat.js @@ -0,0 +1,17 @@ +const settings = require('../settings.json') +module.exports = function (text) { + return JSON.stringify({ + translate: '[%s] %s', + color: '#FFAAFF', + with: [ + { + text: settings.name, + color: 'light_purple' + }, + { + text, + color: 'white' + } + ] + }) +} diff --git a/util/usergen.js b/util/usergen.js new file mode 100644 index 0000000..ce845c3 --- /dev/null +++ b/util/usergen.js @@ -0,0 +1,38 @@ +const rsg = function (count) { + let output = '' + for (let i = 0; i < count; i++) { + const type = Math.floor(Math.random() * 6) + switch (type) { + case 0: + output += ' ' + break + case 1: + output += '§§' + break + case 2: + output += '§ ' + break + case 3: + case 4: + case 5:{ // Make this case more likely + let rng = Math.floor(Math.random() * 16) + 1 + if (rng === 7) rng = 17 // No bells + if (rng === 10) rng = 18 // No line feeds + if (rng === 11) rng = 19 // No vertical tabulations + if (rng === 12) rng = 20 // No form feed + if (rng === 13) rng = 21 // No carriage returns + if (rng === 14) rng = 22 // No shift out + if (rng === 15) rng = 23 // No shift in + output += `§${String.fromCharCode(rng)}` + } + } + } + return output +} +module.exports = function (legal) { + if (legal) { + return Math.floor(Math.random() * 1000000).toString() + } else { + return rsg(6 + Math.floor(Math.random() * 3)) + } +} diff --git a/util/uuidtoint.js b/util/uuidtoint.js new file mode 100644 index 0000000..4807ce8 --- /dev/null +++ b/util/uuidtoint.js @@ -0,0 +1,5 @@ +module.exports = function (uuid) { + const splitUUID = uuid.replace(/[^0-9a-f]/g, '').replace(/.{1,8}/g, a => { return '0x' + a }).match(/.{1,10}/g) + const numUUID = [+splitUUID[0] << 0, +splitUUID[1] << 0, +splitUUID[2] << 0, +splitUUID[3] << 0] + return numUUID +} diff --git a/version.json b/version.json new file mode 100644 index 0000000..4ad5b1a --- /dev/null +++ b/version.json @@ -0,0 +1,5 @@ +{ + "botName": "botvX Dev", + "botVersion": "10.0.0-beta.1", + "sourceURL": "https://code.chipmunk.land/7cc5c4f330d47060/botvX" +} From 9f99a1bbf1a3b22377b16e224dd20db10ec2b4ab Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 30 Jul 2024 15:40:28 -0400 Subject: [PATCH 232/362] Add error handler to this for some reason I got a maximum call stack size exceeded error in this code... --- util/chatparse_1204.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/util/chatparse_1204.js b/util/chatparse_1204.js index 3add56e..e706232 100644 --- a/util/chatparse_1204.js +++ b/util/chatparse_1204.js @@ -8,4 +8,14 @@ const parse = function (data) { return data } } +const parse2 = function (_data) { + try { + return parse(_data) + } catch (e) { + console.error(e) + return { + text: 'An error occured while parsing a message. See console for more information.' + } + } +} module.exports = parse From 93c48357288dad71a8b4ee3e020526ae5b0a3287 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 30 Jul 2024 17:14:41 -0400 Subject: [PATCH 233/362] Add support for 8/4 bit color and white terminals --- plugins/console.js | 2 +- util/chatparse.js | 43 +++++----- util/consolecolors.json | 182 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 203 insertions(+), 24 deletions(-) create mode 100644 util/consolecolors.json diff --git a/plugins/console.js b/plugins/console.js index 367871c..83d43da 100644 --- a/plugins/console.js +++ b/plugins/console.js @@ -5,7 +5,7 @@ const newercommands = require('./command.js').cmds const rl = readln.createInterface({ input: process.stdin, output: process.stdout, - prompt: '\x1b[0m\x1b[38;5;15m> ' + prompt: '\x1b[0m> ' }) rl.on('line', (l) => { try { diff --git a/util/chatparse.js b/util/chatparse.js index d9a5e60..1e4c145 100644 --- a/util/chatparse.js +++ b/util/chatparse.js @@ -1,36 +1,33 @@ -const _lang = require('minecraft-data')('1.20.2').language +const _lang = require('minecraft-data')('1.20.2').language; +const settings = require('../settings.json'); const lang = Object.create(null) // Without constructor function for (const i in _lang) { lang[i] = _lang[i] } -const consoleColors = { - dark_red: '\x1B[0m\x1B[38;2;170;0;0m', - red: '\x1B[0m\x1B[38;2;255;85;85m', - dark_green: '\x1B[0m\x1B[38;2;0;170;0m', - green: '\x1B[0m\x1B[38;2;85;255;85m', - gold: '\x1B[0m\x1B[38;2;255;170;0m', - yellow: '\x1B[0m\x1B[38;2;255;255;85m', - dark_blue: '\x1B[0m\x1B[38;2;0;0;170m', - blue: '\x1B[0m\x1B[38;2;85;85;255m', - dark_purple: '\x1B[0m\x1B[38;2;170;0;170m', - light_purple: '\x1B[0m\x1B[38;2;255;85;255m', - dark_aqua: '\x1B[0m\x1B[38;2;0;170;170m', - aqua: '\x1B[0m\x1B[38;2;85;255;255m', - black: '\x1B[0m\x1B[48;2;220;220;220m\x1B[38;2;0;0;0m', - gray: '\x1B[0m\x1B[38;2;170;170;170m', - dark_gray: '\x1B[0m\x1B[38;2;85;85;85m', - white: '\x1B[0m\x1B[38;2;255;255;255m', - reset: '\x1B[0m\x1B[38;2;255;255;255m' +const _consoleColors = require("./consolecolors.json"); +let consoleColors; +let consoleColors24; +if(_consoleColors[settings.terminalMode]){ + consoleColors=_consoleColors[settings.terminalMode].fourBit + consoleColors24=_consoleColors[settings.terminalMode].twentyFourBit +} else { + consoleColors=_consoleColors.none.fourBit + consoleColors24=_consoleColors.none.twentyFourBit } const hexColorParser = (color) => { - let out = '\x1B[0m' + if(!consoleColors24.enabled || consoleColors24.bit!==24){ //Non-24bit hex color parsing is not implemented yet + return ""; + } + let out = '\x1B[0;' const redChannel = Number('0x' + color.slice(1, 3)) const greenChannel = Number('0x' + color.slice(3, 5)) const blueChannel = Number('0x' + color.slice(5, 7)) - if (redChannel < 96 && greenChannel < 96 && blueChannel < 96) { - out += '\x1B[48;2;220;220;220m' + if (!consoleColors24.lightMode && redChannel < 64 && greenChannel < 64 && blueChannel < 64) { + out += '48;2;220;220;220;' + } else if (consoleColors24.lightMode && ((redChannel > 192 && greenChannel > 192 && blueChannel > 192) || greenChannel > 160)) { + out += '48;2;0;0;0;' } - return out + `\x1B[38;2;${redChannel};${greenChannel};${blueChannel}m` + return out + `38;2;${redChannel};${greenChannel};${blueChannel}m` } const processColor = (col, rcol) => { const out = ['', ''] diff --git a/util/consolecolors.json b/util/consolecolors.json new file mode 100644 index 0000000..0370261 --- /dev/null +++ b/util/consolecolors.json @@ -0,0 +1,182 @@ +{ + "blackTerminal_24bit":{ + "fourBit":{ + "dark_red": "\u001B[0m\u001B[38;2;170;0;0m", + "red": "\u001B[0m\u001B[38;2;255;85;85m", + "dark_green": "\u001B[0m\u001B[38;2;0;170;0m", + "green": "\u001B[0m\u001B[38;2;85;255;85m", + "gold": "\u001B[0m\u001B[38;2;255;170;0m", + "yellow": "\u001B[0m\u001B[38;2;255;255;85m", + "dark_blue": "\u001B[0m\u001B[38;2;0;0;170m", + "blue": "\u001B[0m\u001B[38;2;85;85;255m", + "dark_purple": "\u001B[0m\u001B[38;2;170;0;170m", + "light_purple": "\u001B[0m\u001B[38;2;255;85;255m", + "dark_aqua": "\u001B[0m\u001B[38;2;0;170;170m", + "aqua": "\u001B[0m\u001B[38;2;85;255;255m", + "black": "\u001B[0m\u001B[48;2;220;220;220m\u001B[38;2;0;0;0m", + "gray": "\u001B[0m\u001B[38;2;170;170;170m", + "dark_gray": "\u001B[0m\u001B[38;2;85;85;85m", + "white": "\u001B[0m\u001B[38;2;255;255;255m", + "reset": "\u001B[0m\u001B[38;2;255;255;255m" + }, + "twentyFourBit":{ + "enabled": true, + "bit": 24, + "lightMode": false + } + }, + "whiteTerminal_24bit":{ + "fourBit":{ + "dark_red": "\u001B[0m\u001B[38;2;170;0;0m", + "red": "\u001B[0m\u001B[38;2;255;85;85m", + "dark_green": "\u001B[0m\u001B[38;2;0;170;0m", + "green": "\u001B[0m\u001B[48;2;20;20;20m\u001B[38;2;85;255;85m", + "gold": "\u001B[0m\u001B[38;2;255;170;0m", + "yellow": "\u001B[0m\u001B[48;2;20;20;20m\u001B[38;2;255;255;85m", + "dark_blue": "\u001B[0m\u001B[38;2;0;0;170m", + "blue": "\u001B[0m\u001B[38;2;85;85;255m", + "dark_purple": "\u001B[0m\u001B[38;2;170;0;170m", + "light_purple": "\u001B[0m\u001B[38;2;255;85;255m", + "dark_aqua": "\u001B[0m\u001B[38;2;0;170;170m", + "aqua": "\u001B[0m\u001B[48;2;20;20;20m\u001B[38;2;85;255;255m", + "black": "\u001B[0m\u001B[38;2;0;0;0m", + "gray": "\u001B[0m\u001B[38;2;170;170;170m", + "dark_gray": "\u001B[0m\u001B[38;2;85;85;85m", + "white": "\u001B[0m\u001B[48;2;20;20;20m\u001B[38;2;255;255;255m", + "reset": "\u001B[0m\u001B[48;2;20;20;20m\u001B[38;2;255;255;255m" + }, + "twentyFourBit":{ + "enabled": true, + "bit": 24, + "lightMode": true + } + }, + "blackTerminal_8bit":{ + "fourBit":{ + "dark_red": "\u001B[0m\u001B[38;5;1m", + "red": "\u001B[0m\u001B[38;5;9m", + "dark_green": "\u001B[0m\u001B[38;5;2m", + "green": "\u001B[0m\u001B[38;5;10m", + "gold": "\u001B[0m\u001B[38;5;3m", + "yellow": "\u001B[0m\u001B[38;5;11m", + "dark_blue": "\u001B[0m\u001B[38;5;4m", + "blue": "\u001B[0m\u001B[38;5;12m", + "dark_purple": "\u001B[0m\u001B[38;5;5m", + "light_purple": "\u001B[0m\u001B[38;5;13m", + "dark_aqua": "\u001B[0m\u001B[38;5;6m", + "aqua": "\u001B[0m\u001B[38;5;14m", + "black": "\u001B[0m\u001B[48;5;15m\u001B[38;5;0m", + "gray": "\u001B[0m\u001B[38;5;7m", + "dark_gray": "\u001B[0m\u001B[38;5;8m", + "white": "\u001B[0m\u001B[38;5;15m", + "reset": "\u001B[0m\u001B[38;5;15m" + }, + "twentyFourBit":{ + "enabled": true, + "bit": 8, + "lightMode": false + } + }, + "whiteTerminal_8bit":{ + "fourBit":{ + "dark_red": "\u001B[0m\u001B[38;5;1m", + "red": "\u001B[0m\u001B[38;5;9m", + "dark_green": "\u001B[0m\u001B[38;5;2m", + "green": "\u001B[0m\u001B[48;5;0m\u001B[38;5;10m", + "gold": "\u001B[0m\u001B[38;5;3m", + "yellow": "\u001B[0m\u001B[48;5;0m\u001B[38;5;11m", + "dark_blue": "\u001B[0m\u001B[38;5;4m", + "blue": "\u001B[0m\u001B[38;5;12m", + "dark_purple": "\u001B[0m\u001B[38;5;5m", + "light_purple": "\u001B[0m\u001B[38;5;13m", + "dark_aqua": "\u001B[0m\u001B[38;5;6m", + "aqua": "\u001B[0m\u001B[48;5;0m\u001B[38;5;14m", + "black": "\u001B[0m\u001B[38;5;0m", + "gray": "\u001B[0m\u001B[38;5;7m", + "dark_gray": "\u001B[0m\u001B[38;5;8m", + "white": "\u001B[0m\u001B[48;5;0m\u001B[38;5;15m", + "reset": "\u001B[0m\u001B[48;5;0m\u001B[38;5;15m" + }, + "twentyFourBit":{ + "enabled": true, + "bit": 8, + "lightMode": true + } + }, + "blackTerminal_4bit":{ + "fourBit":{ + "dark_red": "\u001B[0m\u001B[31m", + "red": "\u001B[0m\u001B[1;31m", + "dark_green": "\u001B[0m\u001B[32m", + "green": "\u001B[0m\u001B[1;32m", + "gold": "\u001B[0m\u001B[33m", + "yellow": "\u001B[0m\u001B[1;33m", + "dark_blue": "\u001B[0m\u001B[34m", + "blue": "\u001B[0m\u001B[1;34m", + "dark_purple": "\u001B[0m\u001B[35m", + "light_purple": "\u001B[0m\u001B[1;35m", + "dark_aqua": "\u001B[0m\u001B[36m", + "aqua": "\u001B[0m\u001B[1;36m", + "black": "\u001B[0m\u001B[0;1;47m\u001B[0;30m", + "gray": "\u001B[0m\u001B[0;37m", + "dark_gray": "\u001B[0m\u001B[0;1;30m", + "white": "\u001B[0m\u001B[0;1;37m", + "reset": "\u001B[0m\u001B[0;1;37m" + }, + "twentyFourBit":{ + "enabled": true, + "bit": 4, + "lightMode": false + } + }, + "whiteTerminal_4bit":{ + "fourBit":{ + "dark_red": "\u001B[0m\u001B[31m", + "red": "\u001B[0m\u001B[1;31m", + "dark_green": "\u001B[0m\u001B[32m", + "green": "\u001B[0m\u001B[0;40m\u001B[1;32m", + "gold": "\u001B[0m\u001B[33m", + "yellow": "\u001B[0m\u001B[0;40m\u001B[1;33m", + "dark_blue": "\u001B[0m\u001B[34m", + "blue": "\u001B[0m\u001B[1;34m", + "dark_purple": "\u001B[0m\u001B[35m", + "light_purple": "\u001B[0m\u001B[1;35m", + "dark_aqua": "\u001B[0m\u001B[36m", + "aqua": "\u001B[0m\u001B[0;40m\u001B[1;36m", + "black": "\u001B[0m\u001B[0;30m", + "gray": "\u001B[0m\u001B[0;37m", + "dark_gray": "\u001B[0m\u001B[0;1;30m", + "white": "\u001B[0m\u001B[0;40m\u001B[1;37m", + "reset": "\u001B[0m\u001B[0;40m\u001B[1;37m" + }, + "twentyFourBit":{ + "enabled": true, + "bit": 4, + "lightMode": true + } + }, + "none":{ + "fourBit":{ + "dark_red": "", + "red": "", + "dark_green": "", + "green": "", + "gold": "", + "yellow": "", + "dark_blue": "", + "blue": "", + "dark_purple": "", + "light_purple": "", + "dark_aqua": "", + "aqua": "", + "black": "", + "gray": "", + "dark_gray": "", + "white": "", + "reset": "" + }, + "twentyFourBit":{ + "enabled": false + } + } +} \ No newline at end of file From 4c99aa3d4b4fb40c2f1e947e78c8b58d98ea033d Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 30 Jul 2024 17:17:30 -0400 Subject: [PATCH 234/362] BugFix white terminal --- plugins/!chat.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/!chat.js b/plugins/!chat.js index 00423d8..acc2e34 100755 --- a/plugins/!chat.js +++ b/plugins/!chat.js @@ -83,7 +83,7 @@ module.exports = { if (msg[1].endsWith('\n\n\n\n\nThe chat has been cleared')) return if (msg[1].startsWith('Command set: ')) return b.emit('plainchat', msg[1]) - console2.write(`[${b.id}] [${data.type}] ` + msg[0]) + console2.write(`[${b.id}] [${data.type}] ${msg[0]}\x1b[0m`) const fullCommand = data.message for (const i in b.prefix) { From c3fa4ae039a4d594dc9848883d7a8de11c744696 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 30 Jul 2024 18:11:47 -0400 Subject: [PATCH 235/362] Bugfixes --- plugins/!chat.js | 22 +++++++------- plugins/player.js | 6 ++-- util/ConsoleCommand.js | 2 +- util/chatparse.js | 69 ++++++++++++++++++++++-------------------- 4 files changed, 51 insertions(+), 48 deletions(-) diff --git a/plugins/!chat.js b/plugins/!chat.js index acc2e34..6d1a4a6 100755 --- a/plugins/!chat.js +++ b/plugins/!chat.js @@ -16,7 +16,7 @@ module.exports = { b._client.on('profileless_chat', (data) => { if (data.type === 4) { const json = parse1204(data.message) - const parsed = parse(json)[1] + const parsed = parse(json).plain const split = parsed.split(': ') const chatName = split.splice(0, 1)[0] const username = b.findRealName(chatName) @@ -34,15 +34,15 @@ module.exports = { }, type: 'profileless', uuid: '00000000-0000-0000-0000-000000000000', - message: parse(parse1204(data.message))[1], - username: parse(parse1204(data.name))[1] + message: parse(parse1204(data.message)).plain, + username: parse(parse1204(data.name)).plain }) } }) b._client.on('player_chat', (data) => { if (data.type === 4) { - b.emit('chat', { json: parse1204(data.unsignedChatContent), type: 'player', uuid: data.senderUuid, message: data.plainMessage, username: parse(parse1204(data.networkName))[1] }) + b.emit('chat', { json: parse1204(data.unsignedChatContent), type: 'player', uuid: data.senderUuid, message: data.plainMessage, username: parse(parse1204(data.networkName)).plain }) } else { b.emit('chat', { json: { @@ -55,14 +55,14 @@ module.exports = { }, type: 'player', uuid: data.senderUuid, - message: parse(data.plainMessage)[1], - username: parse(parse1204(data.networkName))[1] + message: parse(data.plainMessage).plain, + username: parse(parse1204(data.networkName)).plain }) } }) b._client.on('system_chat', (data) => { const json = parse1204(data.content) - const parsed = parse(json)[1] + const parsed = parse(json).plain const split = parsed.split(': ') const chatName = split.splice(0, 1)[0] const username = b.findRealName(chatName) @@ -80,10 +80,10 @@ module.exports = { }) b.on('chat', (data) => { const msg = parse(data.json) - if (msg[1].endsWith('\n\n\n\n\nThe chat has been cleared')) return - if (msg[1].startsWith('Command set: ')) return - b.emit('plainchat', msg[1]) - console2.write(`[${b.id}] [${data.type}] ${msg[0]}\x1b[0m`) + if (msg.plain.endsWith('\n\n\n\n\nThe chat has been cleared')) return + if (msg.plain.startsWith('Command set: ')) return + b.emit('plainchat', msg.plain) + console2.write(`[${b.id}] [${data.type}] ${msg.console}\x1b[0m`) const fullCommand = data.message for (const i in b.prefix) { diff --git a/plugins/player.js b/plugins/player.js index c18d37b..5b09619 100644 --- a/plugins/player.js +++ b/plugins/player.js @@ -13,11 +13,11 @@ module.exports = { uuid = data.data[i].UUID } if (data.data[i].player && data.data[i].player.name !== undefined) { - buffer2[uuid] = { realName: data.data[i].player.name, displayName: parse(parse1204(data.data[i].displayName))[1] } + buffer2[uuid] = { realName: data.data[i].player.name, displayName: parse(parse1204(data.data[i].displayName)).plain } } else if (data.data[i].name !== undefined) { - buffer2[uuid] = { realName: data.data[i].name, displayName: parse(parse1204(data.data[i].displayName))[1] } + buffer2[uuid] = { realName: data.data[i].name, displayName: parse(parse1204(data.data[i].displayName)).plain } } else if (data.data[i].displayName !== undefined) { - buffer2[uuid] = { displayName: parse(parse1204(data.data[i].displayName))[1] } + buffer2[uuid] = { displayName: parse(parse1204(data.data[i].displayName)).plain } } } for (const uuid in buffer2) { diff --git a/util/ConsoleCommand.js b/util/ConsoleCommand.js index a724f0e..0091eb4 100644 --- a/util/ConsoleCommand.js +++ b/util/ConsoleCommand.js @@ -8,7 +8,7 @@ const lang = settings.defaultLang class ConsoleCommand { constructor (cmd, index2) { this.send = () => {} // not needed for console - this.reply = text => process.stdout.write(parse(text)[0] + '\n') + this.reply = text => process.stdout.write(parse(text).console + '\n') this.uuid = 'dde5a2a6-ebdd-4bbb-8eac-f75b10c10446_console' // hard-coded because uuid does not exist at console this.username = 'Owner' this.nickname = 'Console' diff --git a/util/chatparse.js b/util/chatparse.js index 1e4c145..9e357be 100644 --- a/util/chatparse.js +++ b/util/chatparse.js @@ -30,17 +30,17 @@ const hexColorParser = (color) => { return out + `38;2;${redChannel};${greenChannel};${blueChannel}m` } const processColor = (col, rcol) => { - const out = ['', ''] + let out; if (col === 'reset') { - out[0] = rcol[0] + out = rcol } else if (col.startsWith('#')) { - out[0] = hexColorParser(col) + out = hexColorParser(col) } else { - out[0] = consoleColors[col] + out = consoleColors[col] } return out } -const parse = function (_data, l = 0, resetColor = [consoleColors.reset]) { +const parse = function (_data, l = 0, resetColor = consoleColors.reset) { if (l >= 12) { return ['', '', ''] } @@ -55,21 +55,25 @@ const parse = function (_data, l = 0, resetColor = [consoleColors.reset]) { data = _data } let nkt = false - const out = ['', '', ''] // console plain minecraft + const out = { + console: "", // Console formatting using ANSI escape codes for colors + plain: "", // Plain formatting with no colors + minecraft: "" // Minecraft section sign formatting + } if (data['']) { data.text = data[''] nkt = true } if (data.color) { if (data.color === 'reset') { - out[0] += resetColor[0] + out.console += resetColor } else if (data.color.startsWith('#')) { - out[0] += hexColorParser(data.color) + out.console += hexColorParser(data.color) } else { - out[0] += consoleColors[data.color] + out.console += consoleColors[data.color] } } else { - out[0] += resetColor[0] + out.console += resetColor } if (data.text) { let _text = data.text @@ -77,12 +81,11 @@ const parse = function (_data, l = 0, resetColor = [consoleColors.reset]) { _text = _text.toString() } if (nkt) { - out[0] += resetColor[0] - out[2] += resetColor[1] + out.console += resetColor } - out[0] += _text.replaceAll('\x1b', '').replaceAll('\x0e', '') // Remove escape codes and [SO] from console format - out[1] += _text - out[2] += _text + out.console += _text.replaceAll('\x1b', '').replaceAll('\x0e', '') // Remove escape codes and [SO] from console format + out.plain += _text + out.minecraft += _text } if (data.translate) { let trans = data.translate.replace(/%%/g, '\ue123').replaceAll('\x1b', '').replaceAll('\x0e', '') // Remove escape codes from console format @@ -95,26 +98,26 @@ const parse = function (_data, l = 0, resetColor = [consoleColors.reset]) { } for (const i in data.with) { const j2 = parse(data.with[i], l + 1, data.color ? processColor(data.color, resetColor) : resetColor) - trans = trans.replace(/%s/, j2[0].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) - trans2 = trans2.replace(/%s/, j2[1].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) - trans3 = trans3.replace(/%s/, j2[2].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) - trans = trans.replaceAll(`%${+i + 1}$s`, j2[0].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) - trans2 = trans2.replaceAll(`%${+i + 1}$s`, j2[1].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) - trans3 = trans3.replaceAll(`%${+i + 1}$s`, j2[2].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + trans = trans.replace(/%s/, j2.console.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + trans2 = trans2.replace(/%s/, j2.plain.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + trans3 = trans3.replace(/%s/, j2.minecraft.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + trans = trans.replaceAll(`%${+i + 1}$s`, j2.console.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + trans2 = trans2.replaceAll(`%${+i + 1}$s`, j2.plain.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + trans3 = trans3.replaceAll(`%${+i + 1}$s`, j2.minecraft.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) } - out[0] += trans.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s') - out[1] += trans2.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s') - out[2] += trans3.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s') + out.console += trans.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s') + out.plain += trans2.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s') + out.minecraft += trans3.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s') } if (data.extra) { for (const i in data.extra) { const parsed = parse(data.extra[i], l, data.color ? processColor(data.color, resetColor) : resetColor) - out[0] += parsed[0] - out[1] += parsed[1] - out[2] += parsed[2] + out.console += parsed.console + out.plain += parsed.plain + out.minecraft += parsed.minecraft } } - out[0] += resetColor[0] + out.console += resetColor return out } const parse2 = function (_data, l, resetColor) { @@ -122,11 +125,11 @@ const parse2 = function (_data, l, resetColor) { return parse(_data) } catch (e) { console.error(e) - return [ - '\x1B[0m\x1B[38;2;255;85;85mAn error occured while parsing a message. See console for more information.\nJSON that caused the error: ' + JSON.stringify(_data), - 'An error occured while parsing a message. See console for more information. JSON that caused the error: ' + JSON.stringify(_data), - '§cAn error occured while parsing a message. See console for more information. JSON that caused the error: ' + JSON.stringify(_data) - ] + return { + console: '\x1B[0m\x1B[38;2;255;85;85mAn error occured while parsing a message. See console for more information.\nJSON that caused the error: ' + JSON.stringify(_data), + plain: 'An error occured while parsing a message. See console for more information. JSON that caused the error: ' + JSON.stringify(_data), + minecraft: '§cAn error occured while parsing a message. See console for more information. JSON that caused the error: ' + JSON.stringify(_data) + } } } module.exports = parse2 From 5b77fae298aa79593774def5965f883234017d3b Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 30 Jul 2024 18:13:27 -0400 Subject: [PATCH 236/362] Remove unused and un-implemented Minecraft format --- util/chatparse.js | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/util/chatparse.js b/util/chatparse.js index 9e357be..513d155 100644 --- a/util/chatparse.js +++ b/util/chatparse.js @@ -57,8 +57,7 @@ const parse = function (_data, l = 0, resetColor = consoleColors.reset) { let nkt = false const out = { console: "", // Console formatting using ANSI escape codes for colors - plain: "", // Plain formatting with no colors - minecraft: "" // Minecraft section sign formatting + plain: "" // Plain formatting with no colors } if (data['']) { data.text = data[''] @@ -85,7 +84,6 @@ const parse = function (_data, l = 0, resetColor = consoleColors.reset) { } out.console += _text.replaceAll('\x1b', '').replaceAll('\x0e', '') // Remove escape codes and [SO] from console format out.plain += _text - out.minecraft += _text } if (data.translate) { let trans = data.translate.replace(/%%/g, '\ue123').replaceAll('\x1b', '').replaceAll('\x0e', '') // Remove escape codes from console format @@ -100,21 +98,17 @@ const parse = function (_data, l = 0, resetColor = consoleColors.reset) { const j2 = parse(data.with[i], l + 1, data.color ? processColor(data.color, resetColor) : resetColor) trans = trans.replace(/%s/, j2.console.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) trans2 = trans2.replace(/%s/, j2.plain.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) - trans3 = trans3.replace(/%s/, j2.minecraft.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) trans = trans.replaceAll(`%${+i + 1}$s`, j2.console.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) trans2 = trans2.replaceAll(`%${+i + 1}$s`, j2.plain.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) - trans3 = trans3.replaceAll(`%${+i + 1}$s`, j2.minecraft.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) } out.console += trans.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s') out.plain += trans2.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s') - out.minecraft += trans3.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s') } if (data.extra) { for (const i in data.extra) { const parsed = parse(data.extra[i], l, data.color ? processColor(data.color, resetColor) : resetColor) out.console += parsed.console out.plain += parsed.plain - out.minecraft += parsed.minecraft } } out.console += resetColor @@ -127,8 +121,7 @@ const parse2 = function (_data, l, resetColor) { console.error(e) return { console: '\x1B[0m\x1B[38;2;255;85;85mAn error occured while parsing a message. See console for more information.\nJSON that caused the error: ' + JSON.stringify(_data), - plain: 'An error occured while parsing a message. See console for more information. JSON that caused the error: ' + JSON.stringify(_data), - minecraft: '§cAn error occured while parsing a message. See console for more information. JSON that caused the error: ' + JSON.stringify(_data) + plain: 'An error occured while parsing a message. See console for more information. JSON that caused the error: ' + JSON.stringify(_data) } } } From 5ab32db8d5445a94531d8612b931a0c855837675 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Wed, 31 Jul 2024 00:24:00 -0400 Subject: [PATCH 237/362] Fix legacy chat --- plugins/!chat.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/!chat.js b/plugins/!chat.js index 6d1a4a6..385c2e8 100755 --- a/plugins/!chat.js +++ b/plugins/!chat.js @@ -71,7 +71,7 @@ module.exports = { }) b._client.on('chat', (data) => { // Legacy chat const json = parse1204(data.message) - const parsed = parse(json)[1] + const parsed = parse(json).plain const split = parsed.split(': ') const chatName = split.splice(0, 1)[0] const username = b.findRealName(chatName) From 83fc1d169dc73d87ff1fc54cec038458365bf357 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Wed, 31 Jul 2024 00:24:13 -0400 Subject: [PATCH 238/362] Add per-server version override in settings --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index a69c8d2..161c7ed 100755 --- a/index.js +++ b/index.js @@ -36,7 +36,7 @@ const createBot = function createBot (host, oldId) { host: host.host, port: host.port ? host.port : 25565, username: generateUser(host.options.legalName), - version: settings.version_mc + version: host.version?host.version:settings.version_mc }) bot._client.on('success', () => { }) From 5b8f9852a0c2ed2aaf2dfc8066812c800fdb3506 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Wed, 31 Jul 2024 00:31:43 -0400 Subject: [PATCH 239/362] 20w13b bugfix --- plugins/player.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/plugins/player.js b/plugins/player.js index 5b09619..9f088be 100644 --- a/plugins/player.js +++ b/plugins/player.js @@ -12,12 +12,18 @@ module.exports = { } else if (data.data[i].UUID) { uuid = data.data[i].UUID } + let displayName; + if(data.data[i].displayName !== undefined){ + displayName = data.data[i].displayName; + } else { + displayName = "Undefined!" + } if (data.data[i].player && data.data[i].player.name !== undefined) { - buffer2[uuid] = { realName: data.data[i].player.name, displayName: parse(parse1204(data.data[i].displayName)).plain } + buffer2[uuid] = { realName: data.data[i].player.name, displayName: displayName.plain } } else if (data.data[i].name !== undefined) { - buffer2[uuid] = { realName: data.data[i].name, displayName: parse(parse1204(data.data[i].displayName)).plain } + buffer2[uuid] = { realName: data.data[i].name, displayName: displayName.plain } } else if (data.data[i].displayName !== undefined) { - buffer2[uuid] = { displayName: parse(parse1204(data.data[i].displayName)).plain } + buffer2[uuid] = { displayName: displayName.plain } } } for (const uuid in buffer2) { From 2b87fd14cc00f6871fb823d74c16f4899ecded42 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Wed, 31 Jul 2024 01:08:25 -0400 Subject: [PATCH 240/362] Fix chatparse_1204 error handler --- util/chatparse_1204.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/chatparse_1204.js b/util/chatparse_1204.js index e706232..4d4dcb2 100644 --- a/util/chatparse_1204.js +++ b/util/chatparse_1204.js @@ -18,4 +18,4 @@ const parse2 = function (_data) { } } } -module.exports = parse +module.exports = parse2 From 12391e8db4acb34c5c2a41235ee2657821b2191f Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Wed, 31 Jul 2024 01:08:51 -0400 Subject: [PATCH 241/362] Vanilla server support --- plugins/!chat.js | 23 ++++++++++++++++++----- plugins/commandblock.js | 8 +++++++- plugins/selfcare.js | 20 +++++++++++--------- 3 files changed, 36 insertions(+), 15 deletions(-) diff --git a/plugins/!chat.js b/plugins/!chat.js index 385c2e8..b667531 100755 --- a/plugins/!chat.js +++ b/plugins/!chat.js @@ -1,3 +1,4 @@ +const settings = require('../settings.json') const console2 = require('./console.js') const parse = require('../util/chatparse.js') const parse1204 = require('../util/chatparse_1204.js') @@ -72,14 +73,26 @@ module.exports = { b._client.on('chat', (data) => { // Legacy chat const json = parse1204(data.message) const parsed = parse(json).plain - const split = parsed.split(': ') - const chatName = split.splice(0, 1)[0] - const username = b.findRealName(chatName) - const uuid = b.findUUID(username) - b.emit('chat', { json, type: 'legacy', uuid: data.uuid ? data.uuid : uuid, message: split.join(': '), username }) + let chatName + let username + let message; + let uuid; + if(b.host.options.isVanilla && json.translate === "chat.type.text"){ // Servers without Extras chat + message = parse(json.with[1]).plain; + username = parse(json.with[0]).plain; + uuid = b.findUUID(username); + } else { // Servers with Extras chat, such as Kaboom + const split = parsed.split(': ') + message = split.join(': ') + uuid = b.findUUID(username) + chatName = split.splice(0, 1)[0] + username = b.findRealName(chatName) + } + b.emit('chat', { json, type: 'legacy', uuid: data.uuid ? data.uuid : uuid, message, username }) }) b.on('chat', (data) => { const msg = parse(data.json) + if(settings.logJSONmessages) console.log(data.json) if (msg.plain.endsWith('\n\n\n\n\nThe chat has been cleared')) return if (msg.plain.startsWith('Command set: ')) return b.emit('plainchat', msg.plain) diff --git a/plugins/commandblock.js b/plugins/commandblock.js index b489fa7..16b9f55 100755 --- a/plugins/commandblock.js +++ b/plugins/commandblock.js @@ -97,7 +97,13 @@ module.exports = { } else { finalname = uuid } - b.ccq.push(`/minecraft:tellraw ${finalname} ${JSON.stringify(message)}`) + let tellrawCommand; + if(b.host.options.isVanilla){ + tellrawCommand = "tellraw"; + } else { + tellrawCommand = "minecraft:tellraw"; + } + b.ccq.push(`/${tellrawCommand} ${finalname} ${JSON.stringify(message)}`) } } } diff --git a/plugins/selfcare.js b/plugins/selfcare.js index c83dad1..699ede0 100755 --- a/plugins/selfcare.js +++ b/plugins/selfcare.js @@ -44,15 +44,17 @@ module.exports = { }) // Commandspy - b.add_sc_task('cspy', '/cspy on', true, true) - b.on('plainchat', (msg) => { - if (msg === 'Successfully disabled CommandSpy') { - b.sc_tasks.cspy.failed = 1 - } else if (msg === 'Successfully enabled CommandSpy') { - b.sc_tasks.cspy.failed = 0 - } - }) - + if(!b.host.options.isVanilla){ + b.add_sc_task('cspy', '/cspy on', true, true) + b.on('plainchat', (msg) => { + if (msg === 'Successfully disabled CommandSpy') { + b.sc_tasks.cspy.failed = 1 + } else if (msg === 'Successfully enabled CommandSpy') { + b.sc_tasks.cspy.failed = 0 + } + }) + } + // Gamemode b.add_sc_task('gamemode', '/minecraft:gamemode creative', true) b._client.on('game_state_change', (p) => { From 6f1271ba819e84198858ad167925b05e0f41ecd4 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Wed, 31 Jul 2024 02:57:43 -0400 Subject: [PATCH 242/362] This wouldn't even work anymore --- util/textformat.js | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 util/textformat.js diff --git a/util/textformat.js b/util/textformat.js deleted file mode 100644 index 89bb3a7..0000000 --- a/util/textformat.js +++ /dev/null @@ -1,17 +0,0 @@ -const settings = require('../settings.json') -module.exports = function (text) { - return JSON.stringify({ - translate: '[%s] %s', - color: '#FFAAFF', - with: [ - { - text: settings.name, - color: 'light_purple' - }, - { - text, - color: 'white' - } - ] - }) -} From 1cab040f8d7b673252fb80ebda6f6a4b02aca510 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Wed, 31 Jul 2024 05:30:35 -0400 Subject: [PATCH 243/362] Remove minecraft section sign chat --- util/chatparse.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/util/chatparse.js b/util/chatparse.js index 513d155..3480603 100644 --- a/util/chatparse.js +++ b/util/chatparse.js @@ -88,11 +88,9 @@ const parse = function (_data, l = 0, resetColor = consoleColors.reset) { if (data.translate) { let trans = data.translate.replace(/%%/g, '\ue123').replaceAll('\x1b', '').replaceAll('\x0e', '') // Remove escape codes from console format let trans2 = data.translate.replace(/%%/g, '\ue123') - let trans3 = data.translate.replace(/%%/g, '\ue123') if (lang[trans] !== undefined) { trans = lang[trans].replace(/%%/g, '\ue123') trans2 = lang[trans2].replace(/%%/g, '\ue123') - trans3 = lang[trans3].replace(/%%/g, '\ue123') } for (const i in data.with) { const j2 = parse(data.with[i], l + 1, data.color ? processColor(data.color, resetColor) : resetColor) From 20fb934a02ae15ba21487f17e02b8f365f800cab Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 <7cc5c4f330d47060@noreply.localhost> Date: Wed, 31 Jul 2024 05:55:57 -0400 Subject: [PATCH 244/362] Update plugins/commands/stop.js --- plugins/commands/stop.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/commands/stop.js b/plugins/commands/stop.js index 441c345..1e8e6ad 100644 --- a/plugins/commands/stop.js +++ b/plugins/commands/stop.js @@ -1,6 +1,6 @@ module.exports = { execute: (c) => { - process.exit(0) + process.exit(1) }, aliases: ['exit'], level: 2 From 27766c8c5647ae06d43e130f5777e6f45e7108c1 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 <7cc5c4f330d47060@noreply.localhost> Date: Wed, 31 Jul 2024 05:56:20 -0400 Subject: [PATCH 245/362] Update plugins/commands/restart.js --- plugins/commands/restart.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/commands/restart.js b/plugins/commands/restart.js index 5f64d6d..b8ed38c 100644 --- a/plugins/commands/restart.js +++ b/plugins/commands/restart.js @@ -1,6 +1,6 @@ module.exports = { execute: (c) => { - process.exit(1) + process.exit(0) }, aliases: ['reboot'], level: 2 From f63d7d4d77743c2057718b55a2d64b69fb51b75d Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Wed, 31 Jul 2024 06:03:45 -0400 Subject: [PATCH 246/362] Add node jndex.js to reamde --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a9e6395..dff16e0 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ botvX is a Minecraft bot for [Kaboom](https://kaboom.pw/) and its clones. It has 3. Extract the files if necessary. 4. Run npm install in the bot's directory. If it doesn't work, try using the Node.js command prompt, or adding Node.js to your PATH. 5. Copy settings_example.json to settings.json , and adjust the settings to fit your needs. Do not forget to also create a secrets file. An example secrets file is provided as secret_example.json. Do not forget, if you use the secrets template, to change the keys (the ones in there are public after all!). -6. Run ./launch.sh (macOS, Linux, FreeBSD) or ./launch.cmd (Windows) to start a bot launcher, which will reload the bot when the process closes. If it displays an error saying Node is not a command, please make sure Node.js is on your PATH. +6. Run ./launch.sh (macOS, Linux, FreeBSD) or ./launch.cmd (Windows) to start a bot launcher, which will reload the bot when the process closes. Alternatively, you can run node index.js to start the bot only once (it will still rejoin when kicked). If it displays an error saying Node is not a command, please make sure Node.js is on your PATH. ## Command list From 38f38dda2a2cdf98b0fd41983e8a2e9c20e46fca Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Wed, 31 Jul 2024 06:08:07 -0400 Subject: [PATCH 247/362] Change internal fallback player name --- plugins/player.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/player.js b/plugins/player.js index 9f088be..d1f27a8 100644 --- a/plugins/player.js +++ b/plugins/player.js @@ -46,7 +46,7 @@ module.exports = { return b.players[i].realName } } - return 'Geometrical Dominator' + return '[[[[ no name ]]]]' } } } From e2f1d7da430e90bd986490be9759cc0f44440131 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Wed, 31 Jul 2024 16:08:04 -0400 Subject: [PATCH 248/362] Add source code link hover to about, make hover texts compatible with 20w14i --- plugins/commands/about.js | 11 ++++++++++- plugins/commands/serverinfo.js | 3 +++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/plugins/commands/about.js b/plugins/commands/about.js index 80ccd0e..02047bf 100644 --- a/plugins/commands/about.js +++ b/plugins/commands/about.js @@ -74,8 +74,17 @@ module.exports = { clickEvent: { action: 'open_url', value: version.sourceURL + }, + hoverEvent: { + action: 'show_text', + contents: { + text: getMessage(c.lang, 'command.about.sourceCode.openInBrowser') + }, + value: { // Added twice for backwards compatibility + text: getMessage(c.lang, 'command.about.sourceCode.openInBrowser') + } } - } + }, ] }) c.reply({ text: '' }) diff --git a/plugins/commands/serverinfo.js b/plugins/commands/serverinfo.js index 10c5899..4f196db 100755 --- a/plugins/commands/serverinfo.js +++ b/plugins/commands/serverinfo.js @@ -22,6 +22,9 @@ const gr = function (l, text, value, color) { action: 'show_text', contents: { text: getMessage(l, 'copyText') + }, + value: { // Added twice for backwards compatibility + text: getMessage(l, 'copyText') } }, clickEvent: { From f09b341ac95b5405cbcb9917bd727aec92d0eedc Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Wed, 31 Jul 2024 16:09:51 -0400 Subject: [PATCH 249/362] Add strings --- util/lang/en-US.json | 1 + util/lang/en-UW.json | 1 + 2 files changed, 2 insertions(+) diff --git a/util/lang/en-US.json b/util/lang/en-US.json index 75aa02f..1177e9a 100644 --- a/util/lang/en-US.json +++ b/util/lang/en-US.json @@ -40,6 +40,7 @@ "command.about.author": "%s - a Minecraft bot made by 77c8f4699b732c11 / a5a06d596f15c7db", "command.about.version": "Version %s", "command.about.sourceCode": "Source code: %s", + "command.about.sourceCode.openInBrowser": "Click to open the source code link in your default browser", "command.about.serverinfo": "To view system information, run the command %s.", "command.cloop.error.tooShort": "Command loops must have a rate above 20ms.", "command.cloop.error.subcommand": "Unknown subcommand, please do %s", diff --git a/util/lang/en-UW.json b/util/lang/en-UW.json index 25e081e..7a40c14 100644 --- a/util/lang/en-UW.json +++ b/util/lang/en-UW.json @@ -40,6 +40,7 @@ "command.about.author": "%s - a Minyecwaft bot made by 77c8f4699b732c11 / a5a06d596f15c7db", "command.about.version": "Vewsion %s", "command.about.sourceCode": "Souwce code: %s", + "command.about.sourceCode.openInBrowser": "Cwick to open the souwce code wink in youw defauwt bwowsew", "command.about.serverinfo": "To view system infowmation, wun the command %s.", "command.cloop.error.tooShort": "Command woops must have a wate above 20ms.", "command.cloop.error.subcommand": "Unknyown subcommand, pwease do %s", From 5f3a41a1a0d7c50cf7c55e05c2129eb14a827422 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 <7cc5c4f330d47060@noreply.localhost> Date: Thu, 1 Aug 2024 00:20:34 -0400 Subject: [PATCH 250/362] revert 2b87fd14cc00f6871fb823d74c16f4899ecded42 revert Fix chatparse_1204 error handler --- util/chatparse_1204.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/chatparse_1204.js b/util/chatparse_1204.js index 4d4dcb2..e706232 100644 --- a/util/chatparse_1204.js +++ b/util/chatparse_1204.js @@ -18,4 +18,4 @@ const parse2 = function (_data) { } } } -module.exports = parse2 +module.exports = parse From 111ba7ba250a8010f3a2225bddf43f6789830c66 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 <7cc5c4f330d47060@noreply.localhost> Date: Thu, 1 Aug 2024 00:21:28 -0400 Subject: [PATCH 251/362] We have to patch prismarine-chat because minecraft-protocol depends on it... revert Add error handler to this for some reason I got a maximum call stack size exceeded error in this code... --- util/chatparse_1204.js | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/util/chatparse_1204.js b/util/chatparse_1204.js index e706232..3add56e 100644 --- a/util/chatparse_1204.js +++ b/util/chatparse_1204.js @@ -8,14 +8,4 @@ const parse = function (data) { return data } } -const parse2 = function (_data) { - try { - return parse(_data) - } catch (e) { - console.error(e) - return { - text: 'An error occured while parsing a message. See console for more information.' - } - } -} module.exports = parse From 33cd9adf6759430cec9f9b397338b26ad1982c4b Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Thu, 1 Aug 2024 19:55:09 -0400 Subject: [PATCH 252/362] Chat parser --- util/chatparse.js | 8 +------- util/chatparse_1204.js | 12 +----------- 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/util/chatparse.js b/util/chatparse.js index 3480603..c9a3584 100644 --- a/util/chatparse.js +++ b/util/chatparse.js @@ -64,13 +64,7 @@ const parse = function (_data, l = 0, resetColor = consoleColors.reset) { nkt = true } if (data.color) { - if (data.color === 'reset') { - out.console += resetColor - } else if (data.color.startsWith('#')) { - out.console += hexColorParser(data.color) - } else { - out.console += consoleColors[data.color] - } + out.console += processColor(data.color, resetColor) } else { out.console += resetColor } diff --git a/util/chatparse_1204.js b/util/chatparse_1204.js index 4d4dcb2..3add56e 100644 --- a/util/chatparse_1204.js +++ b/util/chatparse_1204.js @@ -8,14 +8,4 @@ const parse = function (data) { return data } } -const parse2 = function (_data) { - try { - return parse(_data) - } catch (e) { - console.error(e) - return { - text: 'An error occured while parsing a message. See console for more information.' - } - } -} -module.exports = parse2 +module.exports = parse From 4a4b992c699817406ff09f8a140749be0ca1d14c Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Thu, 1 Aug 2024 19:58:13 -0400 Subject: [PATCH 253/362] Console colors --- util/consolecolors.json | 204 ++++++++++++++++++++-------------------- 1 file changed, 102 insertions(+), 102 deletions(-) diff --git a/util/consolecolors.json b/util/consolecolors.json index 0370261..681d28d 100644 --- a/util/consolecolors.json +++ b/util/consolecolors.json @@ -1,23 +1,23 @@ { "blackTerminal_24bit":{ "fourBit":{ - "dark_red": "\u001B[0m\u001B[38;2;170;0;0m", - "red": "\u001B[0m\u001B[38;2;255;85;85m", - "dark_green": "\u001B[0m\u001B[38;2;0;170;0m", - "green": "\u001B[0m\u001B[38;2;85;255;85m", - "gold": "\u001B[0m\u001B[38;2;255;170;0m", - "yellow": "\u001B[0m\u001B[38;2;255;255;85m", - "dark_blue": "\u001B[0m\u001B[38;2;0;0;170m", - "blue": "\u001B[0m\u001B[38;2;85;85;255m", - "dark_purple": "\u001B[0m\u001B[38;2;170;0;170m", - "light_purple": "\u001B[0m\u001B[38;2;255;85;255m", - "dark_aqua": "\u001B[0m\u001B[38;2;0;170;170m", - "aqua": "\u001B[0m\u001B[38;2;85;255;255m", - "black": "\u001B[0m\u001B[48;2;220;220;220m\u001B[38;2;0;0;0m", - "gray": "\u001B[0m\u001B[38;2;170;170;170m", - "dark_gray": "\u001B[0m\u001B[38;2;85;85;85m", - "white": "\u001B[0m\u001B[38;2;255;255;255m", - "reset": "\u001B[0m\u001B[38;2;255;255;255m" + "dark_red": "\u001B[0;38;2;170;0;0m", + "red": "\u001B[0;38;2;255;85;85m", + "dark_green": "\u001B[0;38;2;0;170;0m", + "green": "\u001B[0;38;2;85;255;85m", + "gold": "\u001B[0;38;2;255;170;0m", + "yellow": "\u001B[0;38;2;255;255;85m", + "dark_blue": "\u001B[0;38;2;0;0;170m", + "blue": "\u001B[0;38;2;85;85;255m", + "dark_purple": "\u001B[0;38;2;170;0;170m", + "light_purple": "\u001B[0;38;2;255;85;255m", + "dark_aqua": "\u001B[0;38;2;0;170;170m", + "aqua": "\u001B[0;38;2;85;255;255m", + "black": "\u001B[0;48;2;220;220;220;38;2;0;0;0m", + "gray": "\u001B[0;38;2;170;170;170m", + "dark_gray": "\u001B[0;38;2;85;85;85m", + "white": "\u001B[0;38;2;255;255;255m", + "reset": "\u001B[0;38;2;255;255;255m" }, "twentyFourBit":{ "enabled": true, @@ -27,23 +27,23 @@ }, "whiteTerminal_24bit":{ "fourBit":{ - "dark_red": "\u001B[0m\u001B[38;2;170;0;0m", - "red": "\u001B[0m\u001B[38;2;255;85;85m", - "dark_green": "\u001B[0m\u001B[38;2;0;170;0m", - "green": "\u001B[0m\u001B[48;2;20;20;20m\u001B[38;2;85;255;85m", - "gold": "\u001B[0m\u001B[38;2;255;170;0m", - "yellow": "\u001B[0m\u001B[48;2;20;20;20m\u001B[38;2;255;255;85m", - "dark_blue": "\u001B[0m\u001B[38;2;0;0;170m", - "blue": "\u001B[0m\u001B[38;2;85;85;255m", - "dark_purple": "\u001B[0m\u001B[38;2;170;0;170m", - "light_purple": "\u001B[0m\u001B[38;2;255;85;255m", - "dark_aqua": "\u001B[0m\u001B[38;2;0;170;170m", - "aqua": "\u001B[0m\u001B[48;2;20;20;20m\u001B[38;2;85;255;255m", - "black": "\u001B[0m\u001B[38;2;0;0;0m", - "gray": "\u001B[0m\u001B[38;2;170;170;170m", - "dark_gray": "\u001B[0m\u001B[38;2;85;85;85m", - "white": "\u001B[0m\u001B[48;2;20;20;20m\u001B[38;2;255;255;255m", - "reset": "\u001B[0m\u001B[48;2;20;20;20m\u001B[38;2;255;255;255m" + "dark_red": "\u001B[0;38;2;170;0;0m", + "red": "\u001B[0;38;2;255;85;85m", + "dark_green": "\u001B[0;38;2;0;170;0m", + "green": "\u001B[0;48;2;20;20;20;38;2;85;255;85m", + "gold": "\u001B[0;38;2;255;170;0m", + "yellow": "\u001B[0;48;2;20;20;20;38;2;255;255;85m", + "dark_blue": "\u001B[0;38;2;0;0;170m", + "blue": "\u001B[0;38;2;85;85;255m", + "dark_purple": "\u001B[0;38;2;170;0;170m", + "light_purple": "\u001B[0;38;2;255;85;255m", + "dark_aqua": "\u001B[0;38;2;0;170;170m", + "aqua": "\u001B[0;48;2;20;20;20;38;2;85;255;255m", + "black": "\u001B[0;38;2;0;0;0m", + "gray": "\u001B[0;38;2;170;170;170m", + "dark_gray": "\u001B[0;38;2;85;85;85m", + "white": "\u001B[0;48;2;20;20;20;38;2;255;255;255m", + "reset": "\u001B[0;48;2;20;20;20;38;2;255;255;255m" }, "twentyFourBit":{ "enabled": true, @@ -53,23 +53,23 @@ }, "blackTerminal_8bit":{ "fourBit":{ - "dark_red": "\u001B[0m\u001B[38;5;1m", - "red": "\u001B[0m\u001B[38;5;9m", - "dark_green": "\u001B[0m\u001B[38;5;2m", - "green": "\u001B[0m\u001B[38;5;10m", - "gold": "\u001B[0m\u001B[38;5;3m", - "yellow": "\u001B[0m\u001B[38;5;11m", - "dark_blue": "\u001B[0m\u001B[38;5;4m", - "blue": "\u001B[0m\u001B[38;5;12m", - "dark_purple": "\u001B[0m\u001B[38;5;5m", - "light_purple": "\u001B[0m\u001B[38;5;13m", - "dark_aqua": "\u001B[0m\u001B[38;5;6m", - "aqua": "\u001B[0m\u001B[38;5;14m", - "black": "\u001B[0m\u001B[48;5;15m\u001B[38;5;0m", - "gray": "\u001B[0m\u001B[38;5;7m", - "dark_gray": "\u001B[0m\u001B[38;5;8m", - "white": "\u001B[0m\u001B[38;5;15m", - "reset": "\u001B[0m\u001B[38;5;15m" + "dark_red": "\u001B[0;38;5;1m", + "red": "\u001B[0;38;5;9m", + "dark_green": "\u001B[0;38;5;2m", + "green": "\u001B[0;38;5;10m", + "gold": "\u001B[0;38;5;3m", + "yellow": "\u001B[0;38;5;11m", + "dark_blue": "\u001B[0;38;5;4m", + "blue": "\u001B[0;38;5;12m", + "dark_purple": "\u001B[0;38;5;5m", + "light_purple": "\u001B[0;38;5;13m", + "dark_aqua": "\u001B[0;38;5;6m", + "aqua": "\u001B[0;38;5;14m", + "black": "\u001B[0;48;5;15;38;5;0m", + "gray": "\u001B[0;38;5;7m", + "dark_gray": "\u001B[0;38;5;8m", + "white": "\u001B[0;38;5;15m", + "reset": "\u001B[0;38;5;15m" }, "twentyFourBit":{ "enabled": true, @@ -79,23 +79,23 @@ }, "whiteTerminal_8bit":{ "fourBit":{ - "dark_red": "\u001B[0m\u001B[38;5;1m", - "red": "\u001B[0m\u001B[38;5;9m", - "dark_green": "\u001B[0m\u001B[38;5;2m", - "green": "\u001B[0m\u001B[48;5;0m\u001B[38;5;10m", - "gold": "\u001B[0m\u001B[38;5;3m", - "yellow": "\u001B[0m\u001B[48;5;0m\u001B[38;5;11m", - "dark_blue": "\u001B[0m\u001B[38;5;4m", - "blue": "\u001B[0m\u001B[38;5;12m", - "dark_purple": "\u001B[0m\u001B[38;5;5m", - "light_purple": "\u001B[0m\u001B[38;5;13m", - "dark_aqua": "\u001B[0m\u001B[38;5;6m", - "aqua": "\u001B[0m\u001B[48;5;0m\u001B[38;5;14m", - "black": "\u001B[0m\u001B[38;5;0m", - "gray": "\u001B[0m\u001B[38;5;7m", - "dark_gray": "\u001B[0m\u001B[38;5;8m", - "white": "\u001B[0m\u001B[48;5;0m\u001B[38;5;15m", - "reset": "\u001B[0m\u001B[48;5;0m\u001B[38;5;15m" + "dark_red": "\u001B[0;38;5;1m", + "red": "\u001B[0;38;5;9m", + "dark_green": "\u001B[0;38;5;2m", + "green": "\u001B[0;48;5;0;38;5;10m", + "gold": "\u001B[0;38;5;3m", + "yellow": "\u001B[0;48;5;0;38;5;11m", + "dark_blue": "\u001B[0;38;5;4m", + "blue": "\u001B[0;38;5;12m", + "dark_purple": "\u001B[0;38;5;5m", + "light_purple": "\u001B[0;38;5;13m", + "dark_aqua": "\u001B[0;38;5;6m", + "aqua": "\u001B[0;48;5;0;38;5;14m", + "black": "\u001B[0;38;5;0m", + "gray": "\u001B[0;38;5;7m", + "dark_gray": "\u001B[0;38;5;8m", + "white": "\u001B[0;48;5;0;38;5;15m", + "reset": "\u001B[0;48;5;0;38;5;15m" }, "twentyFourBit":{ "enabled": true, @@ -105,23 +105,23 @@ }, "blackTerminal_4bit":{ "fourBit":{ - "dark_red": "\u001B[0m\u001B[31m", - "red": "\u001B[0m\u001B[1;31m", - "dark_green": "\u001B[0m\u001B[32m", - "green": "\u001B[0m\u001B[1;32m", - "gold": "\u001B[0m\u001B[33m", - "yellow": "\u001B[0m\u001B[1;33m", - "dark_blue": "\u001B[0m\u001B[34m", - "blue": "\u001B[0m\u001B[1;34m", - "dark_purple": "\u001B[0m\u001B[35m", - "light_purple": "\u001B[0m\u001B[1;35m", - "dark_aqua": "\u001B[0m\u001B[36m", - "aqua": "\u001B[0m\u001B[1;36m", - "black": "\u001B[0m\u001B[0;1;47m\u001B[0;30m", - "gray": "\u001B[0m\u001B[0;37m", - "dark_gray": "\u001B[0m\u001B[0;1;30m", - "white": "\u001B[0m\u001B[0;1;37m", - "reset": "\u001B[0m\u001B[0;1;37m" + "dark_red": "\u001B[0;31m", + "red": "\u001B[0;1;31m", + "dark_green": "\u001B[0;32m", + "green": "\u001B[0;1;32m", + "gold": "\u001B[0;33m", + "yellow": "\u001B[0;1;33m", + "dark_blue": "\u001B[0;34m", + "blue": "\u001B[0;1;34m", + "dark_purple": "\u001B[0;35m", + "light_purple": "\u001B[0;1;35m", + "dark_aqua": "\u001B[0;36m", + "aqua": "\u001B[0;1;36m", + "black": "\u001B[0;1;47;30m", + "gray": "\u001B[0;37m", + "dark_gray": "\u001B[0;1;30m", + "white": "\u001B[0;1;37m", + "reset": "\u001B[0;1;37m" }, "twentyFourBit":{ "enabled": true, @@ -131,23 +131,23 @@ }, "whiteTerminal_4bit":{ "fourBit":{ - "dark_red": "\u001B[0m\u001B[31m", - "red": "\u001B[0m\u001B[1;31m", - "dark_green": "\u001B[0m\u001B[32m", - "green": "\u001B[0m\u001B[0;40m\u001B[1;32m", - "gold": "\u001B[0m\u001B[33m", - "yellow": "\u001B[0m\u001B[0;40m\u001B[1;33m", - "dark_blue": "\u001B[0m\u001B[34m", - "blue": "\u001B[0m\u001B[1;34m", - "dark_purple": "\u001B[0m\u001B[35m", - "light_purple": "\u001B[0m\u001B[1;35m", - "dark_aqua": "\u001B[0m\u001B[36m", - "aqua": "\u001B[0m\u001B[0;40m\u001B[1;36m", - "black": "\u001B[0m\u001B[0;30m", - "gray": "\u001B[0m\u001B[0;37m", - "dark_gray": "\u001B[0m\u001B[0;1;30m", - "white": "\u001B[0m\u001B[0;40m\u001B[1;37m", - "reset": "\u001B[0m\u001B[0;40m\u001B[1;37m" + "dark_red": "\u001B[0;31m", + "red": "\u001B[0;1;31m", + "dark_green": "\u001B[0;32m", + "green": "\u001B[0;40;1;32m", + "gold": "\u001B[0;33m", + "yellow": "\u001B[0;40;1;33m", + "dark_blue": "\u001B[0;34m", + "blue": "\u001B[0;1;34m", + "dark_purple": "\u001B[0;35m", + "light_purple": "\u001B[0;1;35m", + "dark_aqua": "\u001B[0;36m", + "aqua": "\u001B[0;40;1;36m", + "black": "\u001B[0;30m", + "gray": "\u001B[0;37m", + "dark_gray": "\u001B[0;1;30m", + "white": "\u001B[0;40;1;37m", + "reset": "\u001B[0;40;1;37m" }, "twentyFourBit":{ "enabled": true, From eb89f9e657a2fe5e3d1821a8096849cb32af4683 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Thu, 1 Aug 2024 20:00:46 -0400 Subject: [PATCH 254/362] sg.usage": " ", "command.netmsg.desc": "Send a message to all servers the bot is connected to", "command.refill.usage": "", "command.refill.desc": "Refill core", "command.say.usage": " ", "command.say.desc": "Sends a message to chat", "command.serverinfo.usage": "", "command.serverinfo.desc": "Get system/bot info", "command.stop.usage": "", "command.stop.desc": "Restart bot", "command.template.usage": " [optional]", "command.template.desc": "Does nothing", "command.tpr.desc": "Teleport to a random location", "command.tpr.usage": "", "command.verify.usage": " [args...]", "command.verify.desc": "Check the hashing system", "command.about.author": "%s - a Minecraft bot made by 77c8f4699b732c11 / a5a06d596f15c7db", "command.about.version": "Version %s", "command.about.sourceCode": "Source code: %s", "command.about.sourceCode.openInBrowser": "Click to o --- util/{chatparse.js => chatparse_console.js} | 0 util/chatparse_plain.js | 120 ++++++++++++++++++++ 2 files changed, 120 insertions(+) rename util/{chatparse.js => chatparse_console.js} (100%) create mode 100644 util/chatparse_plain.js diff --git a/util/chatparse.js b/util/chatparse_console.js similarity index 100% rename from util/chatparse.js rename to util/chatparse_console.js diff --git a/util/chatparse_plain.js b/util/chatparse_plain.js new file mode 100644 index 0000000..c9a3584 --- /dev/null +++ b/util/chatparse_plain.js @@ -0,0 +1,120 @@ +const _lang = require('minecraft-data')('1.20.2').language; +const settings = require('../settings.json'); +const lang = Object.create(null) // Without constructor function +for (const i in _lang) { + lang[i] = _lang[i] +} +const _consoleColors = require("./consolecolors.json"); +let consoleColors; +let consoleColors24; +if(_consoleColors[settings.terminalMode]){ + consoleColors=_consoleColors[settings.terminalMode].fourBit + consoleColors24=_consoleColors[settings.terminalMode].twentyFourBit +} else { + consoleColors=_consoleColors.none.fourBit + consoleColors24=_consoleColors.none.twentyFourBit +} +const hexColorParser = (color) => { + if(!consoleColors24.enabled || consoleColors24.bit!==24){ //Non-24bit hex color parsing is not implemented yet + return ""; + } + let out = '\x1B[0;' + const redChannel = Number('0x' + color.slice(1, 3)) + const greenChannel = Number('0x' + color.slice(3, 5)) + const blueChannel = Number('0x' + color.slice(5, 7)) + if (!consoleColors24.lightMode && redChannel < 64 && greenChannel < 64 && blueChannel < 64) { + out += '48;2;220;220;220;' + } else if (consoleColors24.lightMode && ((redChannel > 192 && greenChannel > 192 && blueChannel > 192) || greenChannel > 160)) { + out += '48;2;0;0;0;' + } + return out + `38;2;${redChannel};${greenChannel};${blueChannel}m` +} +const processColor = (col, rcol) => { + let out; + if (col === 'reset') { + out = rcol + } else if (col.startsWith('#')) { + out = hexColorParser(col) + } else { + out = consoleColors[col] + } + return out +} +const parse = function (_data, l = 0, resetColor = consoleColors.reset) { + if (l >= 12) { + return ['', '', ''] + } + let data + if (typeof _data === 'string') { + data = { text: _data, color: 'reset' } + } else if (typeof _data === 'number') { + data = { text: _data + '', color: 'reset' } + } else if (_data.constructor === Array) { + data = { extra: _data, color: 'reset' } + } else { + data = _data + } + let nkt = false + const out = { + console: "", // Console formatting using ANSI escape codes for colors + plain: "" // Plain formatting with no colors + } + if (data['']) { + data.text = data[''] + nkt = true + } + if (data.color) { + out.console += processColor(data.color, resetColor) + } else { + out.console += resetColor + } + if (data.text) { + let _text = data.text + if (typeof _text === 'number') { + _text = _text.toString() + } + if (nkt) { + out.console += resetColor + } + out.console += _text.replaceAll('\x1b', '').replaceAll('\x0e', '') // Remove escape codes and [SO] from console format + out.plain += _text + } + if (data.translate) { + let trans = data.translate.replace(/%%/g, '\ue123').replaceAll('\x1b', '').replaceAll('\x0e', '') // Remove escape codes from console format + let trans2 = data.translate.replace(/%%/g, '\ue123') + if (lang[trans] !== undefined) { + trans = lang[trans].replace(/%%/g, '\ue123') + trans2 = lang[trans2].replace(/%%/g, '\ue123') + } + for (const i in data.with) { + const j2 = parse(data.with[i], l + 1, data.color ? processColor(data.color, resetColor) : resetColor) + trans = trans.replace(/%s/, j2.console.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + trans2 = trans2.replace(/%s/, j2.plain.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + trans = trans.replaceAll(`%${+i + 1}$s`, j2.console.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + trans2 = trans2.replaceAll(`%${+i + 1}$s`, j2.plain.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + } + out.console += trans.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s') + out.plain += trans2.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s') + } + if (data.extra) { + for (const i in data.extra) { + const parsed = parse(data.extra[i], l, data.color ? processColor(data.color, resetColor) : resetColor) + out.console += parsed.console + out.plain += parsed.plain + } + } + out.console += resetColor + return out +} +const parse2 = function (_data, l, resetColor) { + try { + return parse(_data) + } catch (e) { + console.error(e) + return { + console: '\x1B[0m\x1B[38;2;255;85;85mAn error occured while parsing a message. See console for more information.\nJSON that caused the error: ' + JSON.stringify(_data), + plain: 'An error occured while parsing a message. See console for more information. JSON that caused the error: ' + JSON.stringify(_data) + } + } +} +module.exports = parse2 From f85a34481be359107bc46602120ff626617cd95b Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Thu, 1 Aug 2024 20:11:59 -0400 Subject: [PATCH 255/362] Start chat parser rewrite --- plugins/player.js | 2 - util/ConsoleCommand.js | 4 +- util/chatparse_console.js | 45 +++++++------------ util/chatparse_plain.js | 93 +++++++-------------------------------- util/mc_lang.js | 6 +++ 5 files changed, 40 insertions(+), 110 deletions(-) create mode 100644 util/mc_lang.js diff --git a/plugins/player.js b/plugins/player.js index d1f27a8..ae130ec 100644 --- a/plugins/player.js +++ b/plugins/player.js @@ -1,5 +1,3 @@ -const parse = require('../util/chatparse.js') -const parse1204 = require('../util/chatparse_1204.js') module.exports = { load: (b) => { b.players = {} diff --git a/util/ConsoleCommand.js b/util/ConsoleCommand.js index 0091eb4..a7d3b28 100644 --- a/util/ConsoleCommand.js +++ b/util/ConsoleCommand.js @@ -1,14 +1,14 @@ // HOW TO WRITE CLASS JS const index = require('../index.js') const { cmds } = require('../plugins/command.js') -const parse = require('../util/chatparse.js') +const parse = require('../util/chatparse_console.js') const settings = require('../settings.json') const {getMessage} = require('../util/lang.js') const lang = settings.defaultLang class ConsoleCommand { constructor (cmd, index2) { this.send = () => {} // not needed for console - this.reply = text => process.stdout.write(parse(text).console + '\n') + this.reply = text => process.stdout.write(parse(text) + '\n') this.uuid = 'dde5a2a6-ebdd-4bbb-8eac-f75b10c10446_console' // hard-coded because uuid does not exist at console this.username = 'Owner' this.nickname = 'Console' diff --git a/util/chatparse_console.js b/util/chatparse_console.js index c9a3584..fe0ad2e 100644 --- a/util/chatparse_console.js +++ b/util/chatparse_console.js @@ -1,9 +1,6 @@ -const _lang = require('minecraft-data')('1.20.2').language; const settings = require('../settings.json'); -const lang = Object.create(null) // Without constructor function -for (const i in _lang) { - lang[i] = _lang[i] -} +const lang = require('./mc_lang.js'); + const _consoleColors = require("./consolecolors.json"); let consoleColors; let consoleColors24; @@ -14,6 +11,7 @@ if(_consoleColors[settings.terminalMode]){ consoleColors=_consoleColors.none.fourBit consoleColors24=_consoleColors.none.twentyFourBit } + const hexColorParser = (color) => { if(!consoleColors24.enabled || consoleColors24.bit!==24){ //Non-24bit hex color parsing is not implemented yet return ""; @@ -29,6 +27,7 @@ const hexColorParser = (color) => { } return out + `38;2;${redChannel};${greenChannel};${blueChannel}m` } + const processColor = (col, rcol) => { let out; if (col === 'reset') { @@ -40,6 +39,7 @@ const processColor = (col, rcol) => { } return out } + const parse = function (_data, l = 0, resetColor = consoleColors.reset) { if (l >= 12) { return ['', '', ''] @@ -55,18 +55,15 @@ const parse = function (_data, l = 0, resetColor = consoleColors.reset) { data = _data } let nkt = false - const out = { - console: "", // Console formatting using ANSI escape codes for colors - plain: "" // Plain formatting with no colors - } + let out = "" if (data['']) { data.text = data[''] nkt = true } if (data.color) { - out.console += processColor(data.color, resetColor) + out += processColor(data.color, resetColor) } else { - out.console += resetColor + out += resetColor } if (data.text) { let _text = data.text @@ -74,36 +71,29 @@ const parse = function (_data, l = 0, resetColor = consoleColors.reset) { _text = _text.toString() } if (nkt) { - out.console += resetColor + out += resetColor } - out.console += _text.replaceAll('\x1b', '').replaceAll('\x0e', '') // Remove escape codes and [SO] from console format - out.plain += _text + out += _text.replaceAll('\x1b', '').replaceAll('\x0e', '') // Remove escape codes and [SO] from console format } if (data.translate) { let trans = data.translate.replace(/%%/g, '\ue123').replaceAll('\x1b', '').replaceAll('\x0e', '') // Remove escape codes from console format - let trans2 = data.translate.replace(/%%/g, '\ue123') if (lang[trans] !== undefined) { trans = lang[trans].replace(/%%/g, '\ue123') - trans2 = lang[trans2].replace(/%%/g, '\ue123') } for (const i in data.with) { const j2 = parse(data.with[i], l + 1, data.color ? processColor(data.color, resetColor) : resetColor) - trans = trans.replace(/%s/, j2.console.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) - trans2 = trans2.replace(/%s/, j2.plain.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) - trans = trans.replaceAll(`%${+i + 1}$s`, j2.console.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) - trans2 = trans2.replaceAll(`%${+i + 1}$s`, j2.plain.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + trans = trans.replace(/%s/, j2.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + trans = trans.replaceAll(`%${+i + 1}$s`, j2.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) } - out.console += trans.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s') - out.plain += trans2.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s') + out += trans.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s') } if (data.extra) { for (const i in data.extra) { const parsed = parse(data.extra[i], l, data.color ? processColor(data.color, resetColor) : resetColor) - out.console += parsed.console - out.plain += parsed.plain + out += parsed } } - out.console += resetColor + out += resetColor return out } const parse2 = function (_data, l, resetColor) { @@ -111,10 +101,7 @@ const parse2 = function (_data, l, resetColor) { return parse(_data) } catch (e) { console.error(e) - return { - console: '\x1B[0m\x1B[38;2;255;85;85mAn error occured while parsing a message. See console for more information.\nJSON that caused the error: ' + JSON.stringify(_data), - plain: 'An error occured while parsing a message. See console for more information. JSON that caused the error: ' + JSON.stringify(_data) - } + return '\x1B[0m\x1B[38;2;255;85;85mAn error occured while parsing a message. See console for more information.\nJSON that caused the error: ' + JSON.stringify(_data) } } module.exports = parse2 diff --git a/util/chatparse_plain.js b/util/chatparse_plain.js index c9a3584..c8523ec 100644 --- a/util/chatparse_plain.js +++ b/util/chatparse_plain.js @@ -1,120 +1,59 @@ -const _lang = require('minecraft-data')('1.20.2').language; -const settings = require('../settings.json'); -const lang = Object.create(null) // Without constructor function -for (const i in _lang) { - lang[i] = _lang[i] -} -const _consoleColors = require("./consolecolors.json"); -let consoleColors; -let consoleColors24; -if(_consoleColors[settings.terminalMode]){ - consoleColors=_consoleColors[settings.terminalMode].fourBit - consoleColors24=_consoleColors[settings.terminalMode].twentyFourBit -} else { - consoleColors=_consoleColors.none.fourBit - consoleColors24=_consoleColors.none.twentyFourBit -} -const hexColorParser = (color) => { - if(!consoleColors24.enabled || consoleColors24.bit!==24){ //Non-24bit hex color parsing is not implemented yet - return ""; - } - let out = '\x1B[0;' - const redChannel = Number('0x' + color.slice(1, 3)) - const greenChannel = Number('0x' + color.slice(3, 5)) - const blueChannel = Number('0x' + color.slice(5, 7)) - if (!consoleColors24.lightMode && redChannel < 64 && greenChannel < 64 && blueChannel < 64) { - out += '48;2;220;220;220;' - } else if (consoleColors24.lightMode && ((redChannel > 192 && greenChannel > 192 && blueChannel > 192) || greenChannel > 160)) { - out += '48;2;0;0;0;' - } - return out + `38;2;${redChannel};${greenChannel};${blueChannel}m` -} -const processColor = (col, rcol) => { - let out; - if (col === 'reset') { - out = rcol - } else if (col.startsWith('#')) { - out = hexColorParser(col) - } else { - out = consoleColors[col] - } - return out -} -const parse = function (_data, l = 0, resetColor = consoleColors.reset) { +const lang = require('./mc_lang.js'); + +const parse = function (_data, l = 0) { if (l >= 12) { return ['', '', ''] } let data if (typeof _data === 'string') { - data = { text: _data, color: 'reset' } + data = { text: _data } } else if (typeof _data === 'number') { - data = { text: _data + '', color: 'reset' } + data = { text: _data + '' } } else if (_data.constructor === Array) { - data = { extra: _data, color: 'reset' } + data = { extra: _data } } else { data = _data } let nkt = false - const out = { - console: "", // Console formatting using ANSI escape codes for colors - plain: "" // Plain formatting with no colors - } + const out = "" if (data['']) { data.text = data[''] nkt = true } - if (data.color) { - out.console += processColor(data.color, resetColor) - } else { - out.console += resetColor - } if (data.text) { let _text = data.text if (typeof _text === 'number') { _text = _text.toString() } - if (nkt) { - out.console += resetColor - } - out.console += _text.replaceAll('\x1b', '').replaceAll('\x0e', '') // Remove escape codes and [SO] from console format - out.plain += _text + out += _text } if (data.translate) { - let trans = data.translate.replace(/%%/g, '\ue123').replaceAll('\x1b', '').replaceAll('\x0e', '') // Remove escape codes from console format let trans2 = data.translate.replace(/%%/g, '\ue123') if (lang[trans] !== undefined) { trans = lang[trans].replace(/%%/g, '\ue123') trans2 = lang[trans2].replace(/%%/g, '\ue123') } for (const i in data.with) { - const j2 = parse(data.with[i], l + 1, data.color ? processColor(data.color, resetColor) : resetColor) - trans = trans.replace(/%s/, j2.console.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) - trans2 = trans2.replace(/%s/, j2.plain.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) - trans = trans.replaceAll(`%${+i + 1}$s`, j2.console.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) - trans2 = trans2.replaceAll(`%${+i + 1}$s`, j2.plain.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + const j2 = parse(data.with[i], l + 1) + trans2 = trans2.replace(/%s/, j2.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + trans2 = trans2.replaceAll(`%${+i + 1}$s`, j2.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) } - out.console += trans.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s') - out.plain += trans2.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s') + out += trans2.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s') } if (data.extra) { for (const i in data.extra) { - const parsed = parse(data.extra[i], l, data.color ? processColor(data.color, resetColor) : resetColor) - out.console += parsed.console - out.plain += parsed.plain + const parsed = parse(data.extra[i], l) + out += parsed } } - out.console += resetColor return out } -const parse2 = function (_data, l, resetColor) { +const parse2 = function (_data, l) { try { return parse(_data) } catch (e) { console.error(e) - return { - console: '\x1B[0m\x1B[38;2;255;85;85mAn error occured while parsing a message. See console for more information.\nJSON that caused the error: ' + JSON.stringify(_data), - plain: 'An error occured while parsing a message. See console for more information. JSON that caused the error: ' + JSON.stringify(_data) - } + return 'An error occured while parsing a message. See console for more information. JSON that caused the error: ' + JSON.stringify(_data) } } module.exports = parse2 diff --git a/util/mc_lang.js b/util/mc_lang.js new file mode 100644 index 0000000..67f656d --- /dev/null +++ b/util/mc_lang.js @@ -0,0 +1,6 @@ +const _lang = require('minecraft-data')('1.20.2').language; +const lang = Object.create(null) // Without constructor function +for (const i in _lang) { + lang[i] = _lang[i] +} +module.exports=lang \ No newline at end of file From 7bad033c971ff54a6ecaa0161569c4b52731e540 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Thu, 1 Aug 2024 20:32:14 -0400 Subject: [PATCH 256/362] Finish chat parser rewrite --- plugins/!chat.js | 37 +++++++++++++++++++------------------ util/chatparse_plain.js | 11 +++++------ 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/plugins/!chat.js b/plugins/!chat.js index b667531..b52eb9a 100755 --- a/plugins/!chat.js +++ b/plugins/!chat.js @@ -1,6 +1,7 @@ const settings = require('../settings.json') const console2 = require('./console.js') -const parse = require('../util/chatparse.js') +const parsePlain = require('../util/chatparse_plain.js') +const parseConsole = require('../util/chatparse_console.js') const parse1204 = require('../util/chatparse_1204.js') const messageTypes = [ '', @@ -17,7 +18,7 @@ module.exports = { b._client.on('profileless_chat', (data) => { if (data.type === 4) { const json = parse1204(data.message) - const parsed = parse(json).plain + const parsed = parsePlain(json).plain const split = parsed.split(': ') const chatName = split.splice(0, 1)[0] const username = b.findRealName(chatName) @@ -35,15 +36,15 @@ module.exports = { }, type: 'profileless', uuid: '00000000-0000-0000-0000-000000000000', - message: parse(parse1204(data.message)).plain, - username: parse(parse1204(data.name)).plain + message: parsePlain(parse1204(data.message)), + username: parsePlain(parse1204(data.name)) }) } }) b._client.on('player_chat', (data) => { if (data.type === 4) { - b.emit('chat', { json: parse1204(data.unsignedChatContent), type: 'player', uuid: data.senderUuid, message: data.plainMessage, username: parse(parse1204(data.networkName)).plain }) + b.emit('chat', { json: parse1204(data.unsignedChatContent), type: 'player', uuid: data.senderUuid, message: data.plainMessage, username: parsePlain(parse1204(data.networkName)) }) } else { b.emit('chat', { json: { @@ -56,14 +57,14 @@ module.exports = { }, type: 'player', uuid: data.senderUuid, - message: parse(data.plainMessage).plain, - username: parse(parse1204(data.networkName)).plain + message: parsePlain(data.plainMessage), + username: parsePlain(parse1204(data.networkName)) }) } }) b._client.on('system_chat', (data) => { const json = parse1204(data.content) - const parsed = parse(json).plain + const parsed = parsePlain(json) const split = parsed.split(': ') const chatName = split.splice(0, 1)[0] const username = b.findRealName(chatName) @@ -72,14 +73,14 @@ module.exports = { }) b._client.on('chat', (data) => { // Legacy chat const json = parse1204(data.message) - const parsed = parse(json).plain + const parsed = parsePlain(json) let chatName let username let message; let uuid; if(b.host.options.isVanilla && json.translate === "chat.type.text"){ // Servers without Extras chat - message = parse(json.with[1]).plain; - username = parse(json.with[0]).plain; + message = parsePlain(json.with[1]); + username = parsePlain(json.with[0]); uuid = b.findUUID(username); } else { // Servers with Extras chat, such as Kaboom const split = parsed.split(': ') @@ -91,12 +92,13 @@ module.exports = { b.emit('chat', { json, type: 'legacy', uuid: data.uuid ? data.uuid : uuid, message, username }) }) b.on('chat', (data) => { - const msg = parse(data.json) + const msgConsole = parseConsole(data.json) + const msgPlain = parsePlain(data.json) if(settings.logJSONmessages) console.log(data.json) - if (msg.plain.endsWith('\n\n\n\n\nThe chat has been cleared')) return - if (msg.plain.startsWith('Command set: ')) return - b.emit('plainchat', msg.plain) - console2.write(`[${b.id}] [${data.type}] ${msg.console}\x1b[0m`) + if (msgPlain.endsWith('\n\n\n\n\nThe chat has been cleared')) return + if (msgPlain.startsWith('Command set: ')) return + b.emit('plainchat', msgPlain) + console2.write(`[${b.id}] [${data.type}] ${msgConsole}\x1b[0m`) const fullCommand = data.message for (const i in b.prefix) { @@ -106,6 +108,5 @@ module.exports = { } } }) - }, - parse + } } diff --git a/util/chatparse_plain.js b/util/chatparse_plain.js index c8523ec..f35f19b 100644 --- a/util/chatparse_plain.js +++ b/util/chatparse_plain.js @@ -15,7 +15,7 @@ const parse = function (_data, l = 0) { data = _data } let nkt = false - const out = "" + let out = "" if (data['']) { data.text = data[''] nkt = true @@ -28,17 +28,16 @@ const parse = function (_data, l = 0) { out += _text } if (data.translate) { - let trans2 = data.translate.replace(/%%/g, '\ue123') + let trans = data.translate.replace(/%%/g, '\ue123') if (lang[trans] !== undefined) { trans = lang[trans].replace(/%%/g, '\ue123') - trans2 = lang[trans2].replace(/%%/g, '\ue123') } for (const i in data.with) { const j2 = parse(data.with[i], l + 1) - trans2 = trans2.replace(/%s/, j2.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) - trans2 = trans2.replaceAll(`%${+i + 1}$s`, j2.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + trans = trans.replace(/%s/, j2.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + trans = trans.replaceAll(`%${+i + 1}$s`, j2.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) } - out += trans2.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s') + out += trans.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s') } if (data.extra) { for (const i in data.extra) { From b1724744a011f368ef3bbbb2316b165eb4cfc538 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Thu, 1 Aug 2024 21:40:58 -0400 Subject: [PATCH 257/362] OMAGAD ONEPLUS --- plugins/!chat.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/!chat.js b/plugins/!chat.js index b52eb9a..add115c 100755 --- a/plugins/!chat.js +++ b/plugins/!chat.js @@ -18,7 +18,7 @@ module.exports = { b._client.on('profileless_chat', (data) => { if (data.type === 4) { const json = parse1204(data.message) - const parsed = parsePlain(json).plain + const parsed = parsePlain(json) const split = parsed.split(': ') const chatName = split.splice(0, 1)[0] const username = b.findRealName(chatName) From 4f289a88cfffc670c064aed4b8fb4b24d314c06c Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Fri, 2 Aug 2024 13:53:41 -0400 Subject: [PATCH 258/362] From the other repo (I also use SSH now!) --- package-lock.json | 6 +++--- plugins/commands/about.js | 10 ++++++++++ util/lang/en-US.json | 3 ++- util/lang/en-UW.json | 3 ++- version.json | 2 ++ 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2078e41..b616ba8 100755 --- a/package-lock.json +++ b/package-lock.json @@ -37,9 +37,9 @@ } }, "node_modules/@types/node": { - "version": "22.0.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.0.0.tgz", - "integrity": "sha512-VT7KSYudcPOzP5Q0wfbowyNLaVR8QWUdw+088uFWwfvpY6uCWaXpqV6ieLAu9WBcnTa7H4Z5RLK8I5t2FuOcqw==", + "version": "22.0.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.0.2.tgz", + "integrity": "sha512-yPL6DyFwY5PiMVEwymNeqUTKsDczQBJ/5T7W/46RwLU/VH+AA8aT5TZkvBviLKLbbm0hlfftEkGrNzfRk/fofQ==", "license": "MIT", "dependencies": { "undici-types": "~6.11.1" diff --git a/plugins/commands/about.js b/plugins/commands/about.js index 02047bf..827786d 100644 --- a/plugins/commands/about.js +++ b/plugins/commands/about.js @@ -10,6 +10,10 @@ module.exports = { { text: version.botName, color: c.colors.primary + }, + { + text: version.botAuthor, + color: c.colors.primary } ] }) @@ -63,6 +67,12 @@ module.exports = { ] }) } + if(version.isPreRelease){ + c.reply({ + text: getMessage(c.lang, 'command.about.preRelease'), + color: c.colors.secondary, + }) + } c.reply({ text: '' }) c.reply({ translate: getMessage(c.lang, 'command.about.sourceCode'), diff --git a/util/lang/en-US.json b/util/lang/en-US.json index 1177e9a..8a37736 100644 --- a/util/lang/en-US.json +++ b/util/lang/en-US.json @@ -37,8 +37,9 @@ "command.tpr.usage": "", "command.verify.usage": " [args...]", "command.verify.desc": "Check the hashing system", - "command.about.author": "%s - a Minecraft bot made by 77c8f4699b732c11 / a5a06d596f15c7db", + "command.about.author": "%s - a Minecraft bot made by %s for Kaboom and clones", "command.about.version": "Version %s", + "command.about.preRelease": "This is prerelease software - there may be errors, and features may be changed or removed at any time.", "command.about.sourceCode": "Source code: %s", "command.about.sourceCode.openInBrowser": "Click to open the source code link in your default browser", "command.about.serverinfo": "To view system information, run the command %s.", diff --git a/util/lang/en-UW.json b/util/lang/en-UW.json index 7a40c14..9ef0045 100644 --- a/util/lang/en-UW.json +++ b/util/lang/en-UW.json @@ -37,8 +37,9 @@ "command.tpr.usage": "", "command.verify.usage": " [awgs...]", "command.verify.desc": "Check the hashing system", - "command.about.author": "%s - a Minyecwaft bot made by 77c8f4699b732c11 / a5a06d596f15c7db", + "command.about.author": "%s - a Minyecwaft bot made by %s", "command.about.version": "Vewsion %s", + "command.about.preRelease": "This is pwewewease softwawe - thewe may be ewwows, and featuwes may be changed ow wemoved at any time.", "command.about.sourceCode": "Souwce code: %s", "command.about.sourceCode.openInBrowser": "Cwick to open the souwce code wink in youw defauwt bwowsew", "command.about.serverinfo": "To view system infowmation, wun the command %s.", diff --git a/version.json b/version.json index 4ad5b1a..41dbd4e 100644 --- a/version.json +++ b/version.json @@ -1,5 +1,7 @@ { "botName": "botvX Dev", "botVersion": "10.0.0-beta.1", + "botAuthor": "a5a06d596f15c7db", + "isPreRelease": true, "sourceURL": "https://code.chipmunk.land/7cc5c4f330d47060/botvX" } From 2565a073a34b6efce7a1859f21c7e80f77744926 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Fri, 2 Aug 2024 13:57:53 -0400 Subject: [PATCH 259/362] Testing --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index dff16e0..7c4cb84 100644 --- a/README.md +++ b/README.md @@ -40,3 +40,4 @@ botvX is a Minecraft bot for [Kaboom](https://kaboom.pw/) and its clones. It has | template | | Used in development, does nothing | | tpr | | Teleport to a random location | | verify | | Check the hashing system | + From 735ebb1f2c01817d0da1affbd2fc917d67f18654 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Fri, 2 Aug 2024 14:02:52 -0400 Subject: [PATCH 260/362] Update example configurations --- secret_example.json | 4 ++-- settings_example.json | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/secret_example.json b/secret_example.json index 61a3ce8..6505d76 100644 --- a/secret_example.json +++ b/secret_example.json @@ -1,4 +1,4 @@ { - "keyTrusted": "Insert trusted level key here...", - "keyOwner": "Insert owner level key here..." + "keyTrusted": "Insert trusted level key here... (PLEASE CHANGE THIS, THIS KEY IS PUBLIC)", + "keyOwner": "Insert owner level key here... (PLEASE CHANGE THIS, THIS KEY IS PUBLIC)" } diff --git a/settings_example.json b/settings_example.json index 5a393ab..9bbe804 100755 --- a/settings_example.json +++ b/settings_example.json @@ -3,6 +3,7 @@ "name": "Minecraft Bot", "version_mc": "1.20.4", "defaultLang": "en-US", + "terminalMode": "blackTerminal_24bit", "colors": { "primary": "#FFCCEE", "secondary": "#FF99DD" From 5bb0c8f00e536bdf92d0c5b26dc3a589a57e5cb7 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sat, 3 Aug 2024 03:00:04 -0400 Subject: [PATCH 261/362] Seperate command loader --- {plugins/commands => commands}/about.js | 4 +-- {plugins/commands => commands}/cb.js | 0 {plugins/commands => commands}/cloop.js | 2 +- {plugins/commands => commands}/eval.js | 2 +- {plugins/commands => commands}/help.js | 0 {plugins/commands => commands}/logoff.js | 0 {plugins/commands => commands}/netmsg.js | 2 +- {plugins/commands => commands}/refill.js | 0 {plugins/commands => commands}/restart.js | 0 {plugins/commands => commands}/say.js | 0 {plugins/commands => commands}/serverinfo.js | 4 +-- {plugins/commands => commands}/stop.js | 0 {plugins/commands => commands}/template.js | 0 {plugins/commands => commands}/tpr.js | 2 +- {plugins/commands => commands}/verify.js | 0 plugins/command.js | 32 ++------------------ plugins/console.js | 12 ++++---- util/ConsoleCommand.js | 2 +- util/commands.js | 29 ++++++++++++++++++ 19 files changed, 46 insertions(+), 45 deletions(-) rename {plugins/commands => commands}/about.js (96%) rename {plugins/commands => commands}/cb.js (100%) rename {plugins/commands => commands}/cloop.js (97%) rename {plugins/commands => commands}/eval.js (59%) rename {plugins/commands => commands}/help.js (100%) rename {plugins/commands => commands}/logoff.js (100%) rename {plugins/commands => commands}/netmsg.js (94%) rename {plugins/commands => commands}/refill.js (100%) rename {plugins/commands => commands}/restart.js (100%) rename {plugins/commands => commands}/say.js (100%) rename {plugins/commands => commands}/serverinfo.js (97%) rename {plugins/commands => commands}/stop.js (100%) rename {plugins/commands => commands}/template.js (100%) rename {plugins/commands => commands}/tpr.js (95%) rename {plugins/commands => commands}/verify.js (100%) create mode 100644 util/commands.js diff --git a/plugins/commands/about.js b/commands/about.js similarity index 96% rename from plugins/commands/about.js rename to commands/about.js index 827786d..2ae70d6 100644 --- a/plugins/commands/about.js +++ b/commands/about.js @@ -1,5 +1,5 @@ -const version = require('../../version.json') -const {getMessage} = require('../../util/lang.js') +const version = require('../version.json') +const {getMessage} = require('../util/lang.js') const cp = require('child_process') module.exports = { execute: function (c) { diff --git a/plugins/commands/cb.js b/commands/cb.js similarity index 100% rename from plugins/commands/cb.js rename to commands/cb.js diff --git a/plugins/commands/cloop.js b/commands/cloop.js similarity index 97% rename from plugins/commands/cloop.js rename to commands/cloop.js index 3d93eeb..dac4f98 100644 --- a/plugins/commands/cloop.js +++ b/commands/cloop.js @@ -1,4 +1,4 @@ -const {getMessage} = require('../../util/lang.js') +const {getMessage} = require('../util/lang.js') module.exports = { execute: (c) => { const subcmd = c.args.splice(0, 1)[0] diff --git a/plugins/commands/eval.js b/commands/eval.js similarity index 59% rename from plugins/commands/eval.js rename to commands/eval.js index 8ed1fa9..fb5090a 100644 --- a/plugins/commands/eval.js +++ b/commands/eval.js @@ -1,4 +1,4 @@ -const index = require('../../index.js') // Not used in the code, but may be used by users of the command +const index = require('../index.js') // Not used in the code, but may be used by users of the command module.exports = { execute: (c) => { try { diff --git a/plugins/commands/help.js b/commands/help.js similarity index 100% rename from plugins/commands/help.js rename to commands/help.js diff --git a/plugins/commands/logoff.js b/commands/logoff.js similarity index 100% rename from plugins/commands/logoff.js rename to commands/logoff.js diff --git a/plugins/commands/netmsg.js b/commands/netmsg.js similarity index 94% rename from plugins/commands/netmsg.js rename to commands/netmsg.js index b3acbac..c4f9a33 100644 --- a/plugins/commands/netmsg.js +++ b/commands/netmsg.js @@ -1,4 +1,4 @@ -const { bot } = require('../../index.js') +const { bot } = require('../index.js') module.exports = { execute: (c) => { const json = { diff --git a/plugins/commands/refill.js b/commands/refill.js similarity index 100% rename from plugins/commands/refill.js rename to commands/refill.js diff --git a/plugins/commands/restart.js b/commands/restart.js similarity index 100% rename from plugins/commands/restart.js rename to commands/restart.js diff --git a/plugins/commands/say.js b/commands/say.js similarity index 100% rename from plugins/commands/say.js rename to commands/say.js diff --git a/plugins/commands/serverinfo.js b/commands/serverinfo.js similarity index 97% rename from plugins/commands/serverinfo.js rename to commands/serverinfo.js index 4f196db..dd3e9bf 100755 --- a/plugins/commands/serverinfo.js +++ b/commands/serverinfo.js @@ -1,7 +1,7 @@ const os = require('os') const cp = require('child_process') -const version = require('../../version.json') -const {getMessage,formatTime} = require('../../util/lang.js') +const version = require('../version.json') +const {getMessage,formatTime} = require('../util/lang.js') const fs = require('fs') const gr = function (l, text, value, color) { if (!color) color = 'white' diff --git a/plugins/commands/stop.js b/commands/stop.js similarity index 100% rename from plugins/commands/stop.js rename to commands/stop.js diff --git a/plugins/commands/template.js b/commands/template.js similarity index 100% rename from plugins/commands/template.js rename to commands/template.js diff --git a/plugins/commands/tpr.js b/commands/tpr.js similarity index 95% rename from plugins/commands/tpr.js rename to commands/tpr.js index ffd7bf0..4c3dcb2 100755 --- a/plugins/commands/tpr.js +++ b/commands/tpr.js @@ -1,4 +1,4 @@ -const {getMessage} = require('../../util/lang.js') +const {getMessage} = require('../util/lang.js') module.exports = { execute: function (c) { let uuid diff --git a/plugins/commands/verify.js b/commands/verify.js similarity index 100% rename from plugins/commands/verify.js rename to commands/verify.js diff --git a/plugins/command.js b/plugins/command.js index e8b07fb..1fd2878 100755 --- a/plugins/command.js +++ b/plugins/command.js @@ -1,35 +1,8 @@ -const fs = require('fs') const Command = require('../util/Command.js') const hashcheck = require('../util/hashcheck.js') const settings = require('../settings.json') const {getMessage} = require('../util/lang.js') -const cmds = Object.create(null) -const bpl = fs.readdirSync('./plugins/commands') -for (const i in bpl) { // Built-in loadCMD - if (!bpl[i].endsWith('.js')) { - continue - } - try { - const commandName = bpl[i].split('.js')[0] - cmds[commandName] = require(`./commands/${bpl[i]}`) - if (cmds[commandName].level === undefined) { - cmds[commandName].level = 0 - } - console.log('Loaded command ' + commandName) - if (cmds[commandName].aliases) { - for (const j in cmds[commandName].aliases) { - cmds[cmds[commandName].aliases[j]] = { - execute: cmds[commandName].execute, - desc: 'Alias to ' + commandName, - usage: cmds[commandName].usage, - level: cmds[commandName].level, - hidden: true, - consoleIndex: cmds[commandName].consoleIndex - } - } - } - } catch (e) { console.log(e) } -} +const cmds = require("../util/commands.js") const sortHelp = function sortHelp (c1, c2) { const level1 = cmds[c1.with[0]].level ? cmds[c1.with[0]].level : 0 @@ -176,6 +149,5 @@ module.exports = { ] }) } - }, - cmds + } } diff --git a/plugins/console.js b/plugins/console.js index 83d43da..995eb46 100644 --- a/plugins/console.js +++ b/plugins/console.js @@ -1,7 +1,7 @@ const readln = require('readline') const index = require('../index.js') const ConsoleCommand = require('../util/ConsoleCommand.js') -const newercommands = require('./command.js').cmds +const cmds = require("../util/commands.js") const rl = readln.createInterface({ input: process.stdin, output: process.stdout, @@ -9,22 +9,22 @@ const rl = readln.createInterface({ }) rl.on('line', (l) => { try { - if (newercommands[l.split(' ')[0].toLowerCase()]) { - if (newercommands[l.split(' ')[0].toLowerCase()].consoleIndex) { + if (cmds[l.split(' ')[0].toLowerCase()]) { + if (cmds[l.split(' ')[0].toLowerCase()].consoleIndex) { const tmpcmd = l.split(' ') const index2 = tmpcmd.splice(1, 1)[0] if (index2 === '*') { for (let i = 0; i < index.bot.length; i++) { const cmd = new ConsoleCommand(tmpcmd.join(' '), i) - newercommands[l.split(' ')[0].toLowerCase()].execute(cmd) + cmds[l.split(' ')[0].toLowerCase()].execute(cmd) } } else { const cmd = new ConsoleCommand(tmpcmd.join(' '), +index2) - newercommands[l.split(' ')[0].toLowerCase()].execute(cmd) + cmds[l.split(' ')[0].toLowerCase()].execute(cmd) } } else { const cmd = new ConsoleCommand(l, -2) - newercommands[l.split(' ')[0].toLowerCase()].execute(cmd) + cmds[l.split(' ')[0].toLowerCase()].execute(cmd) } } } catch (e) { diff --git a/util/ConsoleCommand.js b/util/ConsoleCommand.js index a7d3b28..c6b0d8a 100644 --- a/util/ConsoleCommand.js +++ b/util/ConsoleCommand.js @@ -1,6 +1,6 @@ // HOW TO WRITE CLASS JS const index = require('../index.js') -const { cmds } = require('../plugins/command.js') +const cmds = require('./commands.js') const parse = require('../util/chatparse_console.js') const settings = require('../settings.json') const {getMessage} = require('../util/lang.js') diff --git a/util/commands.js b/util/commands.js new file mode 100644 index 0000000..7d25194 --- /dev/null +++ b/util/commands.js @@ -0,0 +1,29 @@ +const fs = require('fs') +const cmds = Object.create(null) +const bpl = fs.readdirSync('./commands') +for (const i in bpl) { // Built-in loadCMD + if (!bpl[i].endsWith('.js')) { + continue + } + try { + const commandName = bpl[i].split('.js')[0] + cmds[commandName] = require(`../commands/${bpl[i]}`) + if (cmds[commandName].level === undefined) { + cmds[commandName].level = 0 + } + console.log('Loaded command ' + commandName) + if (cmds[commandName].aliases) { + for (const j in cmds[commandName].aliases) { + cmds[cmds[commandName].aliases[j]] = { + execute: cmds[commandName].execute, + desc: 'Alias to ' + commandName, + usage: cmds[commandName].usage, + level: cmds[commandName].level, + hidden: true, + consoleIndex: cmds[commandName].consoleIndex + } + } + } + } catch (e) { console.log(e) } +} +module.exports=cmds; \ No newline at end of file From 86b839ceba536e1f4cf931a6f2cd8f43807d82be Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sat, 3 Aug 2024 03:09:35 -0400 Subject: [PATCH 262/362] Remove extraneous code --- index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 161c7ed..1206279 100755 --- a/index.js +++ b/index.js @@ -38,8 +38,6 @@ const createBot = function createBot (host, oldId) { username: generateUser(host.options.legalName), version: host.version?host.version:settings.version_mc }) - bot._client.on('success', () => { - }) if (typeof oldId !== 'undefined') { for (const i in module.exports.bot[oldId].interval) { clearInterval(module.exports.bot[oldId].interval[i]) @@ -60,6 +58,10 @@ const createBot = function createBot (host, oldId) { bot.info = (msg) => { console.log(`[${bot.id}] [info] ${msg}`) } + bot.displayChat = (type, msg) => { + console.log(`[${bot.id}] [${type}] ${msg}`) + } + loadplug(bot.id) bot._client.on('error', (err) => { console.log(err) From e8d9039178640edf987204bd901f2ff78e303009 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sat, 3 Aug 2024 03:10:18 -0400 Subject: [PATCH 263/362] Remove unneeded exports from console plugin --- plugins/!chat.js | 4 ++-- plugins/console.js | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/plugins/!chat.js b/plugins/!chat.js index add115c..c8eea28 100755 --- a/plugins/!chat.js +++ b/plugins/!chat.js @@ -98,9 +98,9 @@ module.exports = { if (msgPlain.endsWith('\n\n\n\n\nThe chat has been cleared')) return if (msgPlain.startsWith('Command set: ')) return b.emit('plainchat', msgPlain) - console2.write(`[${b.id}] [${data.type}] ${msgConsole}\x1b[0m`) - const fullCommand = data.message + b.displayChat(data.type,`${msgConsole}\x1b[0m`) + const fullCommand = data.message for (const i in b.prefix) { if (fullCommand.startsWith(b.prefix[i])) { const command = fullCommand.slice(b.prefix[i].length) diff --git a/plugins/console.js b/plugins/console.js index 995eb46..0f8ab7a 100644 --- a/plugins/console.js +++ b/plugins/console.js @@ -44,7 +44,8 @@ module.exports = { b.info = (msg) => { consoleWrite(`[${b.id}] [info] ${msg}`) } - }, - rl, - write: consoleWrite + b.displayChat = (type, msg) => { + consoleWrite(`[${b.id}] [${type}] ${msg}`) + } + } } From 8bb9056e9a6c41d451765ee66e61a699302c0509 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sat, 3 Aug 2024 03:15:04 -0400 Subject: [PATCH 264/362] Add alias to verify command --- commands/verify.js | 1 + 1 file changed, 1 insertion(+) diff --git a/commands/verify.js b/commands/verify.js index f1941a2..c20c39d 100644 --- a/commands/verify.js +++ b/commands/verify.js @@ -7,5 +7,6 @@ module.exports = { text: c.command }) }, + aliases: ['validate'], level: 1 } From 9430f2def1cff256781d2a44c0f066e8ed26c49e Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sat, 3 Aug 2024 03:24:56 -0400 Subject: [PATCH 265/362] Seperate version information getter --- commands/about.js | 61 ++++++++---------------------------------- commands/serverinfo.js | 14 +--------- util/version.js | 19 +++++++++++++ 3 files changed, 31 insertions(+), 63 deletions(-) create mode 100644 util/version.js diff --git a/commands/about.js b/commands/about.js index 2ae70d6..e34891c 100644 --- a/commands/about.js +++ b/commands/about.js @@ -1,6 +1,6 @@ const version = require('../version.json') const {getMessage} = require('../util/lang.js') -const cp = require('child_process') +const botVersion = require('../util/version.js') module.exports = { execute: function (c) { c.reply({ @@ -18,55 +18,16 @@ module.exports = { ] }) c.reply({ text: '' }) - const botVersion = version.botVersion - let gitCommit - let gitBranch - try { - gitCommit = cp.execSync('git rev-parse --short HEAD').toString('UTF-8').split('\n')[0] - gitBranch = cp.execSync('git rev-parse --abbrev-ref HEAD').toString('UTF-8').split('\n')[0] - } catch (e) { - gitCommit = false - gitBranch = false - } - if (gitCommit) { - c.reply({ - translate: getMessage(c.lang, 'command.about.version'), - color: c.colors.secondary, - with: [ - [ - { - text: botVersion, - color: c.colors.primary - }, - { - translate: ' (%s - %s)', - color: c.colors.secondary, - with: [ - { - text: gitCommit, - color: c.colors.primary - }, - { - text: gitBranch, - color: c.colors.primary - } - ] - } - ] - ] - }) - } else { - c.reply({ - translate: getMessage(c.lang, 'command.about.version'), - color: c.colors.secondary, - with: [ - { - text: botVersion, - color: c.colors.primary - } - ] - }) - } + c.reply({ + translate: getMessage(c.lang, 'command.about.version'), + color: c.colors.secondary, + with: [ + { + text: botVersion, + color: c.colors.primary + } + ] + }) if(version.isPreRelease){ c.reply({ text: getMessage(c.lang, 'command.about.preRelease'), diff --git a/commands/serverinfo.js b/commands/serverinfo.js index dd3e9bf..5827676 100755 --- a/commands/serverinfo.js +++ b/commands/serverinfo.js @@ -3,6 +3,7 @@ const cp = require('child_process') const version = require('../version.json') const {getMessage,formatTime} = require('../util/lang.js') const fs = require('fs') +const botVersion = require('../util/version.js') const gr = function (l, text, value, color) { if (!color) color = 'white' return { @@ -82,19 +83,6 @@ module.exports = { c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.os.android.model'), dBrand + ' ' + dModel, c.colors)) } c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.botName'), version.botName, c.colors)) - let botVersion = version.botVersion - let gitCommit - let gitBranch - try { - gitCommit = cp.execSync('git rev-parse --short HEAD').toString('UTF-8').split('\n')[0] - gitBranch = cp.execSync('git rev-parse --abbrev-ref HEAD').toString('UTF-8').split('\n')[0] - } catch (e) { - gitCommit = false - gitBranch = false - } - if (gitCommit) { - botVersion += ` (${gitCommit} - ${gitBranch})` - } c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.botVer'), botVersion, c.colors)) } } diff --git a/util/version.js b/util/version.js new file mode 100644 index 0000000..1c3466b --- /dev/null +++ b/util/version.js @@ -0,0 +1,19 @@ +const version = require('../version.json') +const cp = require('child_process') + +let botVersion = version.botVersion +let gitCommit +let gitBranch + +try { + gitCommit = cp.execSync('git rev-parse --short HEAD').toString('UTF-8').split('\n')[0] + gitBranch = cp.execSync('git rev-parse --abbrev-ref HEAD').toString('UTF-8').split('\n')[0] +} catch (e) { + gitCommit = false + gitBranch = false +} +if (gitCommit) { + botVersion += ` (${gitCommit} - ${gitBranch})` +} + +module.exports=botVersion; \ No newline at end of file From f65de615470c74400302257b137a1bbbbc4d2f41 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sat, 3 Aug 2024 03:26:09 -0400 Subject: [PATCH 266/362] Remove bot name from serverinfo --- commands/serverinfo.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/commands/serverinfo.js b/commands/serverinfo.js index 5827676..efbbcb1 100755 --- a/commands/serverinfo.js +++ b/commands/serverinfo.js @@ -1,6 +1,5 @@ const os = require('os') const cp = require('child_process') -const version = require('../version.json') const {getMessage,formatTime} = require('../util/lang.js') const fs = require('fs') const botVersion = require('../util/version.js') @@ -82,7 +81,6 @@ module.exports = { const dBrand = cp.execSync('getprop ro.product.brand').toString('UTF-8').split('\n')[0] c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.os.android.model'), dBrand + ' ' + dModel, c.colors)) } - c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.botName'), version.botName, c.colors)) c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.botVer'), botVersion, c.colors)) } } From cbf339824337fbb2c2d408329b153dd875f2df93 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sat, 3 Aug 2024 03:54:11 -0400 Subject: [PATCH 267/362] Rewrite help command Yes, the help command loads commands (to prevent errors, it can't use the other command loader) --- commands/help.js | 136 ++++++++++++++++++++++++++++++++++++++++- plugins/command.js | 100 ------------------------------ util/ConsoleCommand.js | 31 +--------- 3 files changed, 135 insertions(+), 132 deletions(-) diff --git a/commands/help.js b/commands/help.js index dc48e31..01b181d 100644 --- a/commands/help.js +++ b/commands/help.js @@ -1,9 +1,141 @@ +const fs = require('fs') +const cmds = Object.create(null) +const bpl = fs.readdirSync('./commands') +const {getMessage} = require('../util/lang.js') + +const sortHelp = function sortHelp (c1, c2) { + const level1 = cmds[c1.with[0]].level ? cmds[c1.with[0]].level : 0 + const level2 = cmds[c2.with[0]].level ? cmds[c2.with[0]].level : 0 + return level1 - level2 +} + +for (const i in bpl) { // Built-in loadCMD to the help command, to prevent circular require + if (!bpl[i].endsWith('.js')) { + continue + } + try { + const commandName = bpl[i].split('.js')[0] + if(commandName != "help") cmds[commandName] = require(`./${bpl[i]}`) + if (cmds[commandName].level === undefined) { + cmds[commandName].level = 0 + } + cmds["help"] = module.exports; + + if (cmds[commandName].aliases) { + for (const j in cmds[commandName].aliases) { + cmds[cmds[commandName].aliases[j]] = { + desc: 'Alias to ' + commandName, + usage: cmds[commandName].usage, + level: cmds[commandName].level, + hidden: true, + consoleIndex: cmds[commandName].consoleIndex + } + } + } + } catch (e) { console.log(e) } +} +const printHelp = (c) => { + const commandList = [] + for (const i in cmds) { + if (cmds[i].hidden) continue + let cmdColor + switch (cmds[i].level) { + case 0: + cmdColor = 'green' + break + case 1: + cmdColor = 'red' + break + case 2: + cmdColor = 'dark_red' + break + case 3: + cmdColor = 'dark_gray' + break + default: + cmdColor = 'gray' + } + commandList.push( + { + translate: '%s ', + color: cmdColor, + with: [ + i + ] + } + ) + } + c.reply({ + translate: '%s %s', + with: [ + getMessage(c.lang, 'command.help.cmdList'), + commandList.sort(sortHelp) + ] + }) +} +const printCmdHelp = (c) => { + const cmd=c.args[0]; + if (!cmds[cmd]) { + b.reply({ text: getMessage(c.lang, 'command.help.noCommand') }) + return + } + let usage = getMessage(c.lang, `command.${cmd}.usage`).split('||') + let desc = getMessage(c.lang, `command.${cmd}.desc`) + if (cmds[cmd].usage) { + usage = cmds[cmd].usage.split('||') + } + if (cmds[cmd].desc) { + desc = cmds[cmd].desc + } + // b.tellraw(uuid,{"text":getMessage(lang,"command.help.commandInfo",[cmd,usage,desc])}); + for (const i in usage) { + c.reply({ + translate: getMessage(c.lang, 'command.help.commandUsage'), + color: c.colors.secondary, + with: [ + { + text: cmd, + color: c.colors.primary + }, + { + text: usage[i], + color: c.colors.primary + } + ] + }) + } + c.reply({ + translate: getMessage(c.lang, 'command.help.commandDesc'), + color: c.colors.secondary, + with: [ + { + text: desc, + color: c.colors.primary + } + ] + }) + const permsN = getMessage(c.lang, 'command.help.permsNormal') + const permsT = getMessage(c.lang, 'command.help.permsTrusted') + const permsO = getMessage(c.lang, 'command.help.permsOwner') + const permsC = getMessage(c.lang, 'command.help.permsConsole') + const rPerms = cmds[cmd].level ? cmds[cmd].level : 0 + c.reply({ + translate: getMessage(c.lang, 'command.help.commandPerms'), + color: c.colors.secondary, + with: [ + { + text: [permsN, permsT, permsO, permsC][rPerms], + color: c.colors.primary + } + ] + }) +} module.exports = { execute: (c) => { if (c.args.length > 0) { - c.bot.printCmdHelp(c.uuid, c.args[0], c.lang, c.colors) + printCmdHelp(c) } else { - c.bot.printHelp(c.uuid, c.prefix, c.lang, c.colors) + printHelp(c) } }, aliases: [ diff --git a/plugins/command.js b/plugins/command.js index 1fd2878..9bebe53 100755 --- a/plugins/command.js +++ b/plugins/command.js @@ -4,11 +4,6 @@ const settings = require('../settings.json') const {getMessage} = require('../util/lang.js') const cmds = require("../util/commands.js") -const sortHelp = function sortHelp (c1, c2) { - const level1 = cmds[c1.with[0]].level ? cmds[c1.with[0]].level : 0 - const level2 = cmds[c2.with[0]].level ? cmds[c2.with[0]].level : 0 - return level1 - level2 -} module.exports = { load: (b) => { b.prefix = settings.prefix @@ -54,100 +49,5 @@ module.exports = { } } } - b.printHelp = (uuid, prefix, lang) => { - const commandList = [] - for (const i in cmds) { - if (cmds[i].hidden) continue - let cmdColor - switch (cmds[i].level) { - case 0: - cmdColor = 'green' - break - case 1: - cmdColor = 'red' - break - case 2: - cmdColor = 'dark_red' - break - case 3: - cmdColor = 'dark_gray' - break - default: - cmdColor = 'gray' - } - commandList.push( - { - translate: '%s ', - color: cmdColor, - with: [ - i - ] - } - ) - } - b.tellraw(uuid, { - translate: '%s %s', - with: [ - getMessage(lang, 'command.help.cmdList'), - commandList.sort(sortHelp) - ] - }) - } - b.printCmdHelp = (uuid, cmd, lang, color) => { - if (!cmds[cmd]) { - b.tellraw(uuid, { text: getMessage(lang, 'command.help.noCommand') }) - return - } - let usage = getMessage(lang, `command.${cmd}.usage`).split('||') - let desc = getMessage(lang, `command.${cmd}.desc`) - if (cmds[cmd].usage) { - usage = cmds[cmd].usage.split('||') - } - if (cmds[cmd].desc) { - desc = cmds[cmd].desc - } - // b.tellraw(uuid,{"text":getMessage(lang,"command.help.commandInfo",[cmd,usage,desc])}); - for (const i in usage) { - b.tellraw(uuid, { - translate: getMessage(lang, 'command.help.commandUsage'), - color: color.secondary, - with: [ - { - text: cmd, - color: color.primary - }, - { - text: usage[i], - color: color.primary - } - ] - }) - } - b.tellraw(uuid, { - translate: getMessage(lang, 'command.help.commandDesc'), - color: color.secondary, - with: [ - { - text: desc, - color: color.primary - } - ] - }) - const permsN = getMessage(lang, 'command.help.permsNormal') - const permsT = getMessage(lang, 'command.help.permsTrusted') - const permsO = getMessage(lang, 'command.help.permsOwner') - const permsC = getMessage(lang, 'command.help.permsConsole') - const rPerms = cmds[cmd].level ? cmds[cmd].level : 0 - b.tellraw(uuid, { - translate: getMessage(lang, 'command.help.commandPerms'), - color: color.secondary, - with: [ - { - text: [permsN, permsT, permsO, permsC][rPerms], - color: color.primary - } - ] - }) - } } } diff --git a/util/ConsoleCommand.js b/util/ConsoleCommand.js index c6b0d8a..addf695 100644 --- a/util/ConsoleCommand.js +++ b/util/ConsoleCommand.js @@ -16,36 +16,7 @@ class ConsoleCommand { this.prefix = '' // prefix does not exist at console this.bot = index2 >= 0 ? index.bot[index2] - : { - printHelp: () => { - const helpCmds = [] - for (const i in cmds) { - // if(cmds[i].hidden) continue; - helpCmds.push(i) - } - console.log(getMessage(lang, 'command.help.cmdList'), helpCmds.join(' ')) - }, - printCmdHelp: (uuid, cmd) => { - let usage = getMessage(lang, `command.${cmd}.usage`).split('||') - let desc = getMessage(lang, `command.${cmd}.desc`) - if (cmds[cmd].usage) { - usage = cmds[cmd].usage.split('||') - } - if (cmds[cmd].desc) { - desc = cmds[cmd].desc - } - for (const i in usage) { - console.log(getMessage(lang, 'command.help.commandUsage', [cmd, usage[i]])) - } - console.log(getMessage(lang, 'command.help.commandDesc', [desc])) - const permsN = getMessage(lang, 'command.help.permsNormal') - const permsT = getMessage(lang, 'command.help.permsTrusted') - const permsO = getMessage(lang, 'command.help.permsOwner') - const permsC = getMessage(lang, 'command.help.permsConsole') - const rPerms = cmds[cmd].level ? cmds[cmd].level : 0 - console.log(getMessage(lang, 'command.help.commandPerms', [[permsN, permsT, permsO, permsC][rPerms]])) - } - } // bot does not exist at console + : {} this.type = 'console' this.index = index2 this.args = cmd.split(' ').slice(1) From be96d80ec777fd0bfba35a92bd9da06d47e7efd3 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sat, 3 Aug 2024 03:56:20 -0400 Subject: [PATCH 268/362] Bugfix --- commands/help.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/help.js b/commands/help.js index 01b181d..19762bd 100644 --- a/commands/help.js +++ b/commands/help.js @@ -76,7 +76,7 @@ const printHelp = (c) => { const printCmdHelp = (c) => { const cmd=c.args[0]; if (!cmds[cmd]) { - b.reply({ text: getMessage(c.lang, 'command.help.noCommand') }) + c.reply({ text: getMessage(c.lang, 'command.help.noCommand') }) return } let usage = getMessage(c.lang, `command.${cmd}.usage`).split('||') From cff85e09758c9e4ac586b332e935e381cccb390b Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sat, 3 Aug 2024 03:58:11 -0400 Subject: [PATCH 269/362] Bugfix --- commands/help.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/commands/help.js b/commands/help.js index 19762bd..dd6b716 100644 --- a/commands/help.js +++ b/commands/help.js @@ -20,19 +20,21 @@ for (const i in bpl) { // Built-in loadCMD to the help command, to prevent circu cmds[commandName].level = 0 } cmds["help"] = module.exports; + } catch (e) { console.log(e) } +} - if (cmds[commandName].aliases) { - for (const j in cmds[commandName].aliases) { - cmds[cmds[commandName].aliases[j]] = { - desc: 'Alias to ' + commandName, - usage: cmds[commandName].usage, - level: cmds[commandName].level, - hidden: true, - consoleIndex: cmds[commandName].consoleIndex - } +for (const i in cmds){ + if (cmds[i].aliases) { + for (const j in cmds[i].aliases) { + cmds[cmds[i].aliases[j]] = { + desc: 'Alias to ' + i, + usage: cmds[i].usage, + level: cmds[i].level, + hidden: true, + consoleIndex: cmds[i].consoleIndex } } - } catch (e) { console.log(e) } + } } const printHelp = (c) => { const commandList = [] From 976b85ac474046fce587797036494bb7ff3972a9 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sat, 3 Aug 2024 04:00:16 -0400 Subject: [PATCH 270/362] Old line --- commands/help.js | 1 + 1 file changed, 1 insertion(+) diff --git a/commands/help.js b/commands/help.js index dd6b716..4ebda1b 100644 --- a/commands/help.js +++ b/commands/help.js @@ -36,6 +36,7 @@ for (const i in cmds){ } } } + const printHelp = (c) => { const commandList = [] for (const i in cmds) { From cfc1912b53341f552bb0cb9aa86e7e4dd0906dcd Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sat, 3 Aug 2024 04:07:07 -0400 Subject: [PATCH 271/362] bUGfix --- commands/help.js | 45 +++++++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/commands/help.js b/commands/help.js index 4ebda1b..43398c1 100644 --- a/commands/help.js +++ b/commands/help.js @@ -15,27 +15,15 @@ for (const i in bpl) { // Built-in loadCMD to the help command, to prevent circu } try { const commandName = bpl[i].split('.js')[0] - if(commandName != "help") cmds[commandName] = require(`./${bpl[i]}`) - if (cmds[commandName].level === undefined) { - cmds[commandName].level = 0 - } - cmds["help"] = module.exports; + if(commandName != "help"){ + cmds[commandName] = require(`./${bpl[i]}`) + if (cmds[commandName].level === undefined) { + cmds[commandName].level = 0 + } + } } catch (e) { console.log(e) } } -for (const i in cmds){ - if (cmds[i].aliases) { - for (const j in cmds[i].aliases) { - cmds[cmds[i].aliases[j]] = { - desc: 'Alias to ' + i, - usage: cmds[i].usage, - level: cmds[i].level, - hidden: true, - consoleIndex: cmds[i].consoleIndex - } - } - } -} const printHelp = (c) => { const commandList = [] @@ -145,3 +133,24 @@ module.exports = { 'heko' // Parker2991 request ] } + +cmds.help = module.exports; // Placed after to ensure that the correct values are added to cmds +if (cmds.help.level === undefined) { + cmds.help.level = 0 +} + +console.log(cmds.help) + +for (const i in cmds){ + if (cmds[i].aliases) { + for (const j in cmds[i].aliases) { + cmds[cmds[i].aliases[j]] = { + desc: 'Alias to ' + i, + usage: cmds[i].usage, + level: cmds[i].level, + hidden: true, + consoleIndex: cmds[i].consoleIndex + } + } + } +} \ No newline at end of file From 3cf976aa336b7b8ba249601aa3fd8a2495d1db07 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sat, 3 Aug 2024 04:14:42 -0400 Subject: [PATCH 272/362] Change comment --- util/chatparse_console.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/chatparse_console.js b/util/chatparse_console.js index fe0ad2e..b7a7257 100644 --- a/util/chatparse_console.js +++ b/util/chatparse_console.js @@ -13,7 +13,7 @@ if(_consoleColors[settings.terminalMode]){ } const hexColorParser = (color) => { - if(!consoleColors24.enabled || consoleColors24.bit!==24){ //Non-24bit hex color parsing is not implemented yet + if(!consoleColors24.enabled || consoleColors24.bit!==24){ // Hex color parsing to the 8 bit and 4 bit modes has not been implemented yet return ""; } let out = '\x1B[0;' From 364c95bb6bc2ea3d192452f2a66b127f262d4115 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sat, 3 Aug 2024 17:26:40 -0400 Subject: [PATCH 273/362] Bugfix vanilla --- plugins/!chat.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/!chat.js b/plugins/!chat.js index c8eea28..81f6a03 100755 --- a/plugins/!chat.js +++ b/plugins/!chat.js @@ -79,8 +79,10 @@ module.exports = { let message; let uuid; if(b.host.options.isVanilla && json.translate === "chat.type.text"){ // Servers without Extras chat - message = parsePlain(json.with[1]); - username = parsePlain(json.with[0]); + if(json.with.length>=2){ + message = parsePlain(json.with[1]); + username = parsePlain(json.with[0]); + } uuid = b.findUUID(username); } else { // Servers with Extras chat, such as Kaboom const split = parsed.split(': ') From 30e346598b99b61da5a5a39b33c308e2f6777d0a Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sat, 3 Aug 2024 17:33:42 -0400 Subject: [PATCH 274/362] =?UTF-8?q?=D1=80=D1=83=D1=81=D1=81=D0=BA=D0=B8?= =?UTF-8?q?=D0=B9=20=D1=8F=D0=B7=D1=8B=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/!chat.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/!chat.js b/plugins/!chat.js index 81f6a03..90786be 100755 --- a/plugins/!chat.js +++ b/plugins/!chat.js @@ -79,7 +79,7 @@ module.exports = { let message; let uuid; if(b.host.options.isVanilla && json.translate === "chat.type.text"){ // Servers without Extras chat - if(json.with.length>=2){ + if(json.with && json.with.length>=2){ message = parsePlain(json.with[1]); username = parsePlain(json.with[0]); } From bede76b31f3c6ff74ab0fce95d17385375820855 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 <7cc5c4f330d47060@noreply.localhost> Date: Sat, 3 Aug 2024 21:12:35 -0400 Subject: [PATCH 275/362] Remove alibaba.com debugger --- commands/help.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/commands/help.js b/commands/help.js index 43398c1..92792e1 100644 --- a/commands/help.js +++ b/commands/help.js @@ -20,11 +20,10 @@ for (const i in bpl) { // Built-in loadCMD to the help command, to prevent circu if (cmds[commandName].level === undefined) { cmds[commandName].level = 0 } - } + } } catch (e) { console.log(e) } } - const printHelp = (c) => { const commandList = [] for (const i in cmds) { @@ -64,6 +63,7 @@ const printHelp = (c) => { ] }) } + const printCmdHelp = (c) => { const cmd=c.args[0]; if (!cmds[cmd]) { @@ -139,8 +139,6 @@ if (cmds.help.level === undefined) { cmds.help.level = 0 } -console.log(cmds.help) - for (const i in cmds){ if (cmds[i].aliases) { for (const j in cmds[i].aliases) { @@ -153,4 +151,4 @@ for (const i in cmds){ } } } -} \ No newline at end of file +} From f9674561ad24cf655b4e1521daceb4a72228e293 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sat, 3 Aug 2024 21:15:05 -0400 Subject: [PATCH 276/362] Bump version --- version.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.json b/version.json index 41dbd4e..71dc8d3 100644 --- a/version.json +++ b/version.json @@ -1,6 +1,6 @@ { "botName": "botvX Dev", - "botVersion": "10.0.0-beta.1", + "botVersion": "10.0.0-beta.2", "botAuthor": "a5a06d596f15c7db", "isPreRelease": true, "sourceURL": "https://code.chipmunk.land/7cc5c4f330d47060/botvX" From 7b73122beef93e4f48c3ab31bc157125dd24dc7c Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sun, 4 Aug 2024 01:19:44 -0400 Subject: [PATCH 277/362] Change secret file path in example settings --- settings_example.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings_example.json b/settings_example.json index 9bbe804..99d00f0 100755 --- a/settings_example.json +++ b/settings_example.json @@ -1,5 +1,5 @@ { - "secret":"C:\\Users\\Username\\Documents\\botvX\\secret.json", + "secret":"/path/to/secrets/file/secret.json", "name": "Minecraft Bot", "version_mc": "1.20.4", "defaultLang": "en-US", From f7bde90840ada31e69b3b3d8bc07bdc1c02686e9 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sun, 4 Aug 2024 01:30:28 -0400 Subject: [PATCH 278/362] Spacing [1] --- commands/template.js | 2 +- index.js | 2 ++ util/version.js | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/commands/template.js b/commands/template.js index 375f1f7..8349332 100644 --- a/commands/template.js +++ b/commands/template.js @@ -23,7 +23,7 @@ module.exports = { replacing (name) with the name of the new command. Some more complex commands may have messages of their own, which should be placed there too. First, insert the following line near the top of the command's file (not in the execute function): - const {getMessage} = require('../../util/lang.js') + const { getMessage } = require('../../util/lang.js') Then, to get a specific message: getMessage(c.lang,"(message key)",[(arguments, in an array (optional))]) For example, this will show the "about" command's redirection to "serverinfo": diff --git a/index.js b/index.js index 1206279..ee1037c 100755 --- a/index.js +++ b/index.js @@ -58,6 +58,7 @@ const createBot = function createBot (host, oldId) { bot.info = (msg) => { console.log(`[${bot.id}] [info] ${msg}`) } + bot.displayChat = (type, msg) => { console.log(`[${bot.id}] [${type}] ${msg}`) } @@ -71,4 +72,5 @@ const createBot = function createBot (host, oldId) { for (const i in settings.servers) { createBot(settings.servers[i]) } + module.exports.createBot = createBot diff --git a/util/version.js b/util/version.js index 1c3466b..83d9aef 100644 --- a/util/version.js +++ b/util/version.js @@ -12,6 +12,7 @@ try { gitCommit = false gitBranch = false } + if (gitCommit) { botVersion += ` (${gitCommit} - ${gitBranch})` } From 240fef627334252ee8cd9f074e74cb9aba14d5ce Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sun, 4 Aug 2024 01:41:32 -0400 Subject: [PATCH 279/362] Lint --- commands/about.js | 8 ++++---- commands/cloop.js | 2 +- commands/help.js | 10 +++++----- commands/serverinfo.js | 2 +- commands/tpr.js | 2 +- index.js | 4 ++-- plugins/!chat.js | 19 +++++++++---------- plugins/command.js | 4 ++-- plugins/commandblock.js | 8 ++++---- plugins/console.js | 2 +- plugins/player.js | 8 ++++---- plugins/selfcare.js | 4 ++-- util/ConsoleCommand.js | 3 --- util/chatparse_console.js | 28 ++++++++++++++-------------- util/chatparse_plain.js | 6 ++---- util/commands.js | 2 +- util/lang.js | 20 ++++++++++---------- util/mc_lang.js | 4 ++-- util/version.js | 2 +- 19 files changed, 66 insertions(+), 72 deletions(-) diff --git a/commands/about.js b/commands/about.js index e34891c..acaaf22 100644 --- a/commands/about.js +++ b/commands/about.js @@ -1,5 +1,5 @@ const version = require('../version.json') -const {getMessage} = require('../util/lang.js') +const { getMessage } = require('../util/lang.js') const botVersion = require('../util/version.js') module.exports = { execute: function (c) { @@ -28,10 +28,10 @@ module.exports = { } ] }) - if(version.isPreRelease){ + if (version.isPreRelease) { c.reply({ text: getMessage(c.lang, 'command.about.preRelease'), - color: c.colors.secondary, + color: c.colors.secondary }) } c.reply({ text: '' }) @@ -55,7 +55,7 @@ module.exports = { text: getMessage(c.lang, 'command.about.sourceCode.openInBrowser') } } - }, + } ] }) c.reply({ text: '' }) diff --git a/commands/cloop.js b/commands/cloop.js index dac4f98..4e349b0 100644 --- a/commands/cloop.js +++ b/commands/cloop.js @@ -1,4 +1,4 @@ -const {getMessage} = require('../util/lang.js') +const { getMessage } = require('../util/lang.js') module.exports = { execute: (c) => { const subcmd = c.args.splice(0, 1)[0] diff --git a/commands/help.js b/commands/help.js index 92792e1..0c52dbf 100644 --- a/commands/help.js +++ b/commands/help.js @@ -1,7 +1,7 @@ const fs = require('fs') const cmds = Object.create(null) const bpl = fs.readdirSync('./commands') -const {getMessage} = require('../util/lang.js') +const { getMessage } = require('../util/lang.js') const sortHelp = function sortHelp (c1, c2) { const level1 = cmds[c1.with[0]].level ? cmds[c1.with[0]].level : 0 @@ -15,7 +15,7 @@ for (const i in bpl) { // Built-in loadCMD to the help command, to prevent circu } try { const commandName = bpl[i].split('.js')[0] - if(commandName != "help"){ + if (commandName !== 'help') { cmds[commandName] = require(`./${bpl[i]}`) if (cmds[commandName].level === undefined) { cmds[commandName].level = 0 @@ -65,7 +65,7 @@ const printHelp = (c) => { } const printCmdHelp = (c) => { - const cmd=c.args[0]; + const cmd = c.args[0] if (!cmds[cmd]) { c.reply({ text: getMessage(c.lang, 'command.help.noCommand') }) return @@ -134,12 +134,12 @@ module.exports = { ] } -cmds.help = module.exports; // Placed after to ensure that the correct values are added to cmds +cmds.help = module.exports // Placed after to ensure that the correct values are added to cmds if (cmds.help.level === undefined) { cmds.help.level = 0 } -for (const i in cmds){ +for (const i in cmds) { if (cmds[i].aliases) { for (const j in cmds[i].aliases) { cmds[cmds[i].aliases[j]] = { diff --git a/commands/serverinfo.js b/commands/serverinfo.js index efbbcb1..44d8b44 100755 --- a/commands/serverinfo.js +++ b/commands/serverinfo.js @@ -1,6 +1,6 @@ const os = require('os') const cp = require('child_process') -const {getMessage,formatTime} = require('../util/lang.js') +const { getMessage, formatTime } = require('../util/lang.js') const fs = require('fs') const botVersion = require('../util/version.js') const gr = function (l, text, value, color) { diff --git a/commands/tpr.js b/commands/tpr.js index 4c3dcb2..5e7c418 100755 --- a/commands/tpr.js +++ b/commands/tpr.js @@ -1,4 +1,4 @@ -const {getMessage} = require('../util/lang.js') +const { getMessage } = require('../util/lang.js') module.exports = { execute: function (c) { let uuid diff --git a/index.js b/index.js index ee1037c..a0a4300 100755 --- a/index.js +++ b/index.js @@ -36,7 +36,7 @@ const createBot = function createBot (host, oldId) { host: host.host, port: host.port ? host.port : 25565, username: generateUser(host.options.legalName), - version: host.version?host.version:settings.version_mc + version: host.version ? host.version : settings.version_mc }) if (typeof oldId !== 'undefined') { for (const i in module.exports.bot[oldId].interval) { @@ -58,7 +58,7 @@ const createBot = function createBot (host, oldId) { bot.info = (msg) => { console.log(`[${bot.id}] [info] ${msg}`) } - + bot.displayChat = (type, msg) => { console.log(`[${bot.id}] [${type}] ${msg}`) } diff --git a/plugins/!chat.js b/plugins/!chat.js index 90786be..d8a2657 100755 --- a/plugins/!chat.js +++ b/plugins/!chat.js @@ -1,5 +1,4 @@ const settings = require('../settings.json') -const console2 = require('./console.js') const parsePlain = require('../util/chatparse_plain.js') const parseConsole = require('../util/chatparse_console.js') const parse1204 = require('../util/chatparse_1204.js') @@ -76,14 +75,14 @@ module.exports = { const parsed = parsePlain(json) let chatName let username - let message; - let uuid; - if(b.host.options.isVanilla && json.translate === "chat.type.text"){ // Servers without Extras chat - if(json.with && json.with.length>=2){ - message = parsePlain(json.with[1]); - username = parsePlain(json.with[0]); + let message + let uuid + if (b.host.options.isVanilla && json.translate === 'chat.type.text') { // Servers without Extras chat + if (json.with && json.with.length >= 2) { + message = parsePlain(json.with[1]) + username = parsePlain(json.with[0]) } - uuid = b.findUUID(username); + uuid = b.findUUID(username) } else { // Servers with Extras chat, such as Kaboom const split = parsed.split(': ') message = split.join(': ') @@ -96,11 +95,11 @@ module.exports = { b.on('chat', (data) => { const msgConsole = parseConsole(data.json) const msgPlain = parsePlain(data.json) - if(settings.logJSONmessages) console.log(data.json) + if (settings.logJSONmessages) console.log(data.json) if (msgPlain.endsWith('\n\n\n\n\nThe chat has been cleared')) return if (msgPlain.startsWith('Command set: ')) return b.emit('plainchat', msgPlain) - b.displayChat(data.type,`${msgConsole}\x1b[0m`) + b.displayChat(data.type, `${msgConsole}\x1b[0m`) const fullCommand = data.message for (const i in b.prefix) { diff --git a/plugins/command.js b/plugins/command.js index 9bebe53..257b80e 100755 --- a/plugins/command.js +++ b/plugins/command.js @@ -1,8 +1,8 @@ const Command = require('../util/Command.js') const hashcheck = require('../util/hashcheck.js') const settings = require('../settings.json') -const {getMessage} = require('../util/lang.js') -const cmds = require("../util/commands.js") +const { getMessage } = require('../util/lang.js') +const cmds = require('../util/commands.js') module.exports = { load: (b) => { diff --git a/plugins/commandblock.js b/plugins/commandblock.js index 16b9f55..435c3e3 100755 --- a/plugins/commandblock.js +++ b/plugins/commandblock.js @@ -97,11 +97,11 @@ module.exports = { } else { finalname = uuid } - let tellrawCommand; - if(b.host.options.isVanilla){ - tellrawCommand = "tellraw"; + let tellrawCommand + if (b.host.options.isVanilla) { + tellrawCommand = 'tellraw' } else { - tellrawCommand = "minecraft:tellraw"; + tellrawCommand = 'minecraft:tellraw' } b.ccq.push(`/${tellrawCommand} ${finalname} ${JSON.stringify(message)}`) } diff --git a/plugins/console.js b/plugins/console.js index 0f8ab7a..c5804e8 100644 --- a/plugins/console.js +++ b/plugins/console.js @@ -1,7 +1,7 @@ const readln = require('readline') const index = require('../index.js') const ConsoleCommand = require('../util/ConsoleCommand.js') -const cmds = require("../util/commands.js") +const cmds = require('../util/commands.js') const rl = readln.createInterface({ input: process.stdin, output: process.stdout, diff --git a/plugins/player.js b/plugins/player.js index ae130ec..4080984 100644 --- a/plugins/player.js +++ b/plugins/player.js @@ -10,11 +10,11 @@ module.exports = { } else if (data.data[i].UUID) { uuid = data.data[i].UUID } - let displayName; - if(data.data[i].displayName !== undefined){ - displayName = data.data[i].displayName; + let displayName + if (data.data[i].displayName !== undefined) { + displayName = data.data[i].displayName } else { - displayName = "Undefined!" + displayName = 'Undefined!' } if (data.data[i].player && data.data[i].player.name !== undefined) { buffer2[uuid] = { realName: data.data[i].player.name, displayName: displayName.plain } diff --git a/plugins/selfcare.js b/plugins/selfcare.js index 699ede0..f1f31bc 100755 --- a/plugins/selfcare.js +++ b/plugins/selfcare.js @@ -44,7 +44,7 @@ module.exports = { }) // Commandspy - if(!b.host.options.isVanilla){ + if (!b.host.options.isVanilla) { b.add_sc_task('cspy', '/cspy on', true, true) b.on('plainchat', (msg) => { if (msg === 'Successfully disabled CommandSpy') { @@ -54,7 +54,7 @@ module.exports = { } }) } - + // Gamemode b.add_sc_task('gamemode', '/minecraft:gamemode creative', true) b._client.on('game_state_change', (p) => { diff --git a/util/ConsoleCommand.js b/util/ConsoleCommand.js index addf695..7c29e3b 100644 --- a/util/ConsoleCommand.js +++ b/util/ConsoleCommand.js @@ -1,10 +1,7 @@ // HOW TO WRITE CLASS JS const index = require('../index.js') -const cmds = require('./commands.js') const parse = require('../util/chatparse_console.js') const settings = require('../settings.json') -const {getMessage} = require('../util/lang.js') -const lang = settings.defaultLang class ConsoleCommand { constructor (cmd, index2) { this.send = () => {} // not needed for console diff --git a/util/chatparse_console.js b/util/chatparse_console.js index b7a7257..2b07167 100644 --- a/util/chatparse_console.js +++ b/util/chatparse_console.js @@ -1,20 +1,20 @@ -const settings = require('../settings.json'); -const lang = require('./mc_lang.js'); +const settings = require('../settings.json') +const lang = require('./mc_lang.js') -const _consoleColors = require("./consolecolors.json"); -let consoleColors; -let consoleColors24; -if(_consoleColors[settings.terminalMode]){ - consoleColors=_consoleColors[settings.terminalMode].fourBit - consoleColors24=_consoleColors[settings.terminalMode].twentyFourBit +const _consoleColors = require('./consolecolors.json') +let consoleColors +let consoleColors24 +if (_consoleColors[settings.terminalMode]) { + consoleColors = _consoleColors[settings.terminalMode].fourBit + consoleColors24 = _consoleColors[settings.terminalMode].twentyFourBit } else { - consoleColors=_consoleColors.none.fourBit - consoleColors24=_consoleColors.none.twentyFourBit + consoleColors = _consoleColors.none.fourBit + consoleColors24 = _consoleColors.none.twentyFourBit } const hexColorParser = (color) => { - if(!consoleColors24.enabled || consoleColors24.bit!==24){ // Hex color parsing to the 8 bit and 4 bit modes has not been implemented yet - return ""; + if (!consoleColors24.enabled || consoleColors24.bit !== 24) { // Hex color parsing to the 8 bit and 4 bit modes has not been implemented yet + return '' } let out = '\x1B[0;' const redChannel = Number('0x' + color.slice(1, 3)) @@ -29,7 +29,7 @@ const hexColorParser = (color) => { } const processColor = (col, rcol) => { - let out; + let out if (col === 'reset') { out = rcol } else if (col.startsWith('#')) { @@ -55,7 +55,7 @@ const parse = function (_data, l = 0, resetColor = consoleColors.reset) { data = _data } let nkt = false - let out = "" + let out = '' if (data['']) { data.text = data[''] nkt = true diff --git a/util/chatparse_plain.js b/util/chatparse_plain.js index f35f19b..c6b2856 100644 --- a/util/chatparse_plain.js +++ b/util/chatparse_plain.js @@ -1,4 +1,4 @@ -const lang = require('./mc_lang.js'); +const lang = require('./mc_lang.js') const parse = function (_data, l = 0) { if (l >= 12) { @@ -14,11 +14,9 @@ const parse = function (_data, l = 0) { } else { data = _data } - let nkt = false - let out = "" + let out = '' if (data['']) { data.text = data[''] - nkt = true } if (data.text) { let _text = data.text diff --git a/util/commands.js b/util/commands.js index 7d25194..e1b9015 100644 --- a/util/commands.js +++ b/util/commands.js @@ -26,4 +26,4 @@ for (const i in bpl) { // Built-in loadCMD } } catch (e) { console.log(e) } } -module.exports=cmds; \ No newline at end of file +module.exports = cmds diff --git a/util/lang.js b/util/lang.js index 6b0d2fe..54dcee8 100644 --- a/util/lang.js +++ b/util/lang.js @@ -35,24 +35,24 @@ module.exports = { const days = Math.floor(time / 86400000) % 7 const weeks = Math.floor(time / 604800000) if (weeks !== 0) { - finalString += weeks; - finalString += `${weeks === 1 ? getMessage(language, "time.week") : getMessage(language, "time.weekPlural")}` + finalString += weeks + finalString += `${weeks === 1 ? getMessage(language, 'time.week') : getMessage(language, 'time.weekPlural')}` } if (days !== 0) { - finalString += days; - finalString += `${days === 1 ? getMessage(language, "time.day") : getMessage(language, "time.dayPlural")}` + finalString += days + finalString += `${days === 1 ? getMessage(language, 'time.day') : getMessage(language, 'time.dayPlural')}` } if (hours !== 0) { - finalString += hours; - finalString += `${hours === 1 ? getMessage(language, "time.hour") : getMessage(language, "time.hourPlural")}` + finalString += hours + finalString += `${hours === 1 ? getMessage(language, 'time.hour') : getMessage(language, 'time.hourPlural')}` } if (minutes !== 0) { - finalString += minutes; - finalString += `${minutes === 1 ? getMessage(language, "time.minute") : getMessage(language, "time.minutePlural")}` + finalString += minutes + finalString += `${minutes === 1 ? getMessage(language, 'time.minute') : getMessage(language, 'time.minutePlural')}` } if (seconds !== 0) { - finalString += seconds; - finalString += `${seconds === 1 ? getMessage(language, "time.second") : getMessage(language, "time.secondPlural")}` + finalString += seconds + finalString += `${seconds === 1 ? getMessage(language, 'time.second') : getMessage(language, 'time.secondPlural')}` } return finalString } diff --git a/util/mc_lang.js b/util/mc_lang.js index 67f656d..971486e 100644 --- a/util/mc_lang.js +++ b/util/mc_lang.js @@ -1,6 +1,6 @@ -const _lang = require('minecraft-data')('1.20.2').language; +const _lang = require('minecraft-data')('1.20.2').language const lang = Object.create(null) // Without constructor function for (const i in _lang) { lang[i] = _lang[i] } -module.exports=lang \ No newline at end of file +module.exports = lang diff --git a/util/version.js b/util/version.js index 83d9aef..5ecf7e5 100644 --- a/util/version.js +++ b/util/version.js @@ -17,4 +17,4 @@ if (gitCommit) { botVersion += ` (${gitCommit} - ${gitBranch})` } -module.exports=botVersion; \ No newline at end of file +module.exports = botVersion From 5fb2bbdf88842a978b8a8cd6407a69edbc248b8a Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sun, 4 Aug 2024 01:42:06 -0400 Subject: [PATCH 280/362] Downgrade to beta 1 --- version.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.json b/version.json index 71dc8d3..41dbd4e 100644 --- a/version.json +++ b/version.json @@ -1,6 +1,6 @@ { "botName": "botvX Dev", - "botVersion": "10.0.0-beta.2", + "botVersion": "10.0.0-beta.1", "botAuthor": "a5a06d596f15c7db", "isPreRelease": true, "sourceURL": "https://code.chipmunk.land/7cc5c4f330d47060/botvX" From cd6ee042ec6278d68576ef1ed1125ebac83506b3 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sun, 4 Aug 2024 01:55:45 -0400 Subject: [PATCH 281/362] Rewrite verify command --- commands/verify.js | 17 +++++++++++++---- util/lang/en-US.json | 1 + util/lang/en-UW.json | 1 + 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/commands/verify.js b/commands/verify.js index c20c39d..5e979f5 100644 --- a/commands/verify.js +++ b/commands/verify.js @@ -1,10 +1,19 @@ +const {getMessage} = require('../util/lang.js') module.exports = { execute: (c) => { + const permsN = getMessage(c.lang, 'command.help.permsNormal') + const permsT = getMessage(c.lang, 'command.help.permsTrusted') + const permsO = getMessage(c.lang, 'command.help.permsOwner') + const permsC = getMessage(c.lang, 'command.help.permsConsole') c.reply({ - text: c.verify + '' - }) - c.reply({ - text: c.command + translate: getMessage(c.lang, "command.verify.success"), + color: c.colors.secondary, + with: [ + { + text: [permsN, permsT, permsO, permsC][c.verify], + color: c.colors.primary + } + ] }) }, aliases: ['validate'], diff --git a/util/lang/en-US.json b/util/lang/en-US.json index 8a37736..1ad70b8 100644 --- a/util/lang/en-US.json +++ b/util/lang/en-US.json @@ -80,6 +80,7 @@ "command.serverinfo.botName": "Bot name", "command.serverinfo.botVer": "Bot version", "command.tpr.success": "Teleporting %s to %s, %s, %s", + "command.verify.success": "Successfully verified with permission level %s", "command.error": "An error occured (check console for more info)", "command.disallowed.perms": "You do not have permission to run this command. If you do have permission, please make sure you put the command hash at the end, or ran the command through your client's hashing system.", "command.disallowed.perms.yourLevel": "Your permission level: %s", diff --git a/util/lang/en-UW.json b/util/lang/en-UW.json index 9ef0045..5141028 100644 --- a/util/lang/en-UW.json +++ b/util/lang/en-UW.json @@ -80,6 +80,7 @@ "command.serverinfo.botName": "Bot nyame", "command.serverinfo.botVer": "Bot vewsion", "command.tpr.success": "Tewepowting %s to %s, %s, %s", + "command.verify.success": "Successfuwwy vewified with pewmission wevew %s", "command.error": "An ewwow occuwed (check consowe fow mowe info)", "command.disallowed.perms": "You do nyot have pewmission to wun this command. If you do have pewmission, pwease make suwe you put the command hash at the end, ow wan the command thwough youw cwient's hashing system.", "command.disallowed.perms.yourLevel": "Youw pewmission wevew: %s", From 3a2b60a580314632c7c5557d2b884aad5aa8d094 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sun, 4 Aug 2024 02:00:36 -0400 Subject: [PATCH 282/362] Fixed typo --- plugins/selfcare.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/selfcare.js b/plugins/selfcare.js index f1f31bc..7abfe50 100755 --- a/plugins/selfcare.js +++ b/plugins/selfcare.js @@ -28,7 +28,7 @@ module.exports = { b.sc_tasks[name] = new SCTask(failTask, chatCommand, startFailed) } - // Selfcare tasks + // Self care tasks // Operator b.add_sc_task('op', '/op @s[type=player]', true) @@ -43,7 +43,7 @@ module.exports = { } }) - // Commandspy + // CommandSpy if (!b.host.options.isVanilla) { b.add_sc_task('cspy', '/cspy on', true, true) b.on('plainchat', (msg) => { From e2b3b283925c63c3fb3294b57743714b666127cd Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sun, 4 Aug 2024 02:34:36 -0400 Subject: [PATCH 283/362] Spacing [2] --- util/lang.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/util/lang.js b/util/lang.js index 54dcee8..bc7e8cd 100644 --- a/util/lang.js +++ b/util/lang.js @@ -1,5 +1,6 @@ const fs = require('fs') const languages = {} + const loadplug = (botno) => { const bpl = fs.readdirSync('util/lang') for (const i in bpl) { @@ -12,6 +13,7 @@ const loadplug = (botno) => { } } loadplug() + const getMessage = function (l, msg, with2) { let message = msg.replace(/%%/g, '\ue123') if (languages[l] && languages[l][message] !== undefined) { @@ -25,6 +27,7 @@ const getMessage = function (l, msg, with2) { } return message.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s') } + module.exports = { getMessage, formatTime: function (time, language) { From d91adb5ff27b968ca4e493e9e162e472d015273b Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sun, 4 Aug 2024 02:49:20 -0400 Subject: [PATCH 284/362] Spacing [3] --- plugins/console.js | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/console.js b/plugins/console.js index c5804e8..f025f92 100644 --- a/plugins/console.js +++ b/plugins/console.js @@ -33,6 +33,7 @@ rl.on('line', (l) => { rl.prompt(false) }) rl.prompt() + function consoleWrite (text) { readln.cursorTo(process.stdout, 0) readln.clearLine(process.stdout, 0) From b2dba835a9d4ec587b4d8618c80bd1fc3991dc8c Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sun, 4 Aug 2024 02:49:42 -0400 Subject: [PATCH 285/362] Chat parser fix --- util/chatparse_console.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/util/chatparse_console.js b/util/chatparse_console.js index 2b07167..0af6a67 100644 --- a/util/chatparse_console.js +++ b/util/chatparse_console.js @@ -1,7 +1,7 @@ const settings = require('../settings.json') const lang = require('./mc_lang.js') - const _consoleColors = require('./consolecolors.json') + let consoleColors let consoleColors24 if (_consoleColors[settings.terminalMode]) { @@ -54,12 +54,12 @@ const parse = function (_data, l = 0, resetColor = consoleColors.reset) { } else { data = _data } - let nkt = false - let out = '' if (data['']) { - data.text = data[''] - nkt = true + data.text = data['']; + if(!data.color) data.color="reset"; } + + let out = '' if (data.color) { out += processColor(data.color, resetColor) } else { @@ -70,9 +70,6 @@ const parse = function (_data, l = 0, resetColor = consoleColors.reset) { if (typeof _text === 'number') { _text = _text.toString() } - if (nkt) { - out += resetColor - } out += _text.replaceAll('\x1b', '').replaceAll('\x0e', '') // Remove escape codes and [SO] from console format } if (data.translate) { From 8fb9fdb33704676768f6a86c88af5eb9496f4c41 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sun, 4 Aug 2024 02:50:26 -0400 Subject: [PATCH 286/362] Make the console's UUID an "actual" UUID --- util/ConsoleCommand.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/ConsoleCommand.js b/util/ConsoleCommand.js index 7c29e3b..1a4f3e9 100644 --- a/util/ConsoleCommand.js +++ b/util/ConsoleCommand.js @@ -6,7 +6,7 @@ class ConsoleCommand { constructor (cmd, index2) { this.send = () => {} // not needed for console this.reply = text => process.stdout.write(parse(text) + '\n') - this.uuid = 'dde5a2a6-ebdd-4bbb-8eac-f75b10c10446_console' // hard-coded because uuid does not exist at console + this.uuid = 'dde5a2a6-ebdd-7bbb-8eac-f75b10c10446' // hard-coded because uuid does not exist at console this.username = 'Owner' this.nickname = 'Console' this.command = cmd From 2fe65e23d1e33c139fdd18d11a2cb3016346c374 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sun, 4 Aug 2024 02:51:52 -0400 Subject: [PATCH 287/362] Spacing [4] --- util/chatparse_plain.js | 1 - 1 file changed, 1 deletion(-) diff --git a/util/chatparse_plain.js b/util/chatparse_plain.js index c6b2856..385c724 100644 --- a/util/chatparse_plain.js +++ b/util/chatparse_plain.js @@ -1,5 +1,4 @@ const lang = require('./mc_lang.js') - const parse = function (_data, l = 0) { if (l >= 12) { return ['', '', ''] From 22689b3a697cec246e1fb01c12a4c55334c85f44 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sun, 4 Aug 2024 02:53:11 -0400 Subject: [PATCH 288/362] Remove extraneous comment in command loader --- util/commands.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/commands.js b/util/commands.js index e1b9015..62655be 100644 --- a/util/commands.js +++ b/util/commands.js @@ -1,7 +1,7 @@ const fs = require('fs') const cmds = Object.create(null) const bpl = fs.readdirSync('./commands') -for (const i in bpl) { // Built-in loadCMD +for (const i in bpl) { if (!bpl[i].endsWith('.js')) { continue } From 783548a415afbd179d92a3b19ae9c34efeea1b91 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sun, 4 Aug 2024 03:04:09 -0400 Subject: [PATCH 289/362] Increase chat length limit to 255 --- plugins/cq.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/cq.js b/plugins/cq.js index 4cdbae5..e4065ba 100755 --- a/plugins/cq.js +++ b/plugins/cq.js @@ -11,7 +11,7 @@ module.exports = { b.chatqueue = [] b.chat = function chat (msg) { if (msg.length === 0) return - msg.match(/.{1,250}/g).forEach(element => { + msg.match(/.{1,255}/g).forEach(element => { b.chatqueue.push(element) }) } From 3f41fb4f1649caa9fc6a4e01bed19a8962d65a62 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sun, 4 Aug 2024 03:06:34 -0400 Subject: [PATCH 290/362] Rename x1-z1 to x-z --- plugins/commandblock.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/plugins/commandblock.js b/plugins/commandblock.js index 435c3e3..3ef08f8 100755 --- a/plugins/commandblock.js +++ b/plugins/commandblock.js @@ -16,9 +16,9 @@ module.exports = { b._client.write('update_command_block', { command: b.ccq[0], location: { - x: b.commandPos.x1 + b.blocknoX, - y: b.commandPos.y1 + b.blocknoY, - z: b.commandPos.z1 + b.blocknoZ + x: b.commandPos.x + b.blocknoX, + y: b.commandPos.y + b.blocknoY, + z: b.commandPos.z + b.blocknoZ }, mode: 2, flags: 1 @@ -26,9 +26,9 @@ module.exports = { b._client.write('update_command_block', { command: b.ccq[0], location: { - x: b.commandPos.x1 + b.blocknoX, - y: b.commandPos.y1 + b.blocknoY, - z: b.commandPos.z1 + b.blocknoZ + x: b.commandPos.x + b.blocknoX, + y: b.commandPos.y + b.blocknoY, + z: b.commandPos.z + b.blocknoZ }, mode: 2, flags: 5 @@ -82,9 +82,9 @@ module.exports = { } b.commandPos = { - x1: Math.floor(a.x), - z1: Math.floor(a.z), - y1: 55 + x: Math.floor(a.x), + z: Math.floor(a.z), + y: 55 } b._client.write('teleport_confirm', { teleportId: a.teleportId }) }) From 3555dba5cb73636e8eec36b8b437a80086c0d707 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sun, 4 Aug 2024 03:08:21 -0400 Subject: [PATCH 291/362] Spacing [5] --- plugins/commandblock.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/commandblock.js b/plugins/commandblock.js index 3ef08f8..d6cc39b 100755 --- a/plugins/commandblock.js +++ b/plugins/commandblock.js @@ -48,6 +48,7 @@ module.exports = { } b.ccq.splice(0, 1) } + b._client.on('login', () => { b.add_sc_task('cc', '/fill ~ 55 ~ ~3 60 ~3 command_block{CustomName:\'{"translate":"%s %s","with":[{"translate":"entity.minecraft.ender_dragon"},{"translate":"language.region"}],"color":"#FFAAEE"}\'}', true, true) b.add_sc_task('cc_size', '/gamerule commandModificationBlockLimit 32767', true, false, true) @@ -80,7 +81,6 @@ module.exports = { b.sc_tasks.cc.failed = 1 } } - b.commandPos = { x: Math.floor(a.x), z: Math.floor(a.z), @@ -88,6 +88,7 @@ module.exports = { } b._client.write('teleport_confirm', { teleportId: a.teleportId }) }) + b.tellraw = (uuid, message) => { let finalname = '' if (uuid === '@a') { From 3f7c93a0733e8640ac052df50886eebc0caff79d Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sun, 4 Aug 2024 03:13:12 -0400 Subject: [PATCH 292/362] Spacing [6] --- plugins/command.js | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/command.js b/plugins/command.js index 257b80e..bd6d981 100755 --- a/plugins/command.js +++ b/plugins/command.js @@ -3,7 +3,6 @@ const hashcheck = require('../util/hashcheck.js') const settings = require('../settings.json') const { getMessage } = require('../util/lang.js') const cmds = require('../util/commands.js') - module.exports = { load: (b) => { b.prefix = settings.prefix From 46c5afbffd57b7b0d150a19bf3d1114b79ef2f4a Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sun, 4 Aug 2024 03:17:55 -0400 Subject: [PATCH 293/362] Small fixes --- commands/help.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/commands/help.js b/commands/help.js index 0c52dbf..73ee135 100644 --- a/commands/help.js +++ b/commands/help.js @@ -1,6 +1,5 @@ const fs = require('fs') const cmds = Object.create(null) -const bpl = fs.readdirSync('./commands') const { getMessage } = require('../util/lang.js') const sortHelp = function sortHelp (c1, c2) { @@ -9,6 +8,7 @@ const sortHelp = function sortHelp (c1, c2) { return level1 - level2 } +const bpl = fs.readdirSync('./commands') for (const i in bpl) { // Built-in loadCMD to the help command, to prevent circular require if (!bpl[i].endsWith('.js')) { continue @@ -78,7 +78,6 @@ const printCmdHelp = (c) => { if (cmds[cmd].desc) { desc = cmds[cmd].desc } - // b.tellraw(uuid,{"text":getMessage(lang,"command.help.commandInfo",[cmd,usage,desc])}); for (const i in usage) { c.reply({ translate: getMessage(c.lang, 'command.help.commandUsage'), @@ -121,6 +120,7 @@ const printCmdHelp = (c) => { ] }) } + module.exports = { execute: (c) => { if (c.args.length > 0) { From 68fe0d0cd4d6e100dfbe52f731ad6687eae0ca1d Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sun, 4 Aug 2024 03:18:56 -0400 Subject: [PATCH 294/362] Change colors of commands in help command --- commands/help.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/commands/help.js b/commands/help.js index 73ee135..fea9e36 100644 --- a/commands/help.js +++ b/commands/help.js @@ -40,10 +40,10 @@ const printHelp = (c) => { cmdColor = 'dark_red' break case 3: - cmdColor = 'dark_gray' + cmdColor = 'dark_red' break default: - cmdColor = 'gray' + cmdColor = 'green' } commandList.push( { From 3f93683854b79fd2f7413c8cee10b1b192325d9b Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sun, 4 Aug 2024 03:23:57 -0400 Subject: [PATCH 295/362] Spacing [7] --- plugins/!chat.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/!chat.js b/plugins/!chat.js index d8a2657..b01c3e6 100755 --- a/plugins/!chat.js +++ b/plugins/!chat.js @@ -61,6 +61,7 @@ module.exports = { }) } }) + b._client.on('system_chat', (data) => { const json = parse1204(data.content) const parsed = parsePlain(json) @@ -70,6 +71,7 @@ module.exports = { const uuid = b.findUUID(username) b.emit('chat', { json, type: 'system', uuid, message: split.join(': '), username }) }) + b._client.on('chat', (data) => { // Legacy chat const json = parse1204(data.message) const parsed = parsePlain(json) @@ -92,6 +94,7 @@ module.exports = { } b.emit('chat', { json, type: 'legacy', uuid: data.uuid ? data.uuid : uuid, message, username }) }) + b.on('chat', (data) => { const msgConsole = parseConsole(data.json) const msgPlain = parsePlain(data.json) From cd0492364ff6ad06dd372e2e7bed132aef50cadb Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sun, 4 Aug 2024 03:27:23 -0400 Subject: [PATCH 296/362] Spacing [8] --- commands/serverinfo.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/commands/serverinfo.js b/commands/serverinfo.js index 44d8b44..96b3978 100755 --- a/commands/serverinfo.js +++ b/commands/serverinfo.js @@ -3,6 +3,7 @@ const cp = require('child_process') const { getMessage, formatTime } = require('../util/lang.js') const fs = require('fs') const botVersion = require('../util/version.js') + const gr = function (l, text, value, color) { if (!color) color = 'white' return { @@ -46,6 +47,7 @@ const os2 = function (o2, l) { return o2 } } + module.exports = { execute: function (c) { c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.os'), os2(process.platform, c.lang), c.colors)) From 3c73eb3a71aefb6e53d52bb2eff536ce059a0963 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sun, 4 Aug 2024 03:31:17 -0400 Subject: [PATCH 297/362] Fixed uwu translations --- util/lang/en-UW.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/lang/en-UW.json b/util/lang/en-UW.json index 5141028..104aeba 100644 --- a/util/lang/en-UW.json +++ b/util/lang/en-UW.json @@ -48,7 +48,7 @@ "command.cloop.success.add": "Added command woop with command %s and wate %s", "command.cloop.success.remove": "Wemoved command woop %s", "command.cloop.success.clear": "Cweawed aww command woops", - "command.cloop.list": "%s: Command: %s Rate: %s", + "command.cloop.list": "%s: Command: %s Wate: %s", "command.help.cmdList": "Commands:", "command.help.commandInfo": "%s%s - %s", "command.help.commandUsage": "Usage - %s%s", From c3a92f049d3e7111e32862850f6ffd4b1ffeaaca Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sun, 4 Aug 2024 03:54:31 -0400 Subject: [PATCH 298/362] Add more chat formats --- plugins/!chat.js | 42 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/plugins/!chat.js b/plugins/!chat.js index b01c3e6..73a889d 100755 --- a/plugins/!chat.js +++ b/plugins/!chat.js @@ -6,11 +6,11 @@ const messageTypes = [ '', 'chat.type.emote', 'commands.message.display.incoming', - '', + 'commands.message.display.outgoing', '', 'chat.type.announcement', - '', - '' + 'chat.type.team.text', + 'chat.type.team.sent' ] module.exports = { load: (b) => { @@ -23,11 +23,27 @@ module.exports = { const username = b.findRealName(chatName) const uuid = b.findUUID(username) b.emit('chat', { json, type: 'profileless', uuid, message: split.join(': '), username }) + } else if(data.type === 6 || data.type === 7){ + b.emit('chat', { + json: { + translate: messageTypes[data.type], + color: (data.type === 2 || data.type === 3) ? 'gray' : 'reset', + with: [ + parse1204(data.target), + parse1204(data.name), + data.message + ] + }, + type: 'profileless', + uuid: data.senderUuid, + message: parsePlain(data.message), + username: parsePlain(parse1204(data.name)) + }) } else { b.emit('chat', { json: { translate: messageTypes[data.type], - color: data.type === 2 ? 'gray' : 'reset', + color: (data.type === 2 || data.type === 3) ? 'gray' : 'reset', with: [ parse1204(data.name), parse1204(data.message) @@ -44,11 +60,27 @@ module.exports = { b._client.on('player_chat', (data) => { if (data.type === 4) { b.emit('chat', { json: parse1204(data.unsignedChatContent), type: 'player', uuid: data.senderUuid, message: data.plainMessage, username: parsePlain(parse1204(data.networkName)) }) - } else { + } else if(data.type === 6 || data.type === 7){ b.emit('chat', { json: { translate: messageTypes[data.type], color: data.type === 2 ? 'gray' : 'reset', + with: [ + parse1204(data.networkTargetName), + parse1204(data.networkName), + data.plainMessage + ] + }, + type: 'player', + uuid: data.senderUuid, + message: parsePlain(data.plainMessage), + username: parsePlain(parse1204(data.networkName)) + }) + } else { + b.emit('chat', { + json: { + translate: messageTypes[data.type], + color: (data.type === 2 || data.type === 3) ? 'gray' : 'reset', with: [ parse1204(data.networkName), data.plainMessage From 70ad4149840ff30ac9b42137f1cb3350bf27b708 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 <7cc5c4f330d47060@noreply.localhost> Date: Sun, 4 Aug 2024 06:07:58 -0400 Subject: [PATCH 299/362] Lint --- commands/verify.js | 4 ++-- plugins/!chat.js | 6 +++--- util/chatparse_console.js | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/commands/verify.js b/commands/verify.js index 5e979f5..feafb1e 100644 --- a/commands/verify.js +++ b/commands/verify.js @@ -1,4 +1,4 @@ -const {getMessage} = require('../util/lang.js') +const { getMessage } = require('../util/lang.js') module.exports = { execute: (c) => { const permsN = getMessage(c.lang, 'command.help.permsNormal') @@ -6,7 +6,7 @@ module.exports = { const permsO = getMessage(c.lang, 'command.help.permsOwner') const permsC = getMessage(c.lang, 'command.help.permsConsole') c.reply({ - translate: getMessage(c.lang, "command.verify.success"), + translate: getMessage(c.lang, 'command.verify.success'), color: c.colors.secondary, with: [ { diff --git a/plugins/!chat.js b/plugins/!chat.js index 73a889d..fd547a9 100755 --- a/plugins/!chat.js +++ b/plugins/!chat.js @@ -23,7 +23,7 @@ module.exports = { const username = b.findRealName(chatName) const uuid = b.findUUID(username) b.emit('chat', { json, type: 'profileless', uuid, message: split.join(': '), username }) - } else if(data.type === 6 || data.type === 7){ + } else if (data.type === 6 || data.type === 7) { b.emit('chat', { json: { translate: messageTypes[data.type], @@ -60,7 +60,7 @@ module.exports = { b._client.on('player_chat', (data) => { if (data.type === 4) { b.emit('chat', { json: parse1204(data.unsignedChatContent), type: 'player', uuid: data.senderUuid, message: data.plainMessage, username: parsePlain(parse1204(data.networkName)) }) - } else if(data.type === 6 || data.type === 7){ + } else if (data.type === 6 || data.type === 7) { b.emit('chat', { json: { translate: messageTypes[data.type], @@ -126,7 +126,7 @@ module.exports = { } b.emit('chat', { json, type: 'legacy', uuid: data.uuid ? data.uuid : uuid, message, username }) }) - + b.on('chat', (data) => { const msgConsole = parseConsole(data.json) const msgPlain = parsePlain(data.json) diff --git a/util/chatparse_console.js b/util/chatparse_console.js index 0af6a67..a859bff 100644 --- a/util/chatparse_console.js +++ b/util/chatparse_console.js @@ -55,8 +55,8 @@ const parse = function (_data, l = 0, resetColor = consoleColors.reset) { data = _data } if (data['']) { - data.text = data['']; - if(!data.color) data.color="reset"; + data.text = data[''] + if (!data.color) data.color = 'reset' } let out = '' From 94b121255396c867e4f6527426cc7144d9b3c0db Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sun, 4 Aug 2024 06:11:06 -0400 Subject: [PATCH 300/362] Beta 2 --- version.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.json b/version.json index 41dbd4e..71dc8d3 100644 --- a/version.json +++ b/version.json @@ -1,6 +1,6 @@ { "botName": "botvX Dev", - "botVersion": "10.0.0-beta.1", + "botVersion": "10.0.0-beta.2", "botAuthor": "a5a06d596f15c7db", "isPreRelease": true, "sourceURL": "https://code.chipmunk.land/7cc5c4f330d47060/botvX" From 1fb783b6c1e3a7c08a667a899c091768b13b8a62 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sun, 4 Aug 2024 12:58:09 -0400 Subject: [PATCH 301/362] Update packages --- package-lock.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index b616ba8..cf2b5e7 100755 --- a/package-lock.json +++ b/package-lock.json @@ -37,12 +37,12 @@ } }, "node_modules/@types/node": { - "version": "22.0.2", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.0.2.tgz", - "integrity": "sha512-yPL6DyFwY5PiMVEwymNeqUTKsDczQBJ/5T7W/46RwLU/VH+AA8aT5TZkvBviLKLbbm0hlfftEkGrNzfRk/fofQ==", + "version": "22.1.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.1.0.tgz", + "integrity": "sha512-AOmuRF0R2/5j1knA3c6G3HOk523Ga+l+ZXltX8SF1+5oqcXijjfTd8fY3XRZqSihEu9XhtQnKYLmkFaoxgsJHw==", "license": "MIT", "dependencies": { - "undici-types": "~6.11.1" + "undici-types": "~6.13.0" } }, "node_modules/@types/readable-stream": { @@ -762,9 +762,9 @@ "license": "MIT" }, "node_modules/undici-types": { - "version": "6.11.1", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.11.1.tgz", - "integrity": "sha512-mIDEX2ek50x0OlRgxryxsenE5XaQD4on5U2inY7RApK3SOJpofyw7uW2AyfMKkhAxXIceo2DeWGVGwyvng1GNQ==", + "version": "6.13.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.13.0.tgz", + "integrity": "sha512-xtFJHudx8S2DSoujjMd1WeWvn7KKWFRESZTMeL1RptAYERu29D6jphMjjY+vn96jvN3kVPDNxU/E13VTaXj6jg==", "license": "MIT" }, "node_modules/uri-js": { From a2299e51bc6de7056f23c00cd6fd498940ae6e8a Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sun, 4 Aug 2024 17:40:00 -0400 Subject: [PATCH 302/362] Make chat queue faster --- plugins/cq.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/cq.js b/plugins/cq.js index e4065ba..a5ba6f1 100755 --- a/plugins/cq.js +++ b/plugins/cq.js @@ -6,7 +6,7 @@ module.exports = { b._client.chat(b.chatqueue[0]) b.chatqueue.splice(0, 1) } - }, 150) + }, 100) }) b.chatqueue = [] b.chat = function chat (msg) { From 2a0508d0b26879fd80390505531b6841357f3d96 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 5 Aug 2024 18:31:59 -0400 Subject: [PATCH 303/362] Add online mode to example json --- secret_example.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/secret_example.json b/secret_example.json index 6505d76..8d3d67a 100644 --- a/secret_example.json +++ b/secret_example.json @@ -1,4 +1,6 @@ { "keyTrusted": "Insert trusted level key here... (PLEASE CHANGE THIS, THIS KEY IS PUBLIC)", - "keyOwner": "Insert owner level key here... (PLEASE CHANGE THIS, THIS KEY IS PUBLIC)" + "keyOwner": "Insert owner level key here... (PLEASE CHANGE THIS, THIS KEY IS PUBLIC)", + "onlineEmail": "email@example.com", + "onlinePass": "password" } From fd8c7f418dc7bf90faab13b550926c278053d707 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 5 Aug 2024 18:32:14 -0400 Subject: [PATCH 304/362] This should be a boolean --- plugins/commandblock.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/commandblock.js b/plugins/commandblock.js index 16b9f55..55b15b6 100755 --- a/plugins/commandblock.js +++ b/plugins/commandblock.js @@ -7,7 +7,7 @@ module.exports = { b.ccq = [] b.blocknoX = 0 b.blocknoZ = 0 - b.ccStarted = 0 + b.ccStarted = false b.blocknoY = 0 b.pos = { x: 0, y: 0, z: 0, correct: 0 } From a876a2dc5c097977242ce0e16ea91ec016d01282 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 5 Aug 2024 18:33:40 -0400 Subject: [PATCH 305/362] Remove unused v9-era API --- plugins/commandblock.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/commandblock.js b/plugins/commandblock.js index 55b15b6..1154c3d 100755 --- a/plugins/commandblock.js +++ b/plugins/commandblock.js @@ -9,7 +9,7 @@ module.exports = { b.blocknoZ = 0 b.ccStarted = false b.blocknoY = 0 - b.pos = { x: 0, y: 0, z: 0, correct: 0 } + b.pos = { x: 0, y: 0, z: 0 } b.advanceccq = function () { if (b.ccq[0] && b.ccq[0].length !== 0) { @@ -76,7 +76,6 @@ module.exports = { b.pos = { x: a.x, y: a.y, z: a.z, correct: 1 } if (a.x !== b.original_pos.x || a.z !== b.original_pos.z) { b.original_pos = { x: a.x, y: a.y, z: a.z } - b.pos.correct = 0 b.sc_tasks.cc.failed = 1 } } From 69f58623ad09ef512434b762d23c8e05548064f6 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 5 Aug 2024 18:34:56 -0400 Subject: [PATCH 306/362] Huawei P30 Pro --- plugins/commandblock.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/commandblock.js b/plugins/commandblock.js index 1154c3d..8c1b974 100755 --- a/plugins/commandblock.js +++ b/plugins/commandblock.js @@ -71,9 +71,9 @@ module.exports = { b._client.on('position', function (a) { if (!b.ccStarted) { b.original_pos = { x: a.x, y: a.y, z: a.z } - b.pos = { x: a.x, y: a.y, z: a.z, correct: 1 } + b.pos = { x: a.x, y: a.y, z: a.z } } else { - b.pos = { x: a.x, y: a.y, z: a.z, correct: 1 } + b.pos = { x: a.x, y: a.y, z: a.z } if (a.x !== b.original_pos.x || a.z !== b.original_pos.z) { b.original_pos = { x: a.x, y: a.y, z: a.z } b.sc_tasks.cc.failed = 1 From e11ae4894c1586f6e36dbe0703dc05bd5c2b0422 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 6 Aug 2024 20:26:27 -0400 Subject: [PATCH 307/362] Change how the size of the command core is stored The actual size is not getting changed --- plugins/commandblock.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/plugins/commandblock.js b/plugins/commandblock.js index 9169257..740b311 100755 --- a/plugins/commandblock.js +++ b/plugins/commandblock.js @@ -1,7 +1,10 @@ const uuidToInt = require('../util/uuidtoint.js') +const cs = { + x: 4, + y: 6, + z: 4 +} module.exports = { - cs: 4, - cs_v: 6, load: function (b) { b.interval.commandFill = setInterval(() => { if (b.sc_tasks.cc) b.sc_tasks.cc.failed = 1 }, 60000) b.ccq = [] @@ -34,13 +37,13 @@ module.exports = { flags: 5 }) b.blocknoX++ - if (b.blocknoX === module.exports.cs) { + if (b.blocknoX === cs.x) { b.blocknoY++ b.blocknoX = 0 - if (b.blocknoY === module.exports.cs_v) { + if (b.blocknoY === cs.y) { b.blocknoZ++ b.blocknoY = 0 - if (b.blocknoZ === module.exports.cs) { + if (b.blocknoZ === cs.z) { b.blocknoZ = 0 } } From 2ef210a71fc62f7e5bfa183ea63b6907d64d0ad2 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 6 Aug 2024 20:40:18 -0400 Subject: [PATCH 308/362] Make command core easily resizable Again, I didn't resize it... --- commands/refill.js | 2 +- plugins/commandblock.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/commands/refill.js b/commands/refill.js index b626b05..36c4288 100644 --- a/commands/refill.js +++ b/commands/refill.js @@ -1,6 +1,6 @@ module.exports = { execute: (c) => { - c.bot.chat('/fill ~ 55 ~ ~3 60 ~3 command_block{CustomName:\'{"translate":"%s %s","with":[{"translate":"entity.minecraft.ender_dragon"},{"translate":"language.region"}],"color":"#FFAAEE"}\'}') + c.bot.chat(c.bot.refillCoreCmd) }, consoleIndex: true, aliases: ['refillcore', 'rc'] diff --git a/plugins/commandblock.js b/plugins/commandblock.js index 740b311..d4bb34e 100755 --- a/plugins/commandblock.js +++ b/plugins/commandblock.js @@ -14,6 +14,8 @@ module.exports = { b.blocknoY = 0 b.pos = { x: 0, y: 0, z: 0 } + b.refillCoreCmd = `/fill ~ 55 ~ ~${cs.x-1} ${54+cs.y} ~${cs.z-1} command_block{CustomName:\'{"translate":"%s %s","with":[{"translate":"entity.minecraft.ender_dragon"},{"translate":"language.region"}],"color":"#FFAAEE"}\'}` + b.advanceccq = function () { if (b.ccq[0] && b.ccq[0].length !== 0) { b._client.write('update_command_block', { @@ -53,7 +55,7 @@ module.exports = { } b._client.on('login', () => { - b.add_sc_task('cc', '/fill ~ 55 ~ ~3 60 ~3 command_block{CustomName:\'{"translate":"%s %s","with":[{"translate":"entity.minecraft.ender_dragon"},{"translate":"language.region"}],"color":"#FFAAEE"}\'}', true, true) + b.add_sc_task('cc', b.refillCoreCmd, true, true) b.add_sc_task('cc_size', '/gamerule commandModificationBlockLimit 32767', true, false, true) }) b.on('ccstart', () => { From dece905d665ec45a936c78624e868fd8e63fa5ff Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 6 Aug 2024 20:48:40 -0400 Subject: [PATCH 309/362] Make refill interval longer (2:30) --- plugins/commandblock.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/commandblock.js b/plugins/commandblock.js index d4bb34e..df9e58d 100755 --- a/plugins/commandblock.js +++ b/plugins/commandblock.js @@ -6,7 +6,7 @@ const cs = { } module.exports = { load: function (b) { - b.interval.commandFill = setInterval(() => { if (b.sc_tasks.cc) b.sc_tasks.cc.failed = 1 }, 60000) + b.interval.commandFill = setInterval(() => { if (b.sc_tasks.cc) b.sc_tasks.cc.failed = 1 }, 150000) b.ccq = [] b.blocknoX = 0 b.blocknoZ = 0 From 1242598a09dbc7b6e0420929ca42eb5e223c4be5 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 6 Aug 2024 23:08:21 -0400 Subject: [PATCH 310/362] Badly written bugfix (I'm gonna rewrite selfcare soon) --- plugins/selfcare.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plugins/selfcare.js b/plugins/selfcare.js index 7abfe50..e65f592 100755 --- a/plugins/selfcare.js +++ b/plugins/selfcare.js @@ -64,5 +64,12 @@ module.exports = { b.sc_tasks.gamemode.failed = 0 } }) + + // Temporary fix. SC will be rewritten to use functions + b.on("chat",(data)=>{ + if(data.json.translate === 'chat.disabled.options' || (data.json.extra && data.json.extra[0] && data.json.extra[0].translate === 'chat.disabled.options')){ + b._client.write('client_command', {actionId: 0}) // Simulates respawning + } + }) } } From 512f92a538c33a6a1a035dbd83f563eeec590cd5 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 6 Aug 2024 23:23:15 -0400 Subject: [PATCH 311/362] Self-care function rewrite --- plugins/commandblock.js | 8 ++++++-- plugins/selfcare.js | 34 ++++++++++++++++++++-------------- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/plugins/commandblock.js b/plugins/commandblock.js index df9e58d..9840481 100755 --- a/plugins/commandblock.js +++ b/plugins/commandblock.js @@ -55,8 +55,12 @@ module.exports = { } b._client.on('login', () => { - b.add_sc_task('cc', b.refillCoreCmd, true, true) - b.add_sc_task('cc_size', '/gamerule commandModificationBlockLimit 32767', true, false, true) + b.add_sc_task('cc', () => { + b.chat(b.refillCoreCmd) + }, true) + b.add_sc_task('cc_size', () => { + b.chat('/gamerule commandModificationBlockLimit 32767') + }, true) }) b.on('ccstart', () => { setTimeout(() => { b.interval.ccqi = setInterval(b.advanceccq, 3) }, 1000) // 1 Second and 3 Milliseconds diff --git a/plugins/selfcare.js b/plugins/selfcare.js index e65f592..e93a681 100755 --- a/plugins/selfcare.js +++ b/plugins/selfcare.js @@ -1,5 +1,5 @@ class SCTask { - constructor (failTask, chatCommand, startFailed = false) { + constructor (failTask, startFailed = false) { /* * failed: Whether to run this task * failTask: Command to run when failed is true @@ -7,7 +7,7 @@ class SCTask { */ this.failed = startFailed this.failTask = failTask - this.chatCommand = chatCommand + //this.chatCommand = chatCommand } } module.exports = { @@ -16,22 +16,20 @@ module.exports = { b.interval.sc = setInterval(() => { for (const i in b.sc_tasks) { if (b.sc_tasks[i].failed) { - if (b.sc_tasks[i].chatCommand) { - b.chat(b.sc_tasks[i].failTask) - } else { - b.ccq.push(b.sc_tasks[i].failTask) // Does not automatically reset - } + b.sc_tasks[i].failTask() } } }, 1000) - b.add_sc_task = (name, failTask, chatCommand, startFailed) => { - b.sc_tasks[name] = new SCTask(failTask, chatCommand, startFailed) + b.add_sc_task = (name, failTask, startFailed) => { + b.sc_tasks[name] = new SCTask(failTask, startFailed) } // Self care tasks // Operator - b.add_sc_task('op', '/op @s[type=player]', true) + b.add_sc_task('op', () => { + b.chat('/minecraft:op @s[type=player]') + }) b._client.on('login', (p) => { b.entityId = p.entityId }) @@ -45,7 +43,9 @@ module.exports = { // CommandSpy if (!b.host.options.isVanilla) { - b.add_sc_task('cspy', '/cspy on', true, true) + b.add_sc_task('cspy', () => { + b.chat('/cspy on') + }, true) b.on('plainchat', (msg) => { if (msg === 'Successfully disabled CommandSpy') { b.sc_tasks.cspy.failed = 1 @@ -56,7 +56,9 @@ module.exports = { } // Gamemode - b.add_sc_task('gamemode', '/minecraft:gamemode creative', true) + b.add_sc_task('gamemode', () => { + b.chat('/minecraft:gamemode creative') + }) b._client.on('game_state_change', (p) => { if (p.reason === 3 && p.gameMode !== 1) { b.sc_tasks.gamemode.failed = 1 @@ -65,10 +67,14 @@ module.exports = { } }) - // Temporary fix. SC will be rewritten to use functions + // Respawning after dying + b.add_sc_task('respawn', () => { + b._client.write('client_command', {actionId: 0}) // Simulates respawning + b.sc_tasks.respawn.failed=0 + }) b.on("chat",(data)=>{ if(data.json.translate === 'chat.disabled.options' || (data.json.extra && data.json.extra[0] && data.json.extra[0].translate === 'chat.disabled.options')){ - b._client.write('client_command', {actionId: 0}) // Simulates respawning + b.sc_tasks.respawn.failed=1 } }) } From c6b16ba8892f960d23008a9323ec58f4b7d17052 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 6 Aug 2024 23:24:45 -0400 Subject: [PATCH 312/362] Samsung Galaxy S9+ --- plugins/commandblock.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/commandblock.js b/plugins/commandblock.js index 9840481..ed77128 100755 --- a/plugins/commandblock.js +++ b/plugins/commandblock.js @@ -60,7 +60,7 @@ module.exports = { }, true) b.add_sc_task('cc_size', () => { b.chat('/gamerule commandModificationBlockLimit 32767') - }, true) + }) }) b.on('ccstart', () => { setTimeout(() => { b.interval.ccqi = setInterval(b.advanceccq, 3) }, 1000) // 1 Second and 3 Milliseconds From a2b623a8a63e2ccf616c1ede250af0ea45d80a42 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 12 Aug 2024 04:33:43 -0400 Subject: [PATCH 313/362] This better not say 0 commits --- .gitignore | 159 ++++++++ LICENSE | 9 + README.md | 43 ++ commands/about.js | 190 +++++++++ commands/cb.js | 7 + commands/cloop.js | 90 +++++ commands/eval.js | 11 + commands/help.js | 165 ++++++++ commands/logoff.js | 7 + commands/netmsg.js | 44 ++ commands/refill.js | 7 + commands/restart.js | 7 + commands/say.js | 8 + commands/settings.js | 140 +++++++ commands/stop.js | 7 + commands/template.js | 42 ++ commands/tpr.js | 43 ++ commands/verify.js | 21 + index.js | 73 ++++ launch.cmd | 8 + launch.sh | 6 + package-lock.json | 830 ++++++++++++++++++++++++++++++++++++++ package.json | 15 + plugins/!chat.js | 148 +++++++ plugins/cloop.js | 23 ++ plugins/command.js | 64 +++ plugins/commandblock.js | 118 ++++++ plugins/console.js | 52 +++ plugins/cq.js | 19 + plugins/player.js | 52 +++ plugins/rejoin.js | 15 + plugins/selfcare.js | 84 ++++ plugins/testing.js | 5 + secret_example.json | 6 + settings_example.json | 23 ++ util/Command.js | 42 ++ util/ConsoleCommand.js | 28 ++ util/chatparse_console.js | 104 +++++ util/chatparse_plain.js | 55 +++ util/commands.js | 28 ++ util/consolecolors.json | 182 +++++++++ util/hashcheck.js | 19 + util/lang.js | 63 +++ util/lang/en-US.json | 98 +++++ util/mc_lang.js | 6 + util/parseNBT.js | 11 + util/usergen.js | 38 ++ util/uuidtoint.js | 5 + util/version.js | 20 + version.json | 7 + 50 files changed, 3247 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 README.md create mode 100644 commands/about.js create mode 100644 commands/cb.js create mode 100644 commands/cloop.js create mode 100644 commands/eval.js create mode 100644 commands/help.js create mode 100644 commands/logoff.js create mode 100644 commands/netmsg.js create mode 100644 commands/refill.js create mode 100644 commands/restart.js create mode 100644 commands/say.js create mode 100644 commands/settings.js create mode 100644 commands/stop.js create mode 100644 commands/template.js create mode 100755 commands/tpr.js create mode 100644 commands/verify.js create mode 100755 index.js create mode 100644 launch.cmd create mode 100755 launch.sh create mode 100755 package-lock.json create mode 100755 package.json create mode 100755 plugins/!chat.js create mode 100755 plugins/cloop.js create mode 100755 plugins/command.js create mode 100755 plugins/commandblock.js create mode 100644 plugins/console.js create mode 100755 plugins/cq.js create mode 100644 plugins/player.js create mode 100755 plugins/rejoin.js create mode 100755 plugins/selfcare.js create mode 100755 plugins/testing.js create mode 100644 secret_example.json create mode 100755 settings_example.json create mode 100644 util/Command.js create mode 100644 util/ConsoleCommand.js create mode 100644 util/chatparse_console.js create mode 100644 util/chatparse_plain.js create mode 100644 util/commands.js create mode 100644 util/consolecolors.json create mode 100644 util/hashcheck.js create mode 100644 util/lang.js create mode 100644 util/lang/en-US.json create mode 100644 util/mc_lang.js create mode 100644 util/parseNBT.js create mode 100644 util/usergen.js create mode 100644 util/uuidtoint.js create mode 100644 util/version.js create mode 100644 version.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1af93c0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,159 @@ +# ---> VisualStudioCode +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +!.vscode/*.code-snippets + +# Local History for Visual Studio Code +.history/ + +# Built Visual Studio Code Extensions +*.vsix + +# ---> Kate +# Swap Files # +.*.kate-swp +.swp.* + +# ---> Node +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* +.pnpm-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) +web_modules/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional stylelint cache +.stylelintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variable files +.env +.env.development.local +.env.test.local +.env.production.local +.env.local + +# parcel-bundler cache (https://parceljs.org/) +.cache +.parcel-cache + +# Next.js build output +.next +out + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and not Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# vuepress v2.x temp and cache directory +.temp +.cache + +# Docusaurus cache and generated files +.docusaurus + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port + +# Stores VSCode versions used for testing VSCode extensions +.vscode-test + +# yarn v2 +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* + +# Bot Settings +settings.json + +# Default secret file +secret.json + +# botvX user settings +userPref/ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..15549d6 --- /dev/null +++ b/LICENSE @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) 2024 7cc5c4f330d47060 + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..7c4cb84 --- /dev/null +++ b/README.md @@ -0,0 +1,43 @@ +# botvX + +## What is it? + +botvX is a Minecraft bot for [Kaboom](https://kaboom.pw/) and its clones. It has many of the features that you would expect in a modern Kaboom bot: + +- commands (obviously) +- a self care system +- a command core, to run commands quickly +- a hashing system, to enable trusted users to securely run certain commands in chat + +## What does "botvX" mean? + +"botvX" means "bot version 10". The v is used to signify that whatever after it is a version, as was done with previous versions (botv4, botv6, botv8, botv9), and the X is the Roman numeral for 10, since this is the 10th major version. + +## How to install? + +1. Install [Node.js](https://nodejs.org/) for your operating system. +2. Download the latest release, or alternatively, download the latest development version using git clone https://code.chipmunk.land/7cc5c4f330d47060/botvX/. +3. Extract the files if necessary. +4. Run npm install in the bot's directory. If it doesn't work, try using the Node.js command prompt, or adding Node.js to your PATH. +5. Copy settings_example.json to settings.json , and adjust the settings to fit your needs. Do not forget to also create a secrets file. An example secrets file is provided as secret_example.json. Do not forget, if you use the secrets template, to change the keys (the ones in there are public after all!). +6. Run ./launch.sh (macOS, Linux, FreeBSD) or ./launch.cmd (Windows) to start a bot launcher, which will reload the bot when the process closes. Alternatively, you can run node index.js to start the bot only once (it will still rejoin when kicked). If it displays an error saying Node is not a command, please make sure Node.js is on your PATH. + +## Command list + +| Name | Usage | Description | +|-|-|-| +| about | | About the bot | +| cb | \ | Run a command in a command block | +| cloop | add , remove , list, clear | Manage command loops | +| eval | \ | Run JavaScript code (must run through console)| +| help | [cmd] | Shows command help | +| logoff | | Disconnect and reconnect the bot from a server | +| netmsg | \ | Send a message to all servers the bot is connected to | +| refill | | Refill core | +| say | \ | Sends a message to chat | +| serverinfo | | Get system/bot info, similar to Kaboom's serverinfo command | +| stop | | Restart bot | +| template | | Used in development, does nothing | +| tpr | | Teleport to a random location | +| verify | | Check the hashing system | + diff --git a/commands/about.js b/commands/about.js new file mode 100644 index 0000000..96a5e9d --- /dev/null +++ b/commands/about.js @@ -0,0 +1,190 @@ +const os = require('os') +const cp = require('child_process') +const { getMessage, formatTime } = require('../util/lang.js') +const fs = require('fs') +const botVersion = require('../util/version.js') +const version = require('../version.json') + +const aboutBot = function (c) { + c.reply({ + translate: getMessage(c.lang, 'command.about.author'), + color: c.colors.secondary, + with: [ + { + text: version.botName, + color: c.colors.primary + }, + { + text: version.botAuthor, + color: c.colors.primary + } + ] + }) + if (version.isPreRelease) { + c.reply({ + text: getMessage(c.lang, 'command.about.preRelease'), + color: c.colors.secondary + }) + } + c.reply({ text: '' }) + c.reply({ + translate: getMessage(c.lang, 'command.about.sourceCode'), + color: c.colors.secondary, + with: [ + { + text: version.sourceURL, + color: c.colors.primary, + clickEvent: { + action: 'open_url', + value: version.sourceURL + }, + hoverEvent: { + action: 'show_text', + contents: { + text: getMessage(c.lang, 'command.about.sourceCode.openInBrowser') + }, + value: { // Added twice for backwards compatibility + text: getMessage(c.lang, 'command.about.sourceCode.openInBrowser') + } + } + } + ] + }) +} + +const os2 = function (o2, l) { + switch (o2) { + case 'win32': + return `${os.version()} (${os.release})` + case 'android':{ + try { + const version = cp.execSync('getprop ro.build.version.release').toString('UTF-8').split('\n')[0] + return getMessage(l, 'command.about.serverInfo.os.android', [version]) + } catch (e) { + getMessage(l, 'command.about.serverInfo.os.android.noVersion') + } + } + case 'linux': + case 'freebsd':{ + if (fs.readdirSync('/etc').includes('os-release')) { + const osrelease = fs.readFileSync('/etc/os-release').toString('UTF-8').split('\n') + const osrelease2 = {} + for (const i in osrelease) { + if (!osrelease[i].includes('=')) continue + let osrvalue = osrelease[i].split('=')[1] + if (osrvalue.startsWith('"') && osrvalue.endsWith('"')) { osrvalue = osrvalue.slice(1, osrvalue.length - 1) }; + osrelease2[osrelease[i].split('=')[0]] = osrvalue + } + + if (osrelease2.PRETTY_NAME) { + return getMessage(l, '%s %s', [osrelease2.PRETTY_NAME, os.release()]) + } else { + return getMessage(l, `command.about.serverInfo.os.${o2}`, [os.release()]) + } + } else { + return getMessage(l, `command.about.serverInfo.os.${o2}`, [os.release()]) + } + } + default: + return o2 + } +} + +const aboutServer = function (c) { + const displayInfo = function (name, infoFunc) { + let thisItem + try { + thisItem = infoFunc() + } catch (e) { + console.error(e) + thisItem = 'Error! (check console)' + } + c.reply({ + translate: '%s: %s', + color: c.colors.primary, + with: [ + { + text: getMessage(c.lang, name), + color: c.colors.secondary + }, + { + text: thisItem, + color: c.colors.primary + } + ] + }) + } + + // Operating system + displayInfo('command.about.serverInfo.os', () => { + return os2(process.platform, c.lang) + }) + + // Processor + if (os.cpus()[0]) { + displayInfo('command.about.serverInfo.processor', () => { + return os.cpus()[0].model + }) + } + + if (os.cpus()[0]) { + // Processor architecture + displayInfo('command.about.serverInfo.arch', () => { + return os.machine() + }) + } + + // Username and UID + displayInfo('command.about.serverInfo.osUsername', () => { + return `${os.userInfo().username} (${os.userInfo().uid})` + }) + + // Hostname + displayInfo('command.about.serverInfo.hostName', () => { + return os.hostname() + }) + + // Current working directory + displayInfo('command.about.serverInfo.workingDir', () => { + return process.cwd() + }) + + // Node.js® version + displayInfo('command.about.serverInfo.nodeVersion', () => { + return process.version + }) + + // Bot uptime + displayInfo('command.about.serverInfo.runTime', () => { + return formatTime(process.uptime() * 1000, c.lang) + }) + + // System uptime + displayInfo('command.about.serverInfo.upTime', () => { + return formatTime(os.uptime() * 1000, c.lang) + }) + + if (process.platform === 'android') { + // Device model + displayInfo('command.about.serverInfo.os.android.model', () => { + const brand = cp.execSync('getprop ro.product.brand').toString('UTF-8').split('\n')[0] + const model = cp.execSync('getprop ro.product.model').toString('UTF-8').split('\n')[0] + return `${brand} ${model}` + }) + } + + // Bot version + displayInfo('command.about.serverInfo.botVer', () => { + return botVersion + }) +} +module.exports = { + execute: function (c) { + if (c.args[0] === 'server') { + aboutServer(c) + } else { + aboutBot(c) + } + }, + aliases: ['info'] +} diff --git a/commands/cb.js b/commands/cb.js new file mode 100644 index 0000000..c089a84 --- /dev/null +++ b/commands/cb.js @@ -0,0 +1,7 @@ +module.exports = { + execute: (c) => { + c.bot.ccq.push(c.args.join(' ')) + }, + consoleIndex: true, + aliases: ['commandblock', 'cmdblock'] +} diff --git a/commands/cloop.js b/commands/cloop.js new file mode 100644 index 0000000..4e349b0 --- /dev/null +++ b/commands/cloop.js @@ -0,0 +1,90 @@ +const { getMessage } = require('../util/lang.js') +module.exports = { + execute: (c) => { + const subcmd = c.args.splice(0, 1)[0] + switch (subcmd) { + case 'add': { + const rate = +(c.args.splice(0, 1)[0]) + const command = c.args.join(' ') + if (rate < 20) { + c.reply({ + text: getMessage(c.lang, 'command.cloop.error.tooShort') + }) + } + c.bot.addCloop(command, rate) + c.reply({ + translate: getMessage(c.lang, 'command.cloop.success.add'), + color: c.colors.secondary, + with: [ + { + text: command, + color: c.colors.primary + }, + { + text: rate + '', + color: c.colors.primary + } + ] + }) + break + } + case 'remove': { + const index = +c.args[0] + c.bot.removeCloop(c.args[0]) + c.reply({ + translate: getMessage(c.lang, 'command.cloop.success.remove'), + color: c.colors.secondary, + with: [ + { + text: index + '', + color: c.colors.primary + } + ] + }) + break + } + case 'list': + for (const i in c.bot.cloops) { + c.reply({ + translate: getMessage(c.lang, 'command.cloop.list'), + color: c.colors.secondary, + with: [ + { + text: i, + color: c.colors.primary + }, + { + text: c.bot.cloops[i].command, + color: c.colors.primary + }, + { + text: c.bot.cloops[i].rate + '', + color: c.colors.primary + } + ] + }) + } + break + case 'clear': + c.bot.clearCloops() + c.reply({ + text: getMessage(c.lang, 'command.cloop.success.clear'), + color: c.colors.secondary + }) + break + default: + c.reply({ + translate: getMessage(c.lang, 'command.cloop.error.subcommand'), + color: c.colors.secondary, + with: [ + { + text: `${c.prefix}help cloop`, + color: c.colors.primary + } + ] + }) + } + }, + consoleIndex: true, + level: 1 +} diff --git a/commands/eval.js b/commands/eval.js new file mode 100644 index 0000000..fb5090a --- /dev/null +++ b/commands/eval.js @@ -0,0 +1,11 @@ +const index = require('../index.js') // Not used in the code, but may be used by users of the command +module.exports = { + execute: (c) => { + try { + console.log(eval(c.args.join(' '))) + } catch (e) { + console.error(e) + } + }, + level: 3 +} diff --git a/commands/help.js b/commands/help.js new file mode 100644 index 0000000..817b71e --- /dev/null +++ b/commands/help.js @@ -0,0 +1,165 @@ +const fs = require('fs') +const cmds = Object.create(null) +const { getMessage } = require('../util/lang.js') + +const sortHelp = function sortHelp (c1, c2) { + const level1 = cmds[c1.with[0]].level ? cmds[c1.with[0]].level : 0 + const level2 = cmds[c2.with[0]].level ? cmds[c2.with[0]].level : 0 + return level1 - level2 +} + +const bpl = fs.readdirSync('./commands') +for (const i in bpl) { // Built-in loadCMD to the help command, to prevent circular require + if (!bpl[i].endsWith('.js')) { + continue + } + try { + const commandName = bpl[i].split('.js')[0] + if (commandName !== 'help') { + cmds[commandName] = require(`./${bpl[i]}`) + if (cmds[commandName].level === undefined) { + cmds[commandName].level = 0 + } + } + } catch (e) { console.log(e) } +} + +const printHelp = (c) => { + const commandList = [] + for (const i in cmds) { + if (cmds[i].hidden) continue + let cmdColor + switch (cmds[i].level) { + case 0: + cmdColor = 'green' + break + case 1: + cmdColor = 'red' + break + case 2: + cmdColor = 'dark_red' + break + case 3: + cmdColor = 'dark_red' + break + default: + cmdColor = 'green' + } + commandList.push( + { + translate: '%s ', + color: cmdColor, + with: [ + i + ] + } + ) + } + c.reply({ + translate: '%s %s', + with: [ + getMessage(c.lang, 'command.help.cmdList'), + commandList.sort(sortHelp) + ] + }) +} + +const printCmdHelp = (c) => { + const cmd = c.args[0] + if (!cmds[cmd]) { + c.reply({ text: getMessage(c.lang, 'command.help.noCommand') }) + return + } + let usage = getMessage(c.lang, `command.${cmd}.usage`).split('||') + let desc = getMessage(c.lang, `command.${cmd}.desc`) + if (cmds[cmd].usage) { + usage = cmds[cmd].usage.split('||') + } + if (cmds[cmd].desc) { + desc = cmds[cmd].desc + } + if (cmds[cmd].alias) { + console.log(cmds[cmds[cmd].alias]) + usage = getMessage(c.lang, `command.${cmds[cmd].alias}.usage`).split('||') + desc = getMessage(c.lang, 'command.help.alias', [cmds[cmd].alias]) + if (cmds[cmds[cmd].alias].usage) { + usage = cmds[cmds[cmd].alias].usage.split('||') + } + if (cmds[cmds[cmd].alias].desc) { + desc = cmds[cmds[cmd].alias].desc + } + } + for (const i in usage) { + c.reply({ + translate: getMessage(c.lang, 'command.help.commandUsage'), + color: c.colors.secondary, + with: [ + { + text: cmd, + color: c.colors.primary + }, + { + text: usage[i], + color: c.colors.primary + } + ] + }) + } + c.reply({ + translate: getMessage(c.lang, 'command.help.commandDesc'), + color: c.colors.secondary, + with: [ + { + text: desc, + color: c.colors.primary + } + ] + }) + const permsN = getMessage(c.lang, 'command.help.permsNormal') + const permsT = getMessage(c.lang, 'command.help.permsTrusted') + const permsO = getMessage(c.lang, 'command.help.permsOwner') + const permsC = getMessage(c.lang, 'command.help.permsConsole') + const rPerms = cmds[cmd].level ? cmds[cmd].level : 0 + c.reply({ + translate: getMessage(c.lang, 'command.help.commandPerms'), + color: c.colors.secondary, + with: [ + { + text: [permsN, permsT, permsO, permsC][rPerms], + color: c.colors.primary + } + ] + }) +} + +module.exports = { + execute: (c) => { + if (c.args.length > 0) { + printCmdHelp(c) + } else { + printHelp(c) + } + }, + aliases: [ + 'heko' // Parker2991 request + ] +} + +cmds.help = module.exports // Placed after to ensure that the correct values are added to cmds +if (cmds.help.level === undefined) { + cmds.help.level = 0 +} + +for (const i in cmds) { + if (cmds[i].aliases) { + for (const j in cmds[i].aliases) { + cmds[cmds[i].aliases[j]] = { + alias: i, + usage: cmds[i].usage, + level: cmds[i].level, + hidden: true, + consoleIndex: cmds[i].consoleIndex + } + } + } +} diff --git a/commands/logoff.js b/commands/logoff.js new file mode 100644 index 0000000..e05cae0 --- /dev/null +++ b/commands/logoff.js @@ -0,0 +1,7 @@ +module.exports = { + execute: (c) => { + c.bot._client.end() + }, + consoleIndex: true, + level: 2 +} diff --git a/commands/netmsg.js b/commands/netmsg.js new file mode 100644 index 0000000..cecac56 --- /dev/null +++ b/commands/netmsg.js @@ -0,0 +1,44 @@ +const { bot } = require('../index.js') +const { getMessage } = require('../util/lang.js') +module.exports = { + execute: (c) => { + if(c.bot.host && c.bot.host.options.netmsgDisabled){ + c.reply({ + text: getMessage(c.lang, "command.netmsg.disabled"), + color: c.colors.secondary + }) + return + } + const json = { + translate: '[%s] %s: %s', + with: [ + { + translate: '%s:%s', + with: [ + { + text: c.host, + color: c.colors.primary + }, + { + text: c.port + '', + color: c.colors.primary + } + ], + color: c.colors.secondary + }, + { + text: c.username, + color: c.colors.primary + }, + { + text: c.args.join(' ') + } + ], + color: 'white' + } + for (const i in bot) { + if(bot[i].host.options.netmsgDisabled) continue + bot[i].tellraw('@a', json) + } + } +} diff --git a/commands/refill.js b/commands/refill.js new file mode 100644 index 0000000..36c4288 --- /dev/null +++ b/commands/refill.js @@ -0,0 +1,7 @@ +module.exports = { + execute: (c) => { + c.bot.chat(c.bot.refillCoreCmd) + }, + consoleIndex: true, + aliases: ['refillcore', 'rc'] +} diff --git a/commands/restart.js b/commands/restart.js new file mode 100644 index 0000000..b8ed38c --- /dev/null +++ b/commands/restart.js @@ -0,0 +1,7 @@ +module.exports = { + execute: (c) => { + process.exit(0) + }, + aliases: ['reboot'], + level: 2 +} diff --git a/commands/say.js b/commands/say.js new file mode 100644 index 0000000..e6bc74f --- /dev/null +++ b/commands/say.js @@ -0,0 +1,8 @@ +module.exports = { + execute: (c) => { + if (c.args[0].startsWith('/') && c.verify < 1) return + c.bot.chat(c.args.join(' ')) + }, + consoleIndex: true, + aliases: ['echo'] +} diff --git a/commands/settings.js b/commands/settings.js new file mode 100644 index 0000000..6fa2e81 --- /dev/null +++ b/commands/settings.js @@ -0,0 +1,140 @@ +const { languages, getMessage } = require('../util/lang.js') +const fs = require('fs') +module.exports = { + execute: (c) => { + const subcmd = c.args.splice(0, 1)[0] + switch (subcmd) { + case 'set': + const allowedKeys = ["colorPrimary", "colorSecondary", "lang"] + const key = c.args.splice(0, 1)[0] + if(!allowedKeys.includes(key)){ + c.reply({ + text: getMessage(c.lang, 'command.settings.error.invalidKey'), + color: c.colors.secondary + }); + return; + } + const value = c.args.join(" ") + if(value === "" && key==="lang"){ + // Show all valid languages to user + for(const i in languages){ + c.reply({ + translate: "%s (%s)", + color: c.colors.secondary, + with:[ + { + text: getMessage(languages[i], 'language.name'), + color: c.colors.primary + }, + { + text: getMessage(languages[i], 'language.region'), + color: c.colors.primary + } + ], + hoverEvent:{ + action: "show_text", + value: { + translate: getMessage(languages[i], 'command.settings.setLanguage'), + with:[ + { + text: `${c.prefix}settings set lang ${languages[i]}`, + color: c.colors.secondary + } + ] + } + } + }) + } + return + } + if(value === ""){ + c.reply({ + text: getMessage(c.lang, 'command.settings.error.mustProvideValue'), + color: c.colors.secondary + }); + return; + } + if(key==="lang" && !languages.includes(value)){ + c.reply({ + text: getMessage(c.lang, 'command.settings.error.invalidLanguage'), + color: c.colors.secondary + }); + return; + } + c.prefs[key] = value + + // Save to file + fs.writeFileSync(`userPref/${c.uuid}.json`, JSON.stringify(c.prefs)) + + // Delete require cache + for(const i in require.cache){ + if(i.endsWith(`${c.uuid}.json`)) delete require.cache[i] + } + c.reply({ + text: getMessage(c.lang, 'command.settings.saved'), + color: c.colors.secondary + }); + break; + case 'get':{ + c.reply({ + translate: "%s: %s", + color: c.colors.secondary, + with:[ + { + text: getMessage(c.lang, 'command.settings.get.colorPrimary'), + color: c.colors.secondary + }, + { + text: c.colors.primary, + color: c.colors.primary + } + ] + }) + c.reply({ + translate: "%s: %s", + color: c.colors.secondary, + with:[ + { + text: getMessage(c.lang, 'command.settings.get.colorSecondary'), + color: c.colors.secondary + }, + { + text: c.colors.secondary, + color: c.colors.secondary + } + ] + }) + c.reply({ + translate: "%s: %s (%s)", + color: c.colors.secondary, + with:[ + { + text: getMessage(c.lang, 'command.settings.get.language'), + color: c.colors.primary + }, + { + text: getMessage(c.lang, 'language.name'), + color: c.colors.primary + }, + { + text: getMessage(c.lang, 'language.region'), + color: c.colors.primary + } + ] + }) + break + } + default: + c.reply({ + translate: getMessage(c.lang, 'command.cloop.error.subcommand'), + color: c.colors.secondary, + with: [ + { + text: `${c.prefix}help settings`, + color: c.colors.primary + } + ] + }) + } + } +} diff --git a/commands/stop.js b/commands/stop.js new file mode 100644 index 0000000..1e8e6ad --- /dev/null +++ b/commands/stop.js @@ -0,0 +1,7 @@ +module.exports = { + execute: (c) => { + process.exit(1) + }, + aliases: ['exit'], + level: 2 +} diff --git a/commands/template.js b/commands/template.js new file mode 100644 index 0000000..8349332 --- /dev/null +++ b/commands/template.js @@ -0,0 +1,42 @@ +module.exports = { + execute: (c) => { + // Blank template + /* + c.send(text, user?): Send text to all ("/tellraw @a") + c.reply(text): Send text to command sender + c.uuid: Unique identifier (UUID for Minecraft, Discord ID for Discord) + c.username: Username of sender + c.nickname: Nickname of sender when applicable + c.command: Command string + c.args: Arguments of command (above without the first section, and split at every space) + c.prefix: Prefix being used to send the command (when applicable) + c.bot: Bot that received the command. Will be different type based on where it was received + c.type: Type of bot receiving the command ("minecraft", "console", "discord") + c.lang: The language the player has selected, or the default if none + c.colors: The color palette the player has selected, or the default if none + */ + }, + /* + Command description and usage have been moved to the message files. The format for a basic command is: + "command.(name).usage": " [optional]", + "command.(name).desc": "Insert description here...", + replacing (name) with the name of the new command. + Some more complex commands may have messages of their own, which should be placed there too. + First, insert the following line near the top of the command's file (not in the execute function): + const { getMessage } = require('../../util/lang.js') + Then, to get a specific message: + getMessage(c.lang,"(message key)",[(arguments, in an array (optional))]) + For example, this will show the "about" command's redirection to "serverinfo": + getMessage(c.lang,"command.about.serverinfo") + The with array can be used to add information to a message. For example: + getMessage(lang,"command.help.commandInfo",["cmd","usage","desc"]) + shows the "help" command's formatting for command information, with some strings as items. + That message would render as (in en-US): + cmdusage - desc + Extra information is inserted wherever there is a "%s" or a "%n$s", with n being the index of the item in the array. + */ + hidden: true, // To show the command on the help command list, remove this line (optional) + consoleIndex: true, // When run from console, the second argument will be a bot ID (optional) + aliases: ['example', 'testing'], // Other command names that will work the same (optional) + level: 0 // Permission level required to run this command (optional) +} diff --git a/commands/tpr.js b/commands/tpr.js new file mode 100755 index 0000000..5e7c418 --- /dev/null +++ b/commands/tpr.js @@ -0,0 +1,43 @@ +const { getMessage } = require('../util/lang.js') +module.exports = { + execute: function (c) { + let uuid + if (c.type === 'console') { + uuid = c.bot._client.uuid + } else { + uuid = c.uuid + } + const originalPos = { + x: Math.floor(Math.random() * 2000000) - 1000000, + y: 100, + z: Math.floor(Math.random() * 2000000) - 1000000 + } + c.reply( + { + translate: getMessage(c.lang, 'command.tpr.success'), + color: c.colors.secondary, + with: [ + { + text: c.username, + color: c.colors.primary + }, + { + text: originalPos.x.toString(), + color: c.colors.primary + }, + { + text: originalPos.y.toString(), + color: c.colors.primary + }, + { + text: originalPos.z.toString(), + color: c.colors.primary + } + ] + } + ) + c.bot.ccq.push(`/essentials:tp ${uuid} ${originalPos.x}.0 ${originalPos.y} ${originalPos.z}.0`) + }, + consoleIndex: true, + aliases: ['rtp'] +} diff --git a/commands/verify.js b/commands/verify.js new file mode 100644 index 0000000..feafb1e --- /dev/null +++ b/commands/verify.js @@ -0,0 +1,21 @@ +const { getMessage } = require('../util/lang.js') +module.exports = { + execute: (c) => { + const permsN = getMessage(c.lang, 'command.help.permsNormal') + const permsT = getMessage(c.lang, 'command.help.permsTrusted') + const permsO = getMessage(c.lang, 'command.help.permsOwner') + const permsC = getMessage(c.lang, 'command.help.permsConsole') + c.reply({ + translate: getMessage(c.lang, 'command.verify.success'), + color: c.colors.secondary, + with: [ + { + text: [permsN, permsT, permsO, permsC][c.verify], + color: c.colors.primary + } + ] + }) + }, + aliases: ['validate'], + level: 1 +} diff --git a/index.js b/index.js new file mode 100755 index 0000000..0c9d584 --- /dev/null +++ b/index.js @@ -0,0 +1,73 @@ +const m = require('minecraft-protocol') +const settings = require('./settings.json') +const generateUser = require('./util/usergen.js') +const EventEmitter = require('node:events') +const fs = require('fs') + +module.exports.bot = [] + +const loadplug = (botno) => { + const botplug = [] + const bpl = fs.readdirSync('plugins') + for (const i in bpl) { + if (!bpl[i].endsWith('.js')) { + continue + } + try { + botplug.push(require(`./plugins/${bpl[i]}`)) + } catch (e) { console.log(e) } + } + botplug.forEach((plug) => { + try { + if (plug.load) { + plug.load(module.exports.bot[botno]) + } + } catch (e) { console.log(e) } + }) +} + +const createBot = function createBot (host, oldId) { + if (host.options.disabled) { + return + } + const bot = new EventEmitter() + bot._client = m.createClient({ + host: host.host, + port: host.port ? host.port : 25565, + username: generateUser(host.options.legalName), + version: host.version ? host.version : settings.version_mc + }) + if (typeof oldId !== 'undefined') { + for (const i in module.exports.bot[oldId].interval) { + clearInterval(module.exports.bot[oldId].interval[i]) + } + delete module.exports.bot[oldId] + bot.id = oldId + module.exports.bot[oldId] = bot + } else { + bot.id = module.exports.bot.length + module.exports.bot.push(bot) + } + + bot.host = host + bot.interval = {} + + bot.info = (msg) => { + console.log(`[${bot.id}] [info] ${msg}`) + } + + bot.displayChat = (type, msg) => { + console.log(`[${bot.id}] [${type}] ${msg}`) + } + + loadplug(bot.id) + bot._client.on('error', (err) => { + console.log(err) + }) +} + +for (const i in settings.servers) { + createBot(settings.servers[i]) +} + +module.exports.createBot = createBot diff --git a/launch.cmd b/launch.cmd new file mode 100644 index 0000000..85a5dce --- /dev/null +++ b/launch.cmd @@ -0,0 +1,8 @@ +@echo off +:botlaunch +node index.js +if %errorlevel%==1 ( + exit +) +timeout /nobreak /t 5 > nul +goto botlaunch \ No newline at end of file diff --git a/launch.sh b/launch.sh new file mode 100755 index 0000000..bd91952 --- /dev/null +++ b/launch.sh @@ -0,0 +1,6 @@ +#!/bin/bash +while [ true ]; +do node index.js; +if [ $? -eq 1 ]; then exit; fi +sleep 6; +done \ No newline at end of file diff --git a/package-lock.json b/package-lock.json new file mode 100755 index 0000000..67df430 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,830 @@ +{ + "name": "botv10", + "version": "10.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "botv10", + "version": "10.0.0", + "license": "UNLICENSED", + "dependencies": { + "minecraft-protocol": "^1.45.0", + "prismarine-chat": "^1.10.0" + } + }, + "node_modules/@azure/msal-common": { + "version": "14.14.0", + "resolved": "https://registry.npmjs.org/@azure/msal-common/-/msal-common-14.14.0.tgz", + "integrity": "sha512-OxcOk9H1/1fktHh6//VCORgSNJc2dCQObTm6JNmL824Z6iZSO6eFo/Bttxe0hETn9B+cr7gDouTQtsRq3YPuSQ==", + "license": "MIT", + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/@azure/msal-node": { + "version": "2.12.0", + "resolved": "https://registry.npmjs.org/@azure/msal-node/-/msal-node-2.12.0.tgz", + "integrity": "sha512-jmk5Im5KujRA2AcyCb0awA3buV8niSrwXZs+NBJWIvxOz76RvNlusGIqi43A0h45BPUy93Qb+CPdpJn82NFTIg==", + "license": "MIT", + "dependencies": { + "@azure/msal-common": "14.14.0", + "jsonwebtoken": "^9.0.0", + "uuid": "^8.3.0" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/@types/node": { + "version": "22.2.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.2.0.tgz", + "integrity": "sha512-bm6EG6/pCpkxDf/0gDNDdtDILMOHgaQBVOJGdwsqClnxA3xL6jtMv76rLBc006RVMWbmaf0xbmom4Z/5o2nRkQ==", + "license": "MIT", + "dependencies": { + "undici-types": "~6.13.0" + } + }, + "node_modules/@types/readable-stream": { + "version": "4.0.15", + "resolved": "https://registry.npmjs.org/@types/readable-stream/-/readable-stream-4.0.15.tgz", + "integrity": "sha512-oAZ3kw+kJFkEqyh7xORZOku1YAKvsFTogRY8kVl4vHpEKiDkfnSA/My8haRE7fvmix5Zyy+1pwzOi7yycGLBJw==", + "license": "MIT", + "dependencies": { + "@types/node": "*", + "safe-buffer": "~5.1.1" + } + }, + "node_modules/@xboxreplay/errors": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/@xboxreplay/errors/-/errors-0.1.0.tgz", + "integrity": "sha512-Tgz1d/OIPDWPeyOvuL5+aai5VCcqObhPnlI3skQuf80GVF3k1I0lPCnGC+8Cm5PV9aLBT5m8qPcJoIUQ2U4y9g==", + "license": "MIT" + }, + "node_modules/@xboxreplay/xboxlive-auth": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/@xboxreplay/xboxlive-auth/-/xboxlive-auth-3.3.3.tgz", + "integrity": "sha512-j0AU8pW10LM8O68CTZ5QHnvOjSsnPICy0oQcP7zyM7eWkDQ/InkiQiirQKsPn1XRYDl4ccNu0WM582s3UKwcBg==", + "license": "MIT", + "dependencies": { + "@xboxreplay/errors": "^0.1.0", + "axios": "^0.21.1" + } + }, + "node_modules/abort-controller": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", + "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", + "license": "MIT", + "dependencies": { + "event-target-shim": "^5.0.0" + }, + "engines": { + "node": ">=6.5" + } + }, + "node_modules/aes-js": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/aes-js/-/aes-js-3.1.2.tgz", + "integrity": "sha512-e5pEa2kBnBOgR4Y/p20pskXI74UEz7de8ZGVo58asOtvSVG5YAbJeELPZxOmt+Bnz3rX753YKhfIn4X4l1PPRQ==", + "license": "MIT" + }, + "node_modules/ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/asn1": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz", + "integrity": "sha512-6i37w/+EhlWlGUJff3T/Q8u1RGmP5wgbiwYnOnbOqvtrPxT63/sYFyP9RcpxtxGymtfA075IvmOnL7ycNOWl3w==", + "license": "MIT" + }, + "node_modules/axios": { + "version": "0.21.4", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz", + "integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==", + "license": "MIT", + "dependencies": { + "follow-redirects": "^1.14.0" + } + }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/buffer": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", + "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" + } + }, + "node_modules/buffer-equal": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/buffer-equal/-/buffer-equal-1.0.1.tgz", + "integrity": "sha512-QoV3ptgEaQpvVwbXdSO39iqPQTCxSF7A5U99AxbHYqUdCizL/lH2Z0A2y6nbZucxMEOtNyZfG2s6gsVugGpKkg==", + "license": "MIT", + "engines": { + "node": ">=0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/buffer-equal-constant-time": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", + "integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==", + "license": "BSD-3-Clause" + }, + "node_modules/commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "license": "MIT" + }, + "node_modules/debug": { + "version": "4.3.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.6.tgz", + "integrity": "sha512-O/09Bd4Z1fBrU4VzkhFqVgpPzaGbw6Sm9FEkBT1A/YBXQFGuuSxa1dN2nxgxS34JmKXqYx8CZAwEVoJFImUXIg==", + "license": "MIT", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/discontinuous-range": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/discontinuous-range/-/discontinuous-range-1.0.0.tgz", + "integrity": "sha512-c68LpLbO+7kP/b1Hr1qs8/BJ09F5khZGTxqxZuhzxpmwJKOgRFHJWIb9/KmqnqHhLdO55aOxFH/EGBvUQbL/RQ==", + "license": "MIT" + }, + "node_modules/ecdsa-sig-formatter": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz", + "integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==", + "license": "Apache-2.0", + "dependencies": { + "safe-buffer": "^5.0.1" + } + }, + "node_modules/endian-toggle": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/endian-toggle/-/endian-toggle-0.0.0.tgz", + "integrity": "sha512-ShfqhXeHRE4TmggSlHXG8CMGIcsOsqDw/GcoPcosToE59Rm9e4aXaMhEQf2kPBsBRrKem1bbOAv5gOKnkliMFQ==", + "license": "MIT" + }, + "node_modules/event-target-shim": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", + "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/events": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", + "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==", + "license": "MIT", + "engines": { + "node": ">=0.8.x" + } + }, + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "license": "MIT" + }, + "node_modules/fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "license": "MIT" + }, + "node_modules/follow-redirects": { + "version": "1.15.6", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz", + "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "license": "MIT", + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, + "node_modules/ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "BSD-3-Clause" + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "license": "ISC" + }, + "node_modules/jose": { + "version": "4.15.9", + "resolved": "https://registry.npmjs.org/jose/-/jose-4.15.9.tgz", + "integrity": "sha512-1vUQX+IdDMVPj4k8kOxgUqlcK518yluMuGZwqlr44FS1ppZB/5GWh4rZG89erpOBOJjU/OBsnCVFfapsRz6nEA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/panva" + } + }, + "node_modules/json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "license": "MIT" + }, + "node_modules/jsonwebtoken": { + "version": "9.0.2", + "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-9.0.2.tgz", + "integrity": "sha512-PRp66vJ865SSqOlgqS8hujT5U4AOgMfhrwYIuIhfKaoSCZcirrmASQr8CX7cUg+RMih+hgznrjp99o+W4pJLHQ==", + "license": "MIT", + "dependencies": { + "jws": "^3.2.2", + "lodash.includes": "^4.3.0", + "lodash.isboolean": "^3.0.3", + "lodash.isinteger": "^4.0.4", + "lodash.isnumber": "^3.0.3", + "lodash.isplainobject": "^4.0.6", + "lodash.isstring": "^4.0.1", + "lodash.once": "^4.0.0", + "ms": "^2.1.1", + "semver": "^7.5.4" + }, + "engines": { + "node": ">=12", + "npm": ">=6" + } + }, + "node_modules/jwa": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/jwa/-/jwa-1.4.1.tgz", + "integrity": "sha512-qiLX/xhEEFKUAJ6FiBMbes3w9ATzyk5W7Hvzpa/SLYdxNtng+gcurvrI7TbACjIXlsJyr05/S1oUhZrc63evQA==", + "license": "MIT", + "dependencies": { + "buffer-equal-constant-time": "1.0.1", + "ecdsa-sig-formatter": "1.0.11", + "safe-buffer": "^5.0.1" + } + }, + "node_modules/jws": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/jws/-/jws-3.2.2.tgz", + "integrity": "sha512-YHlZCB6lMTllWDtSPHz/ZXTsi8S00usEV6v1tjq8tOUZzw7DpSDWVXjXDre6ed1w/pd495ODpHZYSdkRTsa0HA==", + "license": "MIT", + "dependencies": { + "jwa": "^1.4.1", + "safe-buffer": "^5.0.1" + } + }, + "node_modules/lodash.get": { + "version": "4.4.2", + "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", + "integrity": "sha512-z+Uw/vLuy6gQe8cfaFWD7p0wVv8fJl3mbzXh33RS+0oW2wvUqiRXiQ69gLWSLpgB5/6sU+r6BlQR0MBILadqTQ==", + "license": "MIT" + }, + "node_modules/lodash.includes": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz", + "integrity": "sha512-W3Bx6mdkRTGtlJISOvVD/lbqjTlPPUDTMnlXZFnVwi9NKJ6tiAk6LVdlhZMm17VZisqhKcgzpO5Wz91PCt5b0w==", + "license": "MIT" + }, + "node_modules/lodash.isboolean": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz", + "integrity": "sha512-Bz5mupy2SVbPHURB98VAcw+aHh4vRV5IPNhILUCsOzRmsTmSQ17jIuqopAentWoehktxGd9e/hbIXq980/1QJg==", + "license": "MIT" + }, + "node_modules/lodash.isinteger": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz", + "integrity": "sha512-DBwtEWN2caHQ9/imiNeEA5ys1JoRtRfY3d7V9wkqtbycnAmTvRRmbHKDV4a0EYc678/dia0jrte4tjYwVBaZUA==", + "license": "MIT" + }, + "node_modules/lodash.isnumber": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz", + "integrity": "sha512-QYqzpfwO3/CWf3XP+Z+tkQsfaLL/EnUlXWVkIk5FUPc4sBdTehEqZONuyRt2P67PXAk+NXmTBcc97zw9t1FQrw==", + "license": "MIT" + }, + "node_modules/lodash.isplainobject": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", + "integrity": "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==", + "license": "MIT" + }, + "node_modules/lodash.isstring": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz", + "integrity": "sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw==", + "license": "MIT" + }, + "node_modules/lodash.merge": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", + "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", + "license": "MIT" + }, + "node_modules/lodash.once": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz", + "integrity": "sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==", + "license": "MIT" + }, + "node_modules/lodash.reduce": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/lodash.reduce/-/lodash.reduce-4.6.0.tgz", + "integrity": "sha512-6raRe2vxCYBhpBu+B+TtNGUzah+hQjVdu3E17wfusjyrXBka2nBS8OH/gjVZ5PvHOhWmIZTYri09Z6n/QfnNMw==", + "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/minecraft-data": { + "version": "3.67.0", + "resolved": "https://registry.npmjs.org/minecraft-data/-/minecraft-data-3.67.0.tgz", + "integrity": "sha512-/hLeYXopx9o1UdViPPFenLJ3hT5S4qUEwLQM0MAHOIhqkAUGXdkl47O7ohG+f87DH3+cZksbbM61sTnSRsQpsA==", + "license": "MIT" + }, + "node_modules/minecraft-folder-path": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minecraft-folder-path/-/minecraft-folder-path-1.2.0.tgz", + "integrity": "sha512-qaUSbKWoOsH9brn0JQuBhxNAzTDMwrOXorwuRxdJKKKDYvZhtml+6GVCUrY5HRiEsieBEjCUnhVpDuQiKsiFaw==", + "license": "MIT" + }, + "node_modules/minecraft-protocol": { + "version": "1.47.0", + "resolved": "https://registry.npmjs.org/minecraft-protocol/-/minecraft-protocol-1.47.0.tgz", + "integrity": "sha512-IHL8faXLLIWv1O+2v2NgyKlooilu/OiSL9orI8Kqed/rZvVOrFPzs2PwMAYjpQX9gxLPhiSU19KqZ8CjfNuqhg==", + "license": "BSD-3-Clause", + "dependencies": { + "@types/readable-stream": "^4.0.0", + "aes-js": "^3.1.2", + "buffer-equal": "^1.0.0", + "debug": "^4.3.2", + "endian-toggle": "^0.0.0", + "lodash.get": "^4.1.2", + "lodash.merge": "^4.3.0", + "minecraft-data": "^3.55.0", + "minecraft-folder-path": "^1.2.0", + "node-fetch": "^2.6.1", + "node-rsa": "^0.4.2", + "prismarine-auth": "^2.2.0", + "prismarine-chat": "^1.10.0", + "prismarine-nbt": "^2.5.0", + "prismarine-realms": "^1.2.0", + "protodef": "^1.8.0", + "readable-stream": "^4.1.0", + "uuid-1345": "^1.0.1", + "yggdrasil": "^1.4.0" + }, + "engines": { + "node": ">=14" + } + }, + "node_modules/mojangson": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/mojangson/-/mojangson-2.0.4.tgz", + "integrity": "sha512-HYmhgDjr1gzF7trGgvcC/huIg2L8FsVbi/KacRe6r1AswbboGVZDS47SOZlomPuMWvZLas8m9vuHHucdZMwTmQ==", + "license": "MIT", + "dependencies": { + "nearley": "^2.19.5" + } + }, + "node_modules/moo": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/moo/-/moo-0.5.2.tgz", + "integrity": "sha512-iSAJLHYKnX41mKcJKjqvnAN9sf0LMDTXDEvFv+ffuRR9a1MIuXLjMNL6EsnDHSkKLTWNqQQ5uo61P4EbU4NU+Q==", + "license": "BSD-3-Clause" + }, + "node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "license": "MIT" + }, + "node_modules/nearley": { + "version": "2.20.1", + "resolved": "https://registry.npmjs.org/nearley/-/nearley-2.20.1.tgz", + "integrity": "sha512-+Mc8UaAebFzgV+KpI5n7DasuuQCHA89dmwm7JXw3TV43ukfNQ9DnBH3Mdb2g/I4Fdxc26pwimBWvjIw0UAILSQ==", + "license": "MIT", + "dependencies": { + "commander": "^2.19.0", + "moo": "^0.5.0", + "railroad-diagrams": "^1.0.0", + "randexp": "0.4.6" + }, + "bin": { + "nearley-railroad": "bin/nearley-railroad.js", + "nearley-test": "bin/nearley-test.js", + "nearley-unparse": "bin/nearley-unparse.js", + "nearleyc": "bin/nearleyc.js" + }, + "funding": { + "type": "individual", + "url": "https://nearley.js.org/#give-to-nearley" + } + }, + "node_modules/node-fetch": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", + "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "license": "MIT", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, + "node_modules/node-rsa": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/node-rsa/-/node-rsa-0.4.2.tgz", + "integrity": "sha512-Bvso6Zi9LY4otIZefYrscsUpo2mUpiAVIEmSZV2q41sP8tHZoert3Yu6zv4f/RXJqMNZQKCtnhDugIuCma23YA==", + "license": "MIT", + "dependencies": { + "asn1": "0.2.3" + } + }, + "node_modules/prismarine-auth": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/prismarine-auth/-/prismarine-auth-2.5.0.tgz", + "integrity": "sha512-CRv/pL6d/T+4cdjWS223PXG+ygHbz40Kef04L59SLMT+axNdAQro23eZZhgiIIu6u7rlvJcZYlIY93gFNtKxXA==", + "license": "MIT", + "dependencies": { + "@azure/msal-node": "^2.0.2", + "@xboxreplay/xboxlive-auth": "^3.3.3", + "debug": "^4.3.3", + "jose": "^4.1.4", + "node-fetch": "^2.6.1", + "smart-buffer": "^4.1.0", + "uuid-1345": "^1.0.2" + } + }, + "node_modules/prismarine-chat": { + "version": "1.10.1", + "resolved": "https://registry.npmjs.org/prismarine-chat/-/prismarine-chat-1.10.1.tgz", + "integrity": "sha512-XukYcuueuhDxzEXG7r8BZyt6jOObrPPB4JESCgb+/XenB9nExoSHF8eTQWWj8faKPLqm1dRQaYwFJlNBlJZJUw==", + "license": "MIT", + "dependencies": { + "mojangson": "^2.0.1", + "prismarine-nbt": "^2.0.0", + "prismarine-registry": "^1.4.0" + } + }, + "node_modules/prismarine-nbt": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/prismarine-nbt/-/prismarine-nbt-2.5.0.tgz", + "integrity": "sha512-F0/8UAa9SDDnAGrBYqZc4nG8h2zj5cE2eAJU5xlDR/IsQQ3moVxkOjE3h3nMv6SbvZrvAcgX7waA/nd9LLHYdA==", + "license": "MIT", + "dependencies": { + "protodef": "^1.9.0" + } + }, + "node_modules/prismarine-realms": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/prismarine-realms/-/prismarine-realms-1.3.2.tgz", + "integrity": "sha512-5apl9Ru8veTj5q2OozRc4GZOuSIcs3yY4UEtALiLKHstBe8bRw8vNlaz4Zla3jsQ8yP/ul1b1IJINTRbocuA6g==", + "license": "MIT", + "dependencies": { + "debug": "^4.3.3", + "node-fetch": "^2.6.1" + } + }, + "node_modules/prismarine-registry": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/prismarine-registry/-/prismarine-registry-1.7.0.tgz", + "integrity": "sha512-yyva0FpWI078nNeMhx8ekVza5uUTYhEv+C+ADu3wUQXiG8qhXkvrf0uzsnhTgZL8BLdsi2axgCEiKw9qSKIuxQ==", + "license": "MIT", + "dependencies": { + "minecraft-data": "^3.0.0", + "prismarine-nbt": "^2.0.0" + } + }, + "node_modules/process": { + "version": "0.11.10", + "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", + "integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==", + "license": "MIT", + "engines": { + "node": ">= 0.6.0" + } + }, + "node_modules/protodef": { + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/protodef/-/protodef-1.15.0.tgz", + "integrity": "sha512-bZ2Omw8dT+DACjJHLrBWZlqN4MlT9g9oSpJDdkUAJOStUzgJp+Zn42FJfPUdwutUxjaxA0PftN0PDlNa2XbneA==", + "license": "MIT", + "dependencies": { + "lodash.get": "^4.4.2", + "lodash.reduce": "^4.6.0", + "protodef-validator": "^1.3.0", + "readable-stream": "^3.0.3" + }, + "engines": { + "node": ">=14" + } + }, + "node_modules/protodef-validator": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/protodef-validator/-/protodef-validator-1.3.1.tgz", + "integrity": "sha512-lZ5FWKZYR9xOjpMw1+EfZRfCjzNRQWPq+Dk+jki47Sikl2EeWEPnTfnJERwnU/EwFq6us+0zqHHzSsmLeYX+Lg==", + "license": "MIT", + "dependencies": { + "ajv": "^6.5.4" + }, + "bin": { + "protodef-validator": "cli.js" + } + }, + "node_modules/protodef/node_modules/readable-stream": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", + "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", + "license": "MIT", + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/punycode": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/railroad-diagrams": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/railroad-diagrams/-/railroad-diagrams-1.0.0.tgz", + "integrity": "sha512-cz93DjNeLY0idrCNOH6PviZGRN9GJhsdm9hpn1YCS879fj4W+x5IFJhhkRZcwVgMmFF7R82UA/7Oh+R8lLZg6A==", + "license": "CC0-1.0" + }, + "node_modules/randexp": { + "version": "0.4.6", + "resolved": "https://registry.npmjs.org/randexp/-/randexp-0.4.6.tgz", + "integrity": "sha512-80WNmd9DA0tmZrw9qQa62GPPWfuXJknrmVmLcxvq4uZBdYqb1wYoKTmnlGUchvVWe0XiLupYkBoXVOxz3C8DYQ==", + "license": "MIT", + "dependencies": { + "discontinuous-range": "1.0.0", + "ret": "~0.1.10" + }, + "engines": { + "node": ">=0.12" + } + }, + "node_modules/readable-stream": { + "version": "4.5.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-4.5.2.tgz", + "integrity": "sha512-yjavECdqeZ3GLXNgRXgeQEdz9fvDDkNKyHnbHRFtOr7/LcfgBcmct7t/ET+HaCTqfh06OzoAxrkN/IfjJBVe+g==", + "license": "MIT", + "dependencies": { + "abort-controller": "^3.0.0", + "buffer": "^6.0.3", + "events": "^3.3.0", + "process": "^0.11.10", + "string_decoder": "^1.3.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + } + }, + "node_modules/ret": { + "version": "0.1.15", + "resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz", + "integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==", + "license": "MIT", + "engines": { + "node": ">=0.12" + } + }, + "node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "license": "MIT" + }, + "node_modules/semver": { + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/smart-buffer": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz", + "integrity": "sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg==", + "license": "MIT", + "engines": { + "node": ">= 6.0.0", + "npm": ">= 3.0.0" + } + }, + "node_modules/string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "license": "MIT", + "dependencies": { + "safe-buffer": "~5.2.0" + } + }, + "node_modules/string_decoder/node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", + "license": "MIT" + }, + "node_modules/undici-types": { + "version": "6.13.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.13.0.tgz", + "integrity": "sha512-xtFJHudx8S2DSoujjMd1WeWvn7KKWFRESZTMeL1RptAYERu29D6jphMjjY+vn96jvN3kVPDNxU/E13VTaXj6jg==", + "license": "MIT" + }, + "node_modules/uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "license": "BSD-2-Clause", + "dependencies": { + "punycode": "^2.1.0" + } + }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", + "license": "MIT" + }, + "node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "license": "MIT", + "bin": { + "uuid": "dist/bin/uuid" + } + }, + "node_modules/uuid-1345": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/uuid-1345/-/uuid-1345-1.0.2.tgz", + "integrity": "sha512-bA5zYZui+3nwAc0s3VdGQGBfbVsJLVX7Np7ch2aqcEWFi5lsAEcmO3+lx3djM1npgpZI8KY2FITZ2uYTnYUYyw==", + "license": "MIT", + "dependencies": { + "macaddress": "^0.5.1" + } + }, + "node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", + "license": "BSD-2-Clause" + }, + "node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "license": "MIT", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, + "node_modules/yggdrasil": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/yggdrasil/-/yggdrasil-1.7.0.tgz", + "integrity": "sha512-QBIo5fiNd7688G3FqXXYGr36uyrYzczlNuzpWFy2zL3+R+3KT2lF+wFxm51synfA3l3z6IBiGOc1/EVXWCYY1Q==", + "license": "MIT", + "dependencies": { + "node-fetch": "^2.6.1", + "uuid": "^8.2.0" + } + } + } +} diff --git a/package.json b/package.json new file mode 100755 index 0000000..0b0cbce --- /dev/null +++ b/package.json @@ -0,0 +1,15 @@ +{ + "dependencies": { + "minecraft-protocol": "^1.45.0", + "prismarine-chat": "^1.10.0" + }, + "name": "botv10", + "version": "10.0.0-beta-2", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "MIT", + "description": "" +} diff --git a/plugins/!chat.js b/plugins/!chat.js new file mode 100755 index 0000000..347013b --- /dev/null +++ b/plugins/!chat.js @@ -0,0 +1,148 @@ +const settings = require('../settings.json') +const parsePlain = require('../util/chatparse_plain.js') +const parseConsole = require('../util/chatparse_console.js') +const parse1204 = require('../util/parseNBT.js') +const messageTypes = [ + '', + 'chat.type.emote', + 'commands.message.display.incoming', + 'commands.message.display.outgoing', + '', + 'chat.type.announcement', + 'chat.type.team.text', + 'chat.type.team.sent' +] +module.exports = { + load: (b) => { + b._client.on('profileless_chat', (data) => { + if (data.type === 4) { + const json = parse1204(data.message) + const parsed = parsePlain(json) + const split = parsed.split(': ') + const chatName = split.splice(0, 1)[0] + const username = b.findRealName(chatName) + const uuid = b.findUUID(username) + b.emit('chat', { json, type: 'profileless', uuid, message: split.join(': '), username }) + } else if (data.type === 6 || data.type === 7) { + b.emit('chat', { + json: { + translate: messageTypes[data.type], + color: (data.type === 2 || data.type === 3) ? 'gray' : 'reset', + with: [ + parse1204(data.target), + parse1204(data.name), + data.message + ] + }, + type: 'profileless', + uuid: data.senderUuid, + message: parsePlain(data.message), + username: parsePlain(parse1204(data.name)) + }) + } else { + b.emit('chat', { + json: { + translate: messageTypes[data.type], + color: (data.type === 2 || data.type === 3) ? 'gray' : 'reset', + with: [ + parse1204(data.name), + parse1204(data.message) + ] + }, + type: 'profileless', + uuid: '00000000-0000-0000-0000-000000000000', + message: parsePlain(parse1204(data.message)), + username: parsePlain(parse1204(data.name)) + }) + } + }) + + b._client.on('player_chat', (data) => { + if (data.type === 4) { + b.emit('chat', { json: parse1204(data.unsignedChatContent), type: 'player', uuid: data.senderUuid, message: data.plainMessage, username: parsePlain(parse1204(data.networkName)) }) + } else if (data.type === 6 || data.type === 7) { + b.emit('chat', { + json: { + translate: messageTypes[data.type], + color: data.type === 2 ? 'gray' : 'reset', + with: [ + parse1204(data.networkTargetName), + parse1204(data.networkName), + data.plainMessage + ] + }, + type: 'player', + uuid: data.senderUuid, + message: parsePlain(data.plainMessage), + username: parsePlain(parse1204(data.networkName)) + }) + } else { + b.emit('chat', { + json: { + translate: messageTypes[data.type], + color: (data.type === 2 || data.type === 3) ? 'gray' : 'reset', + with: [ + parse1204(data.networkName), + data.plainMessage + ] + }, + type: 'player', + uuid: data.senderUuid, + message: parsePlain(data.plainMessage), + username: parsePlain(parse1204(data.networkName)) + }) + } + }) + + b._client.on('system_chat', (data) => { + const json = parse1204(data.content) + const parsed = parsePlain(json) + const split = parsed.split(': ') + const chatName = split.splice(0, 1)[0] + const username = b.findRealName(chatName) + const uuid = b.findUUID(username) + b.emit('chat', { json, type: 'system', uuid, message: split.join(': '), username }) + }) + + b._client.on('chat', (data) => { // Legacy chat + const json = parse1204(data.message) + const parsed = parsePlain(json) + let chatName + let username + let message + let uuid + if (b.host.options.isVanilla && json.translate === 'chat.type.text') { // Servers without Extras chat + if (json.with && json.with.length >= 2) { + message = parsePlain(json.with[1]) + username = parsePlain(json.with[0]) + } + uuid = b.findUUID(username) + } else { // Servers with Extras chat, such as Kaboom + const split = parsed.split(': ') + message = split.join(': ') + uuid = b.findUUID(username) + chatName = split.splice(0, 1)[0] + username = b.findRealName(chatName) + } + b.emit('chat', { json, type: 'legacy', uuid: data.uuid ? data.uuid : uuid, message, username }) + }) + + b.on('chat', (data) => { + const msgConsole = parseConsole(data.json) + const msgPlain = parsePlain(data.json) + if (settings.logJSONmessages) console.log(data.json) + if (msgPlain.endsWith('\n\n\n\n\nThe chat has been cleared')) return + if (msgPlain.startsWith('Command set: ')) return + b.emit('plainchat', msgPlain) + b.displayChat(data.type, `${msgConsole}\x1b[0m`) + + const fullCommand = data.message + for (const i in b.prefix) { + if (fullCommand.startsWith(b.prefix[i])) { + const command = fullCommand.slice(b.prefix[i].length) + b.runCommand(data.username, data.uuid, command, b.prefix[i]) + } + } + }) + } +} diff --git a/plugins/cloop.js b/plugins/cloop.js new file mode 100755 index 0000000..f67fb46 --- /dev/null +++ b/plugins/cloop.js @@ -0,0 +1,23 @@ +module.exports = { + load: (b) => { + b.cloops = [] + b.addCloop = function (command, rate) { + b.cloops.push({ + command, + rate, + interval: setInterval(() => { b.ccq.push(command) }, rate) + }) + b.ccq.push(command) + } + b.removeCloop = function (index) { + clearInterval(b.cloops[index].interval) + b.cloops.splice(index, 1) + } + b.clearCloops = function () { + for (const i in b.cloops) { + clearInterval(b.cloops[i].interval) + } + b.cloops = [] + } + } +} diff --git a/plugins/command.js b/plugins/command.js new file mode 100755 index 0000000..650235b --- /dev/null +++ b/plugins/command.js @@ -0,0 +1,64 @@ +const Command = require('../util/Command.js') +const hashcheck = require('../util/hashcheck.js') +const settings = require('../settings.json') +const { getMessage } = require('../util/lang.js') +const cmds = require('../util/commands.js') +const fs = require("fs") + +if(!fs.readdirSync('.').includes('userPref')) fs.mkdirSync("userPref"); + +const loadSettings = function(uuid){ + try { + return require(`../userPref/${uuid}.json`) + } catch (e) { + return {} + } +} +module.exports = { + load: (b) => { + b.prefix = settings.prefix + b.lastCmd = 0 + b.runCommand = (name, uuid, text, prefix) => { + if (uuid === '00000000-0000-0000-0000-000000000000') return + if (Date.now() - b.lastCmd <= 1000) return + const userSettings = loadSettings(uuid); + b.lastCmd = Date.now() + const cmd = text.split(' ') + const lang = settings.defaultLang + const verify = hashcheck(cmd) + if (verify > 0) { + text = cmd.slice(0, cmd.length - 1).join(' ') + } + if (cmds[cmd[0].toLowerCase()]) { + const command = cmds[cmd[0].toLowerCase()] + if (command.level !== undefined && command.level > verify) { + b.tellraw(uuid, { + text: getMessage(lang, 'command.disallowed.perms') + }) + b.tellraw(uuid, { + text: getMessage(lang, 'command.disallowed.perms.yourLevel', [verify + '']) + }) + b.tellraw(uuid, { + text: getMessage(lang, 'command.disallowed.perms.cmdLevel', [command.level + '']) + }) + return + } + try { + cmds[cmd[0].toLowerCase()].execute(new Command(uuid, name, 'nick N/A', text, prefix, b, verify, userSettings)) + } catch (e) { + console.log(e) + b.tellraw(uuid, { + text: getMessage(lang, 'command.error'), + color: 'red', + hoverEvent: { + action: 'show_text', + value: { + text: e.stack + } + } + }) + } + } + } + } +} diff --git a/plugins/commandblock.js b/plugins/commandblock.js new file mode 100755 index 0000000..725e65d --- /dev/null +++ b/plugins/commandblock.js @@ -0,0 +1,118 @@ +const uuidToInt = require('../util/uuidtoint.js') +const cs = { + x: 4, + y: 6, + z: 4 +} +module.exports = { + load: function (b) { + b.interval.commandFill = setInterval(() => { if (b.sc_tasks.cc) b.sc_tasks.cc.failed = 1 }, 150000) + b.ccq = [] + b.blocknoX = 0 + b.blocknoZ = 0 + b.ccStarted = false + b.blocknoY = 0 + b.pos = { x: 0, y: 0, z: 0 } + + b.refillCoreCmd = `/fill ~ 55 ~ ~${cs.x - 1} ${54 + cs.y} ~${cs.z - 1} command_block{CustomName:'{"translate":"%s %s","with":[{"translate":"entity.minecraft.ender_dragon"},{"translate":"language.region"}],"color":"#FFAAEE"}'}` + + b.advanceccq = function () { + if (b.ccq[0] && b.ccq[0].length !== 0) { + b._client.write('update_command_block', { + command: b.ccq[0], + location: { + x: b.commandPos.x + b.blocknoX, + y: b.commandPos.y + b.blocknoY, + z: b.commandPos.z + b.blocknoZ + }, + mode: 2, + flags: 1 + }) + b._client.write('update_command_block', { + command: b.ccq[0], + location: { + x: b.commandPos.x + b.blocknoX, + y: b.commandPos.y + b.blocknoY, + z: b.commandPos.z + b.blocknoZ + }, + mode: 2, + flags: 5 + }) + b.blocknoX++ + if (b.blocknoX === cs.x) { + b.blocknoY++ + b.blocknoX = 0 + if (b.blocknoY === cs.y) { + b.blocknoZ++ + b.blocknoY = 0 + if (b.blocknoZ === cs.z) { + b.blocknoZ = 0 + } + } + } + } + b.ccq.splice(0, 1) + } + + b._client.on('login', () => { + b.add_sc_task('cc', () => { + b.chat(b.refillCoreCmd) + }, true) + b.add_sc_task('cc_size', () => { + b.chat('/gamerule commandModificationBlockLimit 32768') + }) + }) + b.on('ccstart', () => { + setTimeout(() => { b.interval.ccqi = setInterval(b.advanceccq, 3) }, 1000) // 1 Second and 3 Milliseconds + b.ccStarted = true + }) + b.on('chat', (data) => { + if (data.json.translate === 'commands.fill.failed' || (data.json.extra && data.json.extra[0] && data.json.extra[0].translate === 'commands.fill.failed') || + data.json.translate === 'commands.fill.success' || (data.json.extra && data.json.extra[0] && data.json.extra[0].translate === 'commands.fill.success')) { + if (!b.ccStarted) { + b.emit('ccstart') + } + b.sc_tasks.cc.failed = 0 + b.sc_tasks.cc_size.failed = 0 + } else if (data.json.translate === 'commands.fill.toobig' || (data.json.extra && data.json.extra[0] && data.json.extra[0].translate === 'commands.fill.toobig')) { + b.sc_tasks.cc_size.failed = 1 + } + }) + b._client.on('position', function (a) { + if (!b.ccStarted) { + b.original_pos = { x: a.x, y: a.y, z: a.z } + b.pos = { x: a.x, y: a.y, z: a.z } + } else { + b.pos = { x: a.x, y: a.y, z: a.z } + if (a.x !== b.original_pos.x || a.z !== b.original_pos.z) { + b.original_pos = { x: a.x, y: a.y, z: a.z } + b.sc_tasks.cc.failed = 1 + } + } + b.commandPos = { + x: Math.floor(a.x), + z: Math.floor(a.z), + y: 55 + } + b._client.write('teleport_confirm', { teleportId: a.teleportId }) + }) + + b.tellraw = (uuid, message) => { + let finalname = '' + if (uuid === '@a') { + finalname = '@a' + } else if (uuid.match(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/)) { + finalname = `@a[nbt={UUID:[I;${uuidToInt(uuid)}]}]` + } else { + finalname = uuid + } + let tellrawCommand + if (b.host.options.isVanilla) { + tellrawCommand = 'tellraw' + } else { + tellrawCommand = 'minecraft:tellraw' + } + b.ccq.push(`/${tellrawCommand} ${finalname} ${JSON.stringify(message)}`) + } + } +} diff --git a/plugins/console.js b/plugins/console.js new file mode 100644 index 0000000..f025f92 --- /dev/null +++ b/plugins/console.js @@ -0,0 +1,52 @@ +const readln = require('readline') +const index = require('../index.js') +const ConsoleCommand = require('../util/ConsoleCommand.js') +const cmds = require('../util/commands.js') +const rl = readln.createInterface({ + input: process.stdin, + output: process.stdout, + prompt: '\x1b[0m> ' +}) +rl.on('line', (l) => { + try { + if (cmds[l.split(' ')[0].toLowerCase()]) { + if (cmds[l.split(' ')[0].toLowerCase()].consoleIndex) { + const tmpcmd = l.split(' ') + const index2 = tmpcmd.splice(1, 1)[0] + if (index2 === '*') { + for (let i = 0; i < index.bot.length; i++) { + const cmd = new ConsoleCommand(tmpcmd.join(' '), i) + cmds[l.split(' ')[0].toLowerCase()].execute(cmd) + } + } else { + const cmd = new ConsoleCommand(tmpcmd.join(' '), +index2) + cmds[l.split(' ')[0].toLowerCase()].execute(cmd) + } + } else { + const cmd = new ConsoleCommand(l, -2) + cmds[l.split(' ')[0].toLowerCase()].execute(cmd) + } + } + } catch (e) { + console.log(e) + } + rl.prompt(false) +}) +rl.prompt() + +function consoleWrite (text) { + readln.cursorTo(process.stdout, 0) + readln.clearLine(process.stdout, 0) + process.stdout.write(text + '\n') + rl.prompt(true) +} +module.exports = { + load: (b) => { + b.info = (msg) => { + consoleWrite(`[${b.id}] [info] ${msg}`) + } + b.displayChat = (type, msg) => { + consoleWrite(`[${b.id}] [${type}] ${msg}`) + } + } +} diff --git a/plugins/cq.js b/plugins/cq.js new file mode 100755 index 0000000..a5ba6f1 --- /dev/null +++ b/plugins/cq.js @@ -0,0 +1,19 @@ +module.exports = { + load: (b) => { + b._client.on('login', () => { + b.interval.chatQueue = setInterval(() => { + if (b.chatqueue.length !== 0) { + b._client.chat(b.chatqueue[0]) + b.chatqueue.splice(0, 1) + } + }, 100) + }) + b.chatqueue = [] + b.chat = function chat (msg) { + if (msg.length === 0) return + msg.match(/.{1,255}/g).forEach(element => { + b.chatqueue.push(element) + }) + } + } +} diff --git a/plugins/player.js b/plugins/player.js new file mode 100644 index 0000000..7c96f4e --- /dev/null +++ b/plugins/player.js @@ -0,0 +1,52 @@ +const parse = require('../util/chatparse_plain') +const parseNBT = require('../util/parseNBT') +module.exports = { + load: (b) => { + b.players = {} + b._client.on('player_info', (data) => { + const buffer2 = {} + for (const i in data.data) { + let uuid + if (data.data[i].uuid) { + uuid = data.data[i].uuid + } else if (data.data[i].UUID) { + uuid = data.data[i].UUID + } + let displayName + if (data.data[i].displayName !== undefined) { + displayName = data.data[i].displayName + } else { + displayName = '{"text":"[[[[ No display name ]]]]"}' + } + if (data.data[i].player && data.data[i].player.name !== undefined) { + buffer2[uuid] = { realName: data.data[i].player.name, displayName: parse(parseNBT(displayName)) } + } else if (data.data[i].name !== undefined) { + buffer2[uuid] = { realName: data.data[i].name, displayName: parse(parseNBT(displayName)) } + } else if (data.data[i].displayName !== undefined) { + buffer2[uuid] = { displayName: displayName.plain } + } + } + for (const uuid in buffer2) { + if (!b.players[uuid]) b.players[uuid] = { displayName: '', realName: '' } + if (buffer2[uuid].displayName) b.players[uuid].displayName = buffer2[uuid].displayName + if (buffer2[uuid].realName) b.players[uuid].realName = buffer2[uuid].realName + } + }) + b.findUUID = (name) => { + for (const i in b.players) { + if (b.players[i].realName === name) { + return i + } + } + return '00000000-0000-0000-0000-000000000000' + } + b.findRealName = (name) => { + for (const i in b.players) { + if (b.players[i].displayName === name) { + return b.players[i].realName + } + } + return '[[[[ no name ]]]]' + } + } +} diff --git a/plugins/rejoin.js b/plugins/rejoin.js new file mode 100755 index 0000000..4962757 --- /dev/null +++ b/plugins/rejoin.js @@ -0,0 +1,15 @@ +const index = require('../index.js') +module.exports = { + load: (b) => { + b._client.on('end', () => { + b.info(`Bot ${b.id} disconnected`) + for (const i in b.interval) { + clearInterval(b.interval[i]) + } + setTimeout(() => { + b.info(`Re-connecting bot ${b.id}`) + index.createBot(b.host, b.id) + }, 5000) + }) + } +} diff --git a/plugins/selfcare.js b/plugins/selfcare.js new file mode 100755 index 0000000..38c184d --- /dev/null +++ b/plugins/selfcare.js @@ -0,0 +1,84 @@ +class SCTask { + constructor (failTask, startFailed = false) { + /* + * failed: Whether to run this task + * failTask: Command to run when failed is true + */ + this.failed = startFailed + this.failTask = failTask + } +} +module.exports = { + load: (b) => { + b.sc_tasks = {} + b.selfcareRun = 0 + b.interval.sc = setInterval(() => { + if(Date.now() - b.selfcareRun <= 600){ + return + } + for (const i in b.sc_tasks) { + if (b.sc_tasks[i].failed) { + b.sc_tasks[i].failTask() + } + } + b.selfcareRun = Date.now() + }, 40) + b.add_sc_task = (name, failTask, startFailed) => { + b.sc_tasks[name] = new SCTask(failTask, startFailed) + } + + // Self care tasks + + // Operator + b.add_sc_task('op', () => { + b.chat('/op @s[type=player]') + }) + b._client.on('login', (p) => { + b.entityId = p.entityId + }) + b._client.on('entity_status', (p) => { + if (p.entityId === b.entityId && p.entityStatus === 24) { + b.sc_tasks.op.failed = 1 + } else if (p.entityId === b.entityId && p.entityStatus === 28) { + b.sc_tasks.op.failed = 0 + } + }) + + // CommandSpy + if (!b.host.options.isVanilla) { + b.add_sc_task('cspy', () => { + b.chat('/cspy on') + }, true) + b.on('plainchat', (msg) => { + if (msg === 'Successfully disabled CommandSpy') { + b.sc_tasks.cspy.failed = 1 + } else if (msg === 'Successfully enabled CommandSpy') { + b.sc_tasks.cspy.failed = 0 + } + }) + } + + // Gamemode + b.add_sc_task('gamemode', () => { + b.chat('/minecraft:gamemode creative') + }) + b._client.on('game_state_change', (p) => { + if (p.reason === 3 && p.gameMode !== 1) { + b.sc_tasks.gamemode.failed = 1 + } else if (p.reason === 3 && p.gameMode === 1) { + b.sc_tasks.gamemode.failed = 0 + } + }) + + // Respawning after dying + b.add_sc_task('respawn', () => { + b._client.write('client_command', { actionId: 0 }) // Simulates respawning + b.sc_tasks.respawn.failed = 0 + }) + b.on('chat', (data) => { + if (data.json.translate === 'chat.disabled.options' || (data.json.extra && data.json.extra[0] && data.json.extra[0].translate === 'chat.disabled.options')) { + b.sc_tasks.respawn.failed = 1 + } + }) + } +} diff --git a/plugins/testing.js b/plugins/testing.js new file mode 100755 index 0000000..f886c5e --- /dev/null +++ b/plugins/testing.js @@ -0,0 +1,5 @@ +module.exports = { + load: (b) => { + + } +} diff --git a/secret_example.json b/secret_example.json new file mode 100644 index 0000000..8d3d67a --- /dev/null +++ b/secret_example.json @@ -0,0 +1,6 @@ +{ + "keyTrusted": "Insert trusted level key here... (PLEASE CHANGE THIS, THIS KEY IS PUBLIC)", + "keyOwner": "Insert owner level key here... (PLEASE CHANGE THIS, THIS KEY IS PUBLIC)", + "onlineEmail": "email@example.com", + "onlinePass": "password" +} diff --git a/settings_example.json b/settings_example.json new file mode 100755 index 0000000..99e412f --- /dev/null +++ b/settings_example.json @@ -0,0 +1,23 @@ +{ + "secret":"/path/to/secrets/file/secret.json", + "version_mc": "1.20.4", + "defaultLang": "en-US", + "terminalMode": "blackTerminal_24bit", + "colors": { + "primary": "#FFCCEE", + "secondary": "#FF99DD" + }, + "prefix":[ + "bot:", + "\"" + ], + "servers":[ + { + "host": "kaboom.pw", + "port": 25565, + "options":{ + "name": "kaboom" + } + } + ] +} diff --git a/util/Command.js b/util/Command.js new file mode 100644 index 0000000..ff9fb45 --- /dev/null +++ b/util/Command.js @@ -0,0 +1,42 @@ +// HOW TO WRITE CLASS JS +const settings = require('../settings.json') +class Command { + constructor (uuid, user, nick, cmd, prefix, bot, verify, prefs) { + this.send = (text, uuid) => { bot.tellraw(uuid || '@a', text) } + this.reply = text => bot.tellraw(uuid, text) + this.uuid = uuid + this.username = user + this.nickname = nick + this.command = cmd + this.prefix = prefix + this.bot = bot + this.type = 'minecraft' + this.index = bot.id + this.args = cmd.split(' ').slice(1) + this.verify = verify + this.host = bot.host.host + this.port = bot.host.port + // this.lang = lang + this.prefs = prefs + if(prefs.lang){ + this.lang = prefs.lang + } else { + this.lang = settings.defaultLang + } + + let _colors = {} + if(prefs.colorPrimary){ + _colors.primary = prefs.colorPrimary + } else { + _colors.primary = settings.colors.primary + } + if(prefs.colorSecondary){ + _colors.secondary = prefs.colorSecondary + } else { + _colors.secondary = settings.colors.secondary + } + this.colors = _colors + } +} + +module.exports = Command diff --git a/util/ConsoleCommand.js b/util/ConsoleCommand.js new file mode 100644 index 0000000..1a4f3e9 --- /dev/null +++ b/util/ConsoleCommand.js @@ -0,0 +1,28 @@ +// HOW TO WRITE CLASS JS +const index = require('../index.js') +const parse = require('../util/chatparse_console.js') +const settings = require('../settings.json') +class ConsoleCommand { + constructor (cmd, index2) { + this.send = () => {} // not needed for console + this.reply = text => process.stdout.write(parse(text) + '\n') + this.uuid = 'dde5a2a6-ebdd-7bbb-8eac-f75b10c10446' // hard-coded because uuid does not exist at console + this.username = 'Owner' + this.nickname = 'Console' + this.command = cmd + this.prefix = '' // prefix does not exist at console + this.bot = index2 >= 0 + ? index.bot[index2] + : {} + this.type = 'console' + this.index = index2 + this.args = cmd.split(' ').slice(1) + this.verify = 3 + this.host = '' + this.port = '3' // :3 + this.lang = settings.defaultLang + this.colors = settings.colors + } +} + +module.exports = ConsoleCommand diff --git a/util/chatparse_console.js b/util/chatparse_console.js new file mode 100644 index 0000000..435d9e0 --- /dev/null +++ b/util/chatparse_console.js @@ -0,0 +1,104 @@ +const settings = require('../settings.json') +const lang = require('./mc_lang.js') +const _consoleColors = require('./consolecolors.json') + +let consoleColors +let consoleColors24 +if (_consoleColors[settings.terminalMode]) { + consoleColors = _consoleColors[settings.terminalMode].fourBit + consoleColors24 = _consoleColors[settings.terminalMode].twentyFourBit +} else { + consoleColors = _consoleColors.none.fourBit + consoleColors24 = _consoleColors.none.twentyFourBit +} + +const hexColorParser = (color) => { + if (!consoleColors24.enabled || consoleColors24.bit !== 24) { // Hex color parsing to the 8 bit and 4 bit modes has not been implemented yet + return '' + } + let out = '\x1B[0;' + const redChannel = Number(`0x${color.slice(1, 3)}`) + const greenChannel = Number(`0x${color.slice(3, 5)}`) + const blueChannel = Number(`0x${color.slice(5, 7)}`) + if (!consoleColors24.lightMode && redChannel < 64 && greenChannel < 64 && blueChannel < 64) { + out += '48;2;220;220;220;' + } else if (consoleColors24.lightMode && ((redChannel > 192 && greenChannel > 192 && blueChannel > 192) || greenChannel > 160)) { + out += '48;2;0;0;0;' + } + return out + `38;2;${redChannel};${greenChannel};${blueChannel}m` +} + +const processColor = (col, rcol) => { + let out + if (col === 'reset') { + out = rcol + } else if (col.startsWith('#')) { + out = hexColorParser(col) + } else { + out = consoleColors[col] + } + return out +} + +const parse = function (_data, l = 0, resetColor = consoleColors.reset) { + if (l >= 4) { + return '' + } + let data + if (typeof _data === 'string') { + data = { text: _data, color: 'reset' } + } else if (typeof _data === 'number') { + data = { text: _data + '', color: 'reset' } + } else if (_data.constructor === Array) { + data = { extra: _data, color: 'reset' } + } else { + data = _data + } + if (data['']) { + data.text = data[''] + if (!data.color) data.color = 'reset' + } + + let out = '' + if (data.color) { + out += processColor(data.color, resetColor) + } else { + out += resetColor + } + if (data.text) { + let _text = data.text + if (typeof _text === 'number') { + _text = _text.toString() + } + out += _text.replaceAll('\x1b', '').replaceAll('\x0e', '') // Remove escape codes and [SO] from console format + } + if (data.translate) { + let trans = data.translate.replace(/%%/g, '\ue123').replaceAll('\x1b', '').replaceAll('\x0e', '') // Remove escape codes from console format + if (lang[trans] !== undefined) { + trans = lang[trans].replace(/%%/g, '\ue123') + } + for (const i in data.with) { + const j2 = parse(data.with[i], l + 1, data.color ? processColor(data.color, resetColor) : resetColor) + trans = trans.replace(/%s/, j2.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + trans = trans.replaceAll(`%${+i + 1}$s`, j2.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + } + out += trans.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s') + } + if (data.extra) { + for (const i in data.extra) { + const parsed = parse(data.extra[i], l, data.color ? processColor(data.color, resetColor) : resetColor) + out += parsed + } + } + out += resetColor + return out +} +const parse2 = function (_data, l, resetColor) { + try { + return parse(_data) + } catch (e) { + console.error(e) + return `\x1B[0m\x1B[38;2;255;85;85mAn error occured while parsing a message. See console for more information.\nJSON that caused the error: ${JSON.stringify(_data)}` + } +} +module.exports = parse2 diff --git a/util/chatparse_plain.js b/util/chatparse_plain.js new file mode 100644 index 0000000..8b15ba4 --- /dev/null +++ b/util/chatparse_plain.js @@ -0,0 +1,55 @@ +const lang = require('./mc_lang.js') +const parse = function (_data, l = 0) { + if (l >= 4) { + return '' + } + let data + if (typeof _data === 'string') { + data = { text: _data } + } else if (typeof _data === 'number') { + data = { text: _data + '' } + } else if (_data.constructor === Array) { + data = { extra: _data } + } else { + data = _data + } + let out = '' + if (data['']) { + data.text = data[''] + } + if (data.text) { + let _text = data.text + if (typeof _text === 'number') { + _text = _text.toString() + } + out += _text + } + if (data.translate) { + let trans = data.translate.replace(/%%/g, '\ue123') + if (lang[trans] !== undefined) { + trans = lang[trans].replace(/%%/g, '\ue123') + } + for (const i in data.with) { + const j2 = parse(data.with[i], l + 1) + trans = trans.replace(/%s/, j2.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + trans = trans.replaceAll(`%${+i + 1}$s`, j2.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + } + out += trans.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s') + } + if (data.extra) { + for (const i in data.extra) { + const parsed = parse(data.extra[i], l) + out += parsed + } + } + return out +} +const parse2 = function (_data, l) { + try { + return parse(_data) + } catch (e) { + console.error(e) + return `An error occured while parsing a message. See console for more information. JSON that caused the error: ${JSON.stringify(_data)}` + } +} +module.exports = parse2 diff --git a/util/commands.js b/util/commands.js new file mode 100644 index 0000000..58344c9 --- /dev/null +++ b/util/commands.js @@ -0,0 +1,28 @@ +const fs = require('fs') +const cmds = Object.create(null) +const bpl = fs.readdirSync('./commands') +for (const i in bpl) { + if (!bpl[i].endsWith('.js')) { + continue + } + try { + const commandName = bpl[i].split('.js')[0] + cmds[commandName] = require(`../commands/${bpl[i]}`) + if (cmds[commandName].level === undefined) { + cmds[commandName].level = 0 + } + if (cmds[commandName].aliases) { + for (const j in cmds[commandName].aliases) { + cmds[cmds[commandName].aliases[j]] = { + execute: cmds[commandName].execute, + alias: commandName, + usage: cmds[commandName].usage, + level: cmds[commandName].level, + hidden: true, + consoleIndex: cmds[commandName].consoleIndex + } + } + } + } catch (e) { console.log(e) } +} +module.exports = cmds diff --git a/util/consolecolors.json b/util/consolecolors.json new file mode 100644 index 0000000..681d28d --- /dev/null +++ b/util/consolecolors.json @@ -0,0 +1,182 @@ +{ + "blackTerminal_24bit":{ + "fourBit":{ + "dark_red": "\u001B[0;38;2;170;0;0m", + "red": "\u001B[0;38;2;255;85;85m", + "dark_green": "\u001B[0;38;2;0;170;0m", + "green": "\u001B[0;38;2;85;255;85m", + "gold": "\u001B[0;38;2;255;170;0m", + "yellow": "\u001B[0;38;2;255;255;85m", + "dark_blue": "\u001B[0;38;2;0;0;170m", + "blue": "\u001B[0;38;2;85;85;255m", + "dark_purple": "\u001B[0;38;2;170;0;170m", + "light_purple": "\u001B[0;38;2;255;85;255m", + "dark_aqua": "\u001B[0;38;2;0;170;170m", + "aqua": "\u001B[0;38;2;85;255;255m", + "black": "\u001B[0;48;2;220;220;220;38;2;0;0;0m", + "gray": "\u001B[0;38;2;170;170;170m", + "dark_gray": "\u001B[0;38;2;85;85;85m", + "white": "\u001B[0;38;2;255;255;255m", + "reset": "\u001B[0;38;2;255;255;255m" + }, + "twentyFourBit":{ + "enabled": true, + "bit": 24, + "lightMode": false + } + }, + "whiteTerminal_24bit":{ + "fourBit":{ + "dark_red": "\u001B[0;38;2;170;0;0m", + "red": "\u001B[0;38;2;255;85;85m", + "dark_green": "\u001B[0;38;2;0;170;0m", + "green": "\u001B[0;48;2;20;20;20;38;2;85;255;85m", + "gold": "\u001B[0;38;2;255;170;0m", + "yellow": "\u001B[0;48;2;20;20;20;38;2;255;255;85m", + "dark_blue": "\u001B[0;38;2;0;0;170m", + "blue": "\u001B[0;38;2;85;85;255m", + "dark_purple": "\u001B[0;38;2;170;0;170m", + "light_purple": "\u001B[0;38;2;255;85;255m", + "dark_aqua": "\u001B[0;38;2;0;170;170m", + "aqua": "\u001B[0;48;2;20;20;20;38;2;85;255;255m", + "black": "\u001B[0;38;2;0;0;0m", + "gray": "\u001B[0;38;2;170;170;170m", + "dark_gray": "\u001B[0;38;2;85;85;85m", + "white": "\u001B[0;48;2;20;20;20;38;2;255;255;255m", + "reset": "\u001B[0;48;2;20;20;20;38;2;255;255;255m" + }, + "twentyFourBit":{ + "enabled": true, + "bit": 24, + "lightMode": true + } + }, + "blackTerminal_8bit":{ + "fourBit":{ + "dark_red": "\u001B[0;38;5;1m", + "red": "\u001B[0;38;5;9m", + "dark_green": "\u001B[0;38;5;2m", + "green": "\u001B[0;38;5;10m", + "gold": "\u001B[0;38;5;3m", + "yellow": "\u001B[0;38;5;11m", + "dark_blue": "\u001B[0;38;5;4m", + "blue": "\u001B[0;38;5;12m", + "dark_purple": "\u001B[0;38;5;5m", + "light_purple": "\u001B[0;38;5;13m", + "dark_aqua": "\u001B[0;38;5;6m", + "aqua": "\u001B[0;38;5;14m", + "black": "\u001B[0;48;5;15;38;5;0m", + "gray": "\u001B[0;38;5;7m", + "dark_gray": "\u001B[0;38;5;8m", + "white": "\u001B[0;38;5;15m", + "reset": "\u001B[0;38;5;15m" + }, + "twentyFourBit":{ + "enabled": true, + "bit": 8, + "lightMode": false + } + }, + "whiteTerminal_8bit":{ + "fourBit":{ + "dark_red": "\u001B[0;38;5;1m", + "red": "\u001B[0;38;5;9m", + "dark_green": "\u001B[0;38;5;2m", + "green": "\u001B[0;48;5;0;38;5;10m", + "gold": "\u001B[0;38;5;3m", + "yellow": "\u001B[0;48;5;0;38;5;11m", + "dark_blue": "\u001B[0;38;5;4m", + "blue": "\u001B[0;38;5;12m", + "dark_purple": "\u001B[0;38;5;5m", + "light_purple": "\u001B[0;38;5;13m", + "dark_aqua": "\u001B[0;38;5;6m", + "aqua": "\u001B[0;48;5;0;38;5;14m", + "black": "\u001B[0;38;5;0m", + "gray": "\u001B[0;38;5;7m", + "dark_gray": "\u001B[0;38;5;8m", + "white": "\u001B[0;48;5;0;38;5;15m", + "reset": "\u001B[0;48;5;0;38;5;15m" + }, + "twentyFourBit":{ + "enabled": true, + "bit": 8, + "lightMode": true + } + }, + "blackTerminal_4bit":{ + "fourBit":{ + "dark_red": "\u001B[0;31m", + "red": "\u001B[0;1;31m", + "dark_green": "\u001B[0;32m", + "green": "\u001B[0;1;32m", + "gold": "\u001B[0;33m", + "yellow": "\u001B[0;1;33m", + "dark_blue": "\u001B[0;34m", + "blue": "\u001B[0;1;34m", + "dark_purple": "\u001B[0;35m", + "light_purple": "\u001B[0;1;35m", + "dark_aqua": "\u001B[0;36m", + "aqua": "\u001B[0;1;36m", + "black": "\u001B[0;1;47;30m", + "gray": "\u001B[0;37m", + "dark_gray": "\u001B[0;1;30m", + "white": "\u001B[0;1;37m", + "reset": "\u001B[0;1;37m" + }, + "twentyFourBit":{ + "enabled": true, + "bit": 4, + "lightMode": false + } + }, + "whiteTerminal_4bit":{ + "fourBit":{ + "dark_red": "\u001B[0;31m", + "red": "\u001B[0;1;31m", + "dark_green": "\u001B[0;32m", + "green": "\u001B[0;40;1;32m", + "gold": "\u001B[0;33m", + "yellow": "\u001B[0;40;1;33m", + "dark_blue": "\u001B[0;34m", + "blue": "\u001B[0;1;34m", + "dark_purple": "\u001B[0;35m", + "light_purple": "\u001B[0;1;35m", + "dark_aqua": "\u001B[0;36m", + "aqua": "\u001B[0;40;1;36m", + "black": "\u001B[0;30m", + "gray": "\u001B[0;37m", + "dark_gray": "\u001B[0;1;30m", + "white": "\u001B[0;40;1;37m", + "reset": "\u001B[0;40;1;37m" + }, + "twentyFourBit":{ + "enabled": true, + "bit": 4, + "lightMode": true + } + }, + "none":{ + "fourBit":{ + "dark_red": "", + "red": "", + "dark_green": "", + "green": "", + "gold": "", + "yellow": "", + "dark_blue": "", + "blue": "", + "dark_purple": "", + "light_purple": "", + "dark_aqua": "", + "aqua": "", + "black": "", + "gray": "", + "dark_gray": "", + "white": "", + "reset": "" + }, + "twentyFourBit":{ + "enabled": false + } + } +} \ No newline at end of file diff --git a/util/hashcheck.js b/util/hashcheck.js new file mode 100644 index 0000000..3cad0c2 --- /dev/null +++ b/util/hashcheck.js @@ -0,0 +1,19 @@ +const crypto = require('crypto') +const settings = require('../settings.json') +const secret = require(settings.secret) +module.exports = function (cmd) { + const cmdWithoutHash = cmd.slice(0, cmd.length - 1).join(' ') + const _dateString = Date.now().toString() + const dateString = _dateString.slice(0, _dateString.length - 4) + const hashTrusted = `babyboom:${secret.keyTrusted}:${cmdWithoutHash}:${dateString}` + const hashOwner = `babyboom:${secret.keyOwner}:${cmdWithoutHash}:${dateString}` + const validhashT = crypto.createHash('sha256').update(hashTrusted).digest('hex') + const validhashO = crypto.createHash('sha256').update(hashOwner).digest('hex') + if (cmd[cmd.length - 1] === validhashT) { + return 1 + } + if (cmd[cmd.length - 1] === validhashO) { + return 2 + } + return 0 +} diff --git a/util/lang.js b/util/lang.js new file mode 100644 index 0000000..1ee3436 --- /dev/null +++ b/util/lang.js @@ -0,0 +1,63 @@ +const fs = require('fs') +const languages = {} + +const loadplug = (botno) => { + const bpl = fs.readdirSync('util/lang') + for (const i in bpl) { + if (!bpl[i].endsWith('.json')) { + continue + } + try { + languages[bpl[i].split('.')[0]] = require(`./lang/${bpl[i]}`) + } catch (e) { console.log(e) } + } +} +loadplug() + +const getMessage = function (l, msg, with2) { + let message = msg.replace(/%%/g, '\ue123') + if (languages[l] && languages[l][message] !== undefined) { + message = languages[l][message].replace(/%%/g, '\ue123') + } else if (languages['en-US'] && languages['en-US'][message] !== undefined) { + message = languages['en-US'][message].replace(/%%/g, '\ue123') + } + for (const i in with2) { + message = message.replace(/%s/, with2[i].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + message = message.replaceAll(`%${+i + 1}$s`, with2[i].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + } + return message.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s') +} + +module.exports = { + languages: Object.keys(languages), + getMessage, + formatTime: function (time, language) { + let finalString = '' + const seconds = Math.floor(time / 1000) % 60 + const minutes = Math.floor(time / 60000) % 60 + const hours = Math.floor(time / 3600000) % 24 + const days = Math.floor(time / 86400000) % 7 + const weeks = Math.floor(time / 604800000) + if (weeks !== 0) { + finalString += weeks + finalString += `${weeks === 1 ? getMessage(language, 'time.week') : getMessage(language, 'time.weekPlural')}` + } + if (days !== 0) { + finalString += days + finalString += `${days === 1 ? getMessage(language, 'time.day') : getMessage(language, 'time.dayPlural')}` + } + if (hours !== 0) { + finalString += hours + finalString += `${hours === 1 ? getMessage(language, 'time.hour') : getMessage(language, 'time.hourPlural')}` + } + if (minutes !== 0) { + finalString += minutes + finalString += `${minutes === 1 ? getMessage(language, 'time.minute') : getMessage(language, 'time.minutePlural')}` + } + if (seconds !== 0) { + finalString += seconds + finalString += `${seconds === 1 ? getMessage(language, 'time.second') : getMessage(language, 'time.secondPlural')}` + } + return finalString + } +} diff --git a/util/lang/en-US.json b/util/lang/en-US.json new file mode 100644 index 0000000..7564269 --- /dev/null +++ b/util/lang/en-US.json @@ -0,0 +1,98 @@ +{ + "language.name": "English", + "language.region": "United States", + "time.week": " week ", + "time.weekPlural": " weeks ", + "time.day": " day ", + "time.dayPlural": " days ", + "time.hour": " hour ", + "time.hourPlural": " hours ", + "time.minute": " minute ", + "time.minutePlural": " minutes ", + "time.second": " second ", + "time.secondPlural": " seconds ", + "command.about.usage": "", + "command.about.desc": "About the bot", + "command.cb.usage": " ", + "command.cb.desc": "Run a command in a command block", + "command.cloop.usage": " add || remove || list|| clear", + "command.cloop.desc": "Manage command loops", + "command.eval.usage": " ", + "command.eval.desc": "Run JavaScript code", + "command.help.usage": " [cmd]", + "command.help.desc": "Shows command help", + "command.logoff.usage": "", + "command.logoff.desc": "Disconnect and reconnect the bot from a server", + "command.netmsg.usage": " ", + "command.netmsg.desc": "Send a message to all servers the bot is connected to", + "command.refill.usage": "", + "command.refill.desc": "Refill core", + "command.say.usage": " ", + "command.say.desc": "Sends a message to chat", + "command.stop.usage": "", + "command.stop.desc": "Restart bot", + "command.template.usage": " [optional]", + "command.template.desc": "Does nothing", + "command.tpr.desc": "Teleport to a random location", + "command.tpr.usage": "", + "command.verify.usage": " [args...]", + "command.verify.desc": "Check the hashing system", + "command.about.author": "%s - a Minecraft bot made by %s for Kaboom and clones", + "command.about.version": "Version %s", + "command.about.preRelease": "This is prerelease software - there may be errors, and features may be changed or removed at any time.", + "command.about.sourceCode": "Source code: %s", + "command.about.sourceCode.openInBrowser": "Click to open the source code link in your default browser", + "command.cloop.error.tooShort": "Command loops must have a rate above 20ms.", + "command.cloop.error.subcommand": "Unknown subcommand, please do %s", + "command.cloop.success.add": "Added command loop with command %s and rate %s", + "command.cloop.success.remove": "Removed command loop %s", + "command.cloop.success.clear": "Cleared all command loops", + "command.cloop.list": "%s: Command: %s Rate: %s", + "command.help.cmdList": "Commands:", + "command.help.commandInfo": "%s%s - %s", + "command.help.commandUsage": "Usage - %s%s", + "command.help.commandDesc": "Description - %s", + "command.help.commandPerms": "Required permissions - %s", + "command.help.permsNormal": "Normal", + "command.help.permsTrusted": "Trusted", + "command.help.permsOwner": "Owner", + "command.help.permsConsole": "Console", + "command.help.noCommand": "Command does not exist", + "command.help.alias": "Alias to %s", + "command.netmsg.disabled": "This command has been disabled on this server.", + "command.settings.get.colorPrimary": "Primary color", + "command.settings.get.colorSecondary": "Secondary color", + "command.settings.get.language": "Language", + "command.settings.setLanguage": "Run %s to set this as your language", + "command.settings.error.invalidKey": "Invalid key", + "command.settings.error.invalidLanguage": "Invalid language", + "command.settings.error.mustProvideValue": "You must provide a value", + "command.about.serverInfo.os.android": "Android %s", + "command.about.serverInfo.os.android.noVersion": "Android", + "command.about.serverInfo.os.freebsd": "FreeBSD %s", + "command.about.serverInfo.os.linux": "Linux %s", + "command.about.serverInfo.os.macos": "macOS", + "command.about.serverInfo.os.macos_old": "OS X", + "command.about.serverInfo.os": "Operating system", + "command.about.serverInfo.processor": "CPU", + "command.about.serverInfo.arch": "Architecture", + "command.about.serverInfo.osUsername": "Username", + "command.about.serverInfo.hostName": "Hostname", + "command.about.serverInfo.workingDir": "Working directory", + "command.about.serverInfo.runTime": "Bot uptime", + "command.about.serverInfo.upTime": "System uptime", + "command.about.serverInfo.nodeVersion": "Node.js version", + "command.about.serverInfo.osRelease": "Linux release", + "command.about.serverInfo.osRelease.missing": "/etc/os-release does not exist. Information may be limited.", + "command.about.serverInfo.os.android.version": "Android version", + "command.about.serverInfo.os.android.model": "Device model", + "command.about.serverInfo.botName": "Bot name", + "command.about.serverInfo.botVer": "Bot version", + "command.tpr.success": "Teleporting %s to %s, %s, %s", + "command.verify.success": "Successfully verified with permission level %s", + "command.error": "An error occured (check console for more info)", + "command.disallowed.perms": "You do not have permission to run this command. If you do have permission, please make sure you put the command hash at the end, or ran the command through your client's hashing system.", + "command.disallowed.perms.yourLevel": "Your permission level: %s", + "command.disallowed.perms.cmdLevel": "Command requires: %s", + "copyText": "Click to copy!" +} diff --git a/util/mc_lang.js b/util/mc_lang.js new file mode 100644 index 0000000..971486e --- /dev/null +++ b/util/mc_lang.js @@ -0,0 +1,6 @@ +const _lang = require('minecraft-data')('1.20.2').language +const lang = Object.create(null) // Without constructor function +for (const i in _lang) { + lang[i] = _lang[i] +} +module.exports = lang diff --git a/util/parseNBT.js b/util/parseNBT.js new file mode 100644 index 0000000..3add56e --- /dev/null +++ b/util/parseNBT.js @@ -0,0 +1,11 @@ +const { processNbtMessage } = require('prismarine-chat') +const parse = function (data) { + if (typeof data.type === 'string') { + return JSON.parse(processNbtMessage(data)) + } else if (typeof data === 'string') { + return JSON.parse(data) + } else { + return data + } +} +module.exports = parse diff --git a/util/usergen.js b/util/usergen.js new file mode 100644 index 0000000..ce845c3 --- /dev/null +++ b/util/usergen.js @@ -0,0 +1,38 @@ +const rsg = function (count) { + let output = '' + for (let i = 0; i < count; i++) { + const type = Math.floor(Math.random() * 6) + switch (type) { + case 0: + output += ' ' + break + case 1: + output += '§§' + break + case 2: + output += '§ ' + break + case 3: + case 4: + case 5:{ // Make this case more likely + let rng = Math.floor(Math.random() * 16) + 1 + if (rng === 7) rng = 17 // No bells + if (rng === 10) rng = 18 // No line feeds + if (rng === 11) rng = 19 // No vertical tabulations + if (rng === 12) rng = 20 // No form feed + if (rng === 13) rng = 21 // No carriage returns + if (rng === 14) rng = 22 // No shift out + if (rng === 15) rng = 23 // No shift in + output += `§${String.fromCharCode(rng)}` + } + } + } + return output +} +module.exports = function (legal) { + if (legal) { + return Math.floor(Math.random() * 1000000).toString() + } else { + return rsg(6 + Math.floor(Math.random() * 3)) + } +} diff --git a/util/uuidtoint.js b/util/uuidtoint.js new file mode 100644 index 0000000..e4470d2 --- /dev/null +++ b/util/uuidtoint.js @@ -0,0 +1,5 @@ +module.exports = function (uuid) { + const splitUUID = uuid.replace(/[^0-9a-f]/g, '').replace(/.{1,8}/g, a => { return `0x${a}` }).match(/.{1,10}/g) + const numUUID = [+splitUUID[0] << 0, +splitUUID[1] << 0, +splitUUID[2] << 0, +splitUUID[3] << 0] + return numUUID +} diff --git a/util/version.js b/util/version.js new file mode 100644 index 0000000..5ecf7e5 --- /dev/null +++ b/util/version.js @@ -0,0 +1,20 @@ +const version = require('../version.json') +const cp = require('child_process') + +let botVersion = version.botVersion +let gitCommit +let gitBranch + +try { + gitCommit = cp.execSync('git rev-parse --short HEAD').toString('UTF-8').split('\n')[0] + gitBranch = cp.execSync('git rev-parse --abbrev-ref HEAD').toString('UTF-8').split('\n')[0] +} catch (e) { + gitCommit = false + gitBranch = false +} + +if (gitCommit) { + botVersion += ` (${gitCommit} - ${gitBranch})` +} + +module.exports = botVersion diff --git a/version.json b/version.json new file mode 100644 index 0000000..71dc8d3 --- /dev/null +++ b/version.json @@ -0,0 +1,7 @@ +{ + "botName": "botvX Dev", + "botVersion": "10.0.0-beta.2", + "botAuthor": "a5a06d596f15c7db", + "isPreRelease": true, + "sourceURL": "https://code.chipmunk.land/7cc5c4f330d47060/botvX" +} From a0be4b8b9d3d4723030ba661d2c1cf485421bf1c Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 12 Aug 2024 04:46:54 -0400 Subject: [PATCH 314/362] Update packages (this better not still say 1 commit) --- package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 67df430..d27dd66 100755 --- a/package-lock.json +++ b/package-lock.json @@ -1,13 +1,13 @@ { "name": "botv10", - "version": "10.0.0", + "version": "10.0.0-beta-2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "botv10", - "version": "10.0.0", - "license": "UNLICENSED", + "version": "10.0.0-beta-2", + "license": "MIT", "dependencies": { "minecraft-protocol": "^1.45.0", "prismarine-chat": "^1.10.0" From 67f95bae154bdc1d91521cfad874c0e023187c54 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 <7cc5c4f330d47060@noreply.localhost> Date: Mon, 12 Aug 2024 05:55:22 -0400 Subject: [PATCH 315/362] Update version.json --- version.json | 1 + 1 file changed, 1 insertion(+) diff --git a/version.json b/version.json index 71dc8d3..3a93298 100644 --- a/version.json +++ b/version.json @@ -5,3 +5,4 @@ "isPreRelease": true, "sourceURL": "https://code.chipmunk.land/7cc5c4f330d47060/botvX" } + From 0c0c05f820da9666078a95d3f5945420af2d16d7 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 <7cc5c4f330d47060@noreply.localhost> Date: Mon, 12 Aug 2024 20:34:55 -0400 Subject: [PATCH 316/362] Update version.json --- version.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/version.json b/version.json index 3a93298..10fcd57 100644 --- a/version.json +++ b/version.json @@ -4,5 +4,4 @@ "botAuthor": "a5a06d596f15c7db", "isPreRelease": true, "sourceURL": "https://code.chipmunk.land/7cc5c4f330d47060/botvX" -} - +} \ No newline at end of file From 13a7ddc778e0b4d7efb52d995c6b7bb6ddd37d4b Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 12 Aug 2024 20:46:26 -0400 Subject: [PATCH 317/362] This is NOT a release candidate yet --- version.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.json b/version.json index 10fcd57..e9d2ba3 100644 --- a/version.json +++ b/version.json @@ -1,6 +1,6 @@ { "botName": "botvX Dev", - "botVersion": "10.0.0-beta.2", + "botVersion": "10.0.0-rc.1", "botAuthor": "a5a06d596f15c7db", "isPreRelease": true, "sourceURL": "https://code.chipmunk.land/7cc5c4f330d47060/botvX" From b2c5e2e353a5cd9ba5133496b94afef40bbbb2cc Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 12 Aug 2024 20:48:38 -0400 Subject: [PATCH 318/362] Change prerelease warning --- util/lang/en-US.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/lang/en-US.json b/util/lang/en-US.json index 7564269..50c8b31 100644 --- a/util/lang/en-US.json +++ b/util/lang/en-US.json @@ -39,7 +39,7 @@ "command.verify.desc": "Check the hashing system", "command.about.author": "%s - a Minecraft bot made by %s for Kaboom and clones", "command.about.version": "Version %s", - "command.about.preRelease": "This is prerelease software - there may be errors, and features may be changed or removed at any time.", + "command.about.preRelease": "This is a development version - there may be errors, and features may be changed or removed at any time. Please report any errors to the bot's developer.", "command.about.sourceCode": "Source code: %s", "command.about.sourceCode.openInBrowser": "Click to open the source code link in your default browser", "command.cloop.error.tooShort": "Command loops must have a rate above 20ms.", From fd62d27352e8f9a1246caed40a9f9ddae85773c0 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 13 Aug 2024 02:04:47 -0400 Subject: [PATCH 319/362] Move lang files --- {util/lang => lang}/en-US.json | 0 util/lang.js | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) rename {util/lang => lang}/en-US.json (100%) diff --git a/util/lang/en-US.json b/lang/en-US.json similarity index 100% rename from util/lang/en-US.json rename to lang/en-US.json diff --git a/util/lang.js b/util/lang.js index 1ee3436..64af12a 100644 --- a/util/lang.js +++ b/util/lang.js @@ -2,13 +2,13 @@ const fs = require('fs') const languages = {} const loadplug = (botno) => { - const bpl = fs.readdirSync('util/lang') + const bpl = fs.readdirSync('lang') for (const i in bpl) { if (!bpl[i].endsWith('.json')) { continue } try { - languages[bpl[i].split('.')[0]] = require(`./lang/${bpl[i]}`) + languages[bpl[i].split('.')[0]] = require(`../lang/${bpl[i]}`) } catch (e) { console.log(e) } } } From 58df0b2b6a9dd50c56f3c1fa593d789dfb003ad1 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 13 Aug 2024 02:07:37 -0400 Subject: [PATCH 320/362] Rename netmsgDisabled to hidden --- commands/netmsg.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/commands/netmsg.js b/commands/netmsg.js index cecac56..8fe5582 100644 --- a/commands/netmsg.js +++ b/commands/netmsg.js @@ -2,7 +2,7 @@ const { bot } = require('../index.js') const { getMessage } = require('../util/lang.js') module.exports = { execute: (c) => { - if(c.bot.host && c.bot.host.options.netmsgDisabled){ + if(c.bot.host && c.bot.host.options.hidden){ c.reply({ text: getMessage(c.lang, "command.netmsg.disabled"), color: c.colors.secondary @@ -37,7 +37,7 @@ module.exports = { color: 'white' } for (const i in bot) { - if(bot[i].host.options.netmsgDisabled) continue + if(bot[i].host.options.hidden) continue bot[i].tellraw('@a', json) } } From 58b94697bbe10b9df037b8d59fb4ff3869e5b2b9 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 13 Aug 2024 02:08:23 -0400 Subject: [PATCH 321/362] Add serverlist to about command --- commands/about.js | 24 ++++++++++++++++++++++++ lang/en-US.json | 1 + 2 files changed, 25 insertions(+) diff --git a/commands/about.js b/commands/about.js index 96a5e9d..22a8487 100644 --- a/commands/about.js +++ b/commands/about.js @@ -4,6 +4,7 @@ const { getMessage, formatTime } = require('../util/lang.js') const fs = require('fs') const botVersion = require('../util/version.js') const version = require('../version.json') +const index = require('../index.js') const aboutBot = function (c) { c.reply({ @@ -178,10 +179,33 @@ const aboutServer = function (c) { return botVersion }) } + +const displayServerList = function (c) { + for(const i in index.bot){ + if(index.bot[i].host.options && index.bot[i].host.options.hidden) continue + c.reply({ + translate: getMessage(c.lang, 'command.about.serverListItem'), + color: c.colors.secondary, + with:[ + { + text: i.toString(), + color: c.colors.primary + }, + { + text: `${index.bot[i].host.host}:${index.bot[i].host.port}`, + color: c.colors.primary + } + ] + }) + } +} + module.exports = { execute: function (c) { if (c.args[0] === 'server') { aboutServer(c) + } else if (c.args[0] === 'serverlist') { + displayServerList(c) } else { aboutBot(c) } diff --git a/lang/en-US.json b/lang/en-US.json index 50c8b31..d0dd80f 100644 --- a/lang/en-US.json +++ b/lang/en-US.json @@ -88,6 +88,7 @@ "command.about.serverInfo.os.android.model": "Device model", "command.about.serverInfo.botName": "Bot name", "command.about.serverInfo.botVer": "Bot version", + "command.about.serverListItem": "Server %s - %s", "command.tpr.success": "Teleporting %s to %s, %s, %s", "command.verify.success": "Successfully verified with permission level %s", "command.error": "An error occured (check console for more info)", From 6310355a8abf42320214a9c7472a3039e8c69167 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 13 Aug 2024 02:13:01 -0400 Subject: [PATCH 322/362] Add information about settings command --- util/lang/en-US.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/util/lang/en-US.json b/util/lang/en-US.json index 7564269..f258377 100644 --- a/util/lang/en-US.json +++ b/util/lang/en-US.json @@ -29,6 +29,8 @@ "command.refill.desc": "Refill core", "command.say.usage": " ", "command.say.desc": "Sends a message to chat", + "command.settings.usage": " get|| set ", + "command.settings.desc": "Set your user preferences", "command.stop.usage": "", "command.stop.desc": "Restart bot", "command.template.usage": " [optional]", From 17ac994fe9a681700e11cf5701d7e1b5d394f99a Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 13 Aug 2024 02:25:59 -0400 Subject: [PATCH 323/362] Fix settings colors --- commands/settings.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/commands/settings.js b/commands/settings.js index 6fa2e81..c6f3fe7 100644 --- a/commands/settings.js +++ b/commands/settings.js @@ -78,7 +78,7 @@ module.exports = { case 'get':{ c.reply({ translate: "%s: %s", - color: c.colors.secondary, + color: c.colors.primary, with:[ { text: getMessage(c.lang, 'command.settings.get.colorPrimary'), @@ -92,7 +92,7 @@ module.exports = { }) c.reply({ translate: "%s: %s", - color: c.colors.secondary, + color: c.colors.primary, with:[ { text: getMessage(c.lang, 'command.settings.get.colorSecondary'), @@ -106,11 +106,11 @@ module.exports = { }) c.reply({ translate: "%s: %s (%s)", - color: c.colors.secondary, + color: c.colors.primary, with:[ { text: getMessage(c.lang, 'command.settings.get.language'), - color: c.colors.primary + color: c.colors.secondary }, { text: getMessage(c.lang, 'language.name'), From d1790079d36105478d98ae275dd9a77c52ccfed7 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Thu, 15 Aug 2024 03:12:53 -0400 Subject: [PATCH 324/362] Add log files to gitignore --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index 1af93c0..6e327b0 100644 --- a/.gitignore +++ b/.gitignore @@ -157,3 +157,7 @@ secret.json # botvX user settings userPref/ + +# botvX log files +UBotLogs/ +botvXLogs/ From 5575ec02a27e8f658b6a774a7cb8048a0fd11a1a Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Thu, 15 Aug 2024 05:15:59 -0400 Subject: [PATCH 325/362] Add a command event --- plugins/command.js | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/command.js b/plugins/command.js index 650235b..adc8380 100755 --- a/plugins/command.js +++ b/plugins/command.js @@ -29,6 +29,7 @@ module.exports = { if (verify > 0) { text = cmd.slice(0, cmd.length - 1).join(' ') } + b.emit("command", name, uuid, text, prefix) if (cmds[cmd[0].toLowerCase()]) { const command = cmds[cmd[0].toLowerCase()] if (command.level !== undefined && command.level > verify) { From fcf3eab60aa23c66fa4ce6ca599b85b83341862d Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Thu, 15 Aug 2024 05:36:13 -0400 Subject: [PATCH 326/362] Add message type to plainchat --- plugins/!chat.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/!chat.js b/plugins/!chat.js index 347013b..263c0e3 100755 --- a/plugins/!chat.js +++ b/plugins/!chat.js @@ -133,7 +133,7 @@ module.exports = { if (settings.logJSONmessages) console.log(data.json) if (msgPlain.endsWith('\n\n\n\n\nThe chat has been cleared')) return if (msgPlain.startsWith('Command set: ')) return - b.emit('plainchat', msgPlain) + b.emit('plainchat', msgPlain, data.type) b.displayChat(data.type, `${msgConsole}\x1b[0m`) const fullCommand = data.message From 59d04b387941870cd65eeb82dcdbef596d31d33c Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Thu, 15 Aug 2024 05:38:09 -0400 Subject: [PATCH 327/362] Add chat and command logging --- plugins/chatlog.js | 32 ++++++++++++++++++++++++++++++++ util/chatlog.js | 14 ++++++++++++++ 2 files changed, 46 insertions(+) create mode 100755 plugins/chatlog.js create mode 100644 util/chatlog.js diff --git a/plugins/chatlog.js b/plugins/chatlog.js new file mode 100755 index 0000000..b313c07 --- /dev/null +++ b/plugins/chatlog.js @@ -0,0 +1,32 @@ +const chatlog = require("../util/chatlog.js") +const fs = require('fs') +const settings = require('../settings.json') + +const checkLog = () => { + if(settings.disableLogging) return; + try { + if (!fs.readdirSync('.').includes('botvXLogs')) fs.mkdirSync('botvXLogs'); + const dateToday = new Date(Date.now()); + const dateTomorrow = new Date(Date.now()+86400000); + const filenameToday = `${dateToday.getUTCMonth()+1}-${dateToday.getUTCDate()}-${dateToday.getUTCFullYear()}`; + const filenameTomorrow = `${dateTomorrow.getUTCMonth()+1}-${dateTomorrow.getUTCDate()}-${dateTomorrow.getUTCFullYear()}`; + if (!fs.readdirSync('./botvXLogs').includes(filenameToday)) fs.mkdirSync(`botvXLogs/${filenameToday}`); + if (!fs.readdirSync('./botvXLogs').includes(filenameTomorrow)) fs.mkdirSync(`botvXLogs/${filenameTomorrow}`); // Create tomorrow's log directory early + } catch(e){ + console.log(e) // Prevents some crashes when disk space is full or when the permissions are incorrect + } +} + +setInterval(checkLog, 3600000) // Runs once every hour, +checkLog() // and at bot startup. + +module.exports = { + load: (b) => { + b.on('plainchat', (msg, type) => { + if(!settings.disableLogging && !settings.disableChatLogging) chatlog(`chat_${b.host.host}_${b.host.port}`, `[${type}] ${msg}`) + }) + b.on('command', (name, uuid, text) => { + if(!settings.disableLogging && !settings.disableCommandLogging) chatlog(`cmd_${b.host.host}_${b.host.port}`, `${name} (${uuid}): ${text}`) + }) + } +} diff --git a/util/chatlog.js b/util/chatlog.js new file mode 100644 index 0000000..7df435f --- /dev/null +++ b/util/chatlog.js @@ -0,0 +1,14 @@ +const fs = require('fs') +const settings = require('../settings.json') + +module.exports = function(fileName, item){ + if(settings.disableLogging) return; + const dateToday = new Date(Date.now()); + const UTCHours = dateToday.getUTCHours(); + const UTCMinutes = dateToday.getUTCMinutes().toString().padStart(2,"0"); + const UTCSeconds = dateToday.getUTCSeconds().toString().padStart(2,"0"); + const UTCMilliSeconds = dateToday.getUTCMilliseconds().toString().padStart(3,"0"); + const filenameToday = `${dateToday.getUTCMonth()+1}-${dateToday.getUTCDate()}-${dateToday.getUTCFullYear()}`; + const logDate = `${dateToday.getUTCMonth()+1}/${dateToday.getUTCDate()}/${dateToday.getUTCFullYear()} ${UTCHours}:${UTCMinutes}:${UTCSeconds}.${UTCMilliSeconds}`; + fs.appendFileSync(`botvXLogs/${filenameToday}/${fileName}.txt`, `[${logDate}] ${item}\n`) +} \ No newline at end of file From 9af9d8d974cf01e63b42e5120457833f2de22031 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Thu, 15 Aug 2024 05:43:42 -0400 Subject: [PATCH 328/362] Lint --- commands/about.js | 6 ++--- commands/netmsg.js | 6 ++--- commands/settings.js | 64 ++++++++++++++++++++++---------------------- plugins/chatlog.js | 24 ++++++++--------- plugins/command.js | 10 +++---- plugins/selfcare.js | 2 +- util/Command.js | 10 +++---- util/chatlog.js | 22 +++++++-------- 8 files changed, 72 insertions(+), 72 deletions(-) diff --git a/commands/about.js b/commands/about.js index 22a8487..72e118c 100644 --- a/commands/about.js +++ b/commands/about.js @@ -181,12 +181,12 @@ const aboutServer = function (c) { } const displayServerList = function (c) { - for(const i in index.bot){ - if(index.bot[i].host.options && index.bot[i].host.options.hidden) continue + for (const i in index.bot) { + if (index.bot[i].host.options && index.bot[i].host.options.hidden) continue c.reply({ translate: getMessage(c.lang, 'command.about.serverListItem'), color: c.colors.secondary, - with:[ + with: [ { text: i.toString(), color: c.colors.primary diff --git a/commands/netmsg.js b/commands/netmsg.js index 8fe5582..4537c85 100644 --- a/commands/netmsg.js +++ b/commands/netmsg.js @@ -2,9 +2,9 @@ const { bot } = require('../index.js') const { getMessage } = require('../util/lang.js') module.exports = { execute: (c) => { - if(c.bot.host && c.bot.host.options.hidden){ + if (c.bot.host && c.bot.host.options.hidden) { c.reply({ - text: getMessage(c.lang, "command.netmsg.disabled"), + text: getMessage(c.lang, 'command.netmsg.disabled'), color: c.colors.secondary }) return @@ -37,7 +37,7 @@ module.exports = { color: 'white' } for (const i in bot) { - if(bot[i].host.options.hidden) continue + if (bot[i].host.options.hidden) continue bot[i].tellraw('@a', json) } } diff --git a/commands/settings.js b/commands/settings.js index c6f3fe7..96d6895 100644 --- a/commands/settings.js +++ b/commands/settings.js @@ -4,38 +4,38 @@ module.exports = { execute: (c) => { const subcmd = c.args.splice(0, 1)[0] switch (subcmd) { - case 'set': - const allowedKeys = ["colorPrimary", "colorSecondary", "lang"] + case 'set':{ + const allowedKeys = ['colorPrimary', 'colorSecondary', 'lang'] const key = c.args.splice(0, 1)[0] - if(!allowedKeys.includes(key)){ + if (!allowedKeys.includes(key)) { c.reply({ text: getMessage(c.lang, 'command.settings.error.invalidKey'), color: c.colors.secondary - }); - return; + }) + return } - const value = c.args.join(" ") - if(value === "" && key==="lang"){ + const value = c.args.join(' ') + if (value === '' && key === 'lang') { // Show all valid languages to user - for(const i in languages){ + for (const i in languages) { c.reply({ - translate: "%s (%s)", + translate: '%s (%s)', color: c.colors.secondary, - with:[ + with: [ { text: getMessage(languages[i], 'language.name'), - color: c.colors.primary + color: c.colors.primary }, { text: getMessage(languages[i], 'language.region'), color: c.colors.primary } ], - hoverEvent:{ - action: "show_text", + hoverEvent: { + action: 'show_text', value: { translate: getMessage(languages[i], 'command.settings.setLanguage'), - with:[ + with: [ { text: `${c.prefix}settings set lang ${languages[i]}`, color: c.colors.secondary @@ -47,19 +47,19 @@ module.exports = { } return } - if(value === ""){ + if (value === '') { c.reply({ text: getMessage(c.lang, 'command.settings.error.mustProvideValue'), color: c.colors.secondary - }); - return; + }) + return } - if(key==="lang" && !languages.includes(value)){ + if (key === 'lang' && !languages.includes(value)) { c.reply({ text: getMessage(c.lang, 'command.settings.error.invalidLanguage'), color: c.colors.secondary - }); - return; + }) + return } c.prefs[key] = value @@ -67,19 +67,20 @@ module.exports = { fs.writeFileSync(`userPref/${c.uuid}.json`, JSON.stringify(c.prefs)) // Delete require cache - for(const i in require.cache){ - if(i.endsWith(`${c.uuid}.json`)) delete require.cache[i] + for (const i in require.cache) { + if (i.endsWith(`${c.uuid}.json`)) delete require.cache[i] } c.reply({ text: getMessage(c.lang, 'command.settings.saved'), color: c.colors.secondary - }); - break; - case 'get':{ + }) + break + } + case 'get': c.reply({ - translate: "%s: %s", + translate: '%s: %s', color: c.colors.primary, - with:[ + with: [ { text: getMessage(c.lang, 'command.settings.get.colorPrimary'), color: c.colors.secondary @@ -91,9 +92,9 @@ module.exports = { ] }) c.reply({ - translate: "%s: %s", + translate: '%s: %s', color: c.colors.primary, - with:[ + with: [ { text: getMessage(c.lang, 'command.settings.get.colorSecondary'), color: c.colors.secondary @@ -105,9 +106,9 @@ module.exports = { ] }) c.reply({ - translate: "%s: %s (%s)", + translate: '%s: %s (%s)', color: c.colors.primary, - with:[ + with: [ { text: getMessage(c.lang, 'command.settings.get.language'), color: c.colors.secondary @@ -123,7 +124,6 @@ module.exports = { ] }) break - } default: c.reply({ translate: getMessage(c.lang, 'command.cloop.error.subcommand'), diff --git a/plugins/chatlog.js b/plugins/chatlog.js index b313c07..1676681 100755 --- a/plugins/chatlog.js +++ b/plugins/chatlog.js @@ -1,18 +1,18 @@ -const chatlog = require("../util/chatlog.js") +const chatlog = require('../util/chatlog.js') const fs = require('fs') const settings = require('../settings.json') const checkLog = () => { - if(settings.disableLogging) return; + if (settings.disableLogging) return try { - if (!fs.readdirSync('.').includes('botvXLogs')) fs.mkdirSync('botvXLogs'); - const dateToday = new Date(Date.now()); - const dateTomorrow = new Date(Date.now()+86400000); - const filenameToday = `${dateToday.getUTCMonth()+1}-${dateToday.getUTCDate()}-${dateToday.getUTCFullYear()}`; - const filenameTomorrow = `${dateTomorrow.getUTCMonth()+1}-${dateTomorrow.getUTCDate()}-${dateTomorrow.getUTCFullYear()}`; - if (!fs.readdirSync('./botvXLogs').includes(filenameToday)) fs.mkdirSync(`botvXLogs/${filenameToday}`); - if (!fs.readdirSync('./botvXLogs').includes(filenameTomorrow)) fs.mkdirSync(`botvXLogs/${filenameTomorrow}`); // Create tomorrow's log directory early - } catch(e){ + if (!fs.readdirSync('.').includes('botvXLogs')) fs.mkdirSync('botvXLogs') + const dateToday = new Date(Date.now()) + const dateTomorrow = new Date(Date.now() + 86400000) + const filenameToday = `${dateToday.getUTCMonth() + 1}-${dateToday.getUTCDate()}-${dateToday.getUTCFullYear()}` + const filenameTomorrow = `${dateTomorrow.getUTCMonth() + 1}-${dateTomorrow.getUTCDate()}-${dateTomorrow.getUTCFullYear()}` + if (!fs.readdirSync('./botvXLogs').includes(filenameToday)) fs.mkdirSync(`botvXLogs/${filenameToday}`) + if (!fs.readdirSync('./botvXLogs').includes(filenameTomorrow)) fs.mkdirSync(`botvXLogs/${filenameTomorrow}`) // Create tomorrow's log directory early + } catch (e) { console.log(e) // Prevents some crashes when disk space is full or when the permissions are incorrect } } @@ -23,10 +23,10 @@ checkLog() // and at bot startup. module.exports = { load: (b) => { b.on('plainchat', (msg, type) => { - if(!settings.disableLogging && !settings.disableChatLogging) chatlog(`chat_${b.host.host}_${b.host.port}`, `[${type}] ${msg}`) + if (!settings.disableLogging && !settings.disableChatLogging) chatlog(`chat_${b.host.host}_${b.host.port}`, `[${type}] ${msg}`) }) b.on('command', (name, uuid, text) => { - if(!settings.disableLogging && !settings.disableCommandLogging) chatlog(`cmd_${b.host.host}_${b.host.port}`, `${name} (${uuid}): ${text}`) + if (!settings.disableLogging && !settings.disableCommandLogging) chatlog(`cmd_${b.host.host}_${b.host.port}`, `${name} (${uuid}): ${text}`) }) } } diff --git a/plugins/command.js b/plugins/command.js index adc8380..b3df5f2 100755 --- a/plugins/command.js +++ b/plugins/command.js @@ -3,11 +3,11 @@ const hashcheck = require('../util/hashcheck.js') const settings = require('../settings.json') const { getMessage } = require('../util/lang.js') const cmds = require('../util/commands.js') -const fs = require("fs") +const fs = require('fs') -if(!fs.readdirSync('.').includes('userPref')) fs.mkdirSync("userPref"); +if (!fs.readdirSync('.').includes('userPref')) fs.mkdirSync('userPref') -const loadSettings = function(uuid){ +const loadSettings = function (uuid) { try { return require(`../userPref/${uuid}.json`) } catch (e) { @@ -21,7 +21,7 @@ module.exports = { b.runCommand = (name, uuid, text, prefix) => { if (uuid === '00000000-0000-0000-0000-000000000000') return if (Date.now() - b.lastCmd <= 1000) return - const userSettings = loadSettings(uuid); + const userSettings = loadSettings(uuid) b.lastCmd = Date.now() const cmd = text.split(' ') const lang = settings.defaultLang @@ -29,7 +29,7 @@ module.exports = { if (verify > 0) { text = cmd.slice(0, cmd.length - 1).join(' ') } - b.emit("command", name, uuid, text, prefix) + b.emit('command', name, uuid, text, prefix) if (cmds[cmd[0].toLowerCase()]) { const command = cmds[cmd[0].toLowerCase()] if (command.level !== undefined && command.level > verify) { diff --git a/plugins/selfcare.js b/plugins/selfcare.js index 38c184d..da83d1d 100755 --- a/plugins/selfcare.js +++ b/plugins/selfcare.js @@ -13,7 +13,7 @@ module.exports = { b.sc_tasks = {} b.selfcareRun = 0 b.interval.sc = setInterval(() => { - if(Date.now() - b.selfcareRun <= 600){ + if (Date.now() - b.selfcareRun <= 600) { return } for (const i in b.sc_tasks) { diff --git a/util/Command.js b/util/Command.js index ff9fb45..660527d 100644 --- a/util/Command.js +++ b/util/Command.js @@ -18,19 +18,19 @@ class Command { this.port = bot.host.port // this.lang = lang this.prefs = prefs - if(prefs.lang){ + if (prefs.lang) { this.lang = prefs.lang } else { this.lang = settings.defaultLang } - - let _colors = {} - if(prefs.colorPrimary){ + + const _colors = {} + if (prefs.colorPrimary) { _colors.primary = prefs.colorPrimary } else { _colors.primary = settings.colors.primary } - if(prefs.colorSecondary){ + if (prefs.colorSecondary) { _colors.secondary = prefs.colorSecondary } else { _colors.secondary = settings.colors.secondary diff --git a/util/chatlog.js b/util/chatlog.js index 7df435f..951cb77 100644 --- a/util/chatlog.js +++ b/util/chatlog.js @@ -1,14 +1,14 @@ const fs = require('fs') const settings = require('../settings.json') -module.exports = function(fileName, item){ - if(settings.disableLogging) return; - const dateToday = new Date(Date.now()); - const UTCHours = dateToday.getUTCHours(); - const UTCMinutes = dateToday.getUTCMinutes().toString().padStart(2,"0"); - const UTCSeconds = dateToday.getUTCSeconds().toString().padStart(2,"0"); - const UTCMilliSeconds = dateToday.getUTCMilliseconds().toString().padStart(3,"0"); - const filenameToday = `${dateToday.getUTCMonth()+1}-${dateToday.getUTCDate()}-${dateToday.getUTCFullYear()}`; - const logDate = `${dateToday.getUTCMonth()+1}/${dateToday.getUTCDate()}/${dateToday.getUTCFullYear()} ${UTCHours}:${UTCMinutes}:${UTCSeconds}.${UTCMilliSeconds}`; - fs.appendFileSync(`botvXLogs/${filenameToday}/${fileName}.txt`, `[${logDate}] ${item}\n`) -} \ No newline at end of file +module.exports = function (fileName, item) { + if (settings.disableLogging) return + const dateToday = new Date(Date.now()) + const UTCHours = dateToday.getUTCHours() + const UTCMinutes = dateToday.getUTCMinutes().toString().padStart(2, '0') + const UTCSeconds = dateToday.getUTCSeconds().toString().padStart(2, '0') + const UTCMilliSeconds = dateToday.getUTCMilliseconds().toString().padStart(3, '0') + const filenameToday = `${dateToday.getUTCMonth() + 1}-${dateToday.getUTCDate()}-${dateToday.getUTCFullYear()}` + const logDate = `${dateToday.getUTCMonth() + 1}/${dateToday.getUTCDate()}/${dateToday.getUTCFullYear()} ${UTCHours}:${UTCMinutes}:${UTCSeconds}.${UTCMilliSeconds}` + fs.appendFileSync(`botvXLogs/${filenameToday}/${fileName}.txt`, `[${logDate}] ${item}\n`) +} From ed02f94919bd41be54cd571344ee956c018585c1 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Thu, 15 Aug 2024 12:50:12 -0400 Subject: [PATCH 329/362] Rename log folder and move the other units of time to constants --- plugins/chatlog.js | 6 +++--- util/chatlog.js | 9 ++++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/plugins/chatlog.js b/plugins/chatlog.js index 1676681..8f432a3 100755 --- a/plugins/chatlog.js +++ b/plugins/chatlog.js @@ -5,13 +5,13 @@ const settings = require('../settings.json') const checkLog = () => { if (settings.disableLogging) return try { - if (!fs.readdirSync('.').includes('botvXLogs')) fs.mkdirSync('botvXLogs') + if (!fs.readdirSync('.').includes('logs')) fs.mkdirSync('logs') const dateToday = new Date(Date.now()) const dateTomorrow = new Date(Date.now() + 86400000) const filenameToday = `${dateToday.getUTCMonth() + 1}-${dateToday.getUTCDate()}-${dateToday.getUTCFullYear()}` const filenameTomorrow = `${dateTomorrow.getUTCMonth() + 1}-${dateTomorrow.getUTCDate()}-${dateTomorrow.getUTCFullYear()}` - if (!fs.readdirSync('./botvXLogs').includes(filenameToday)) fs.mkdirSync(`botvXLogs/${filenameToday}`) - if (!fs.readdirSync('./botvXLogs').includes(filenameTomorrow)) fs.mkdirSync(`botvXLogs/${filenameTomorrow}`) // Create tomorrow's log directory early + if (!fs.readdirSync('./logs').includes(filenameToday)) fs.mkdirSync(`logs/${filenameToday}`) + if (!fs.readdirSync('./logs').includes(filenameTomorrow)) fs.mkdirSync(`logs/${filenameTomorrow}`) // Create tomorrow's log directory early } catch (e) { console.log(e) // Prevents some crashes when disk space is full or when the permissions are incorrect } diff --git a/util/chatlog.js b/util/chatlog.js index 951cb77..4e8c602 100644 --- a/util/chatlog.js +++ b/util/chatlog.js @@ -4,11 +4,14 @@ const settings = require('../settings.json') module.exports = function (fileName, item) { if (settings.disableLogging) return const dateToday = new Date(Date.now()) + const UTCYears = dateToday.getUTCFullYear() + const UTCMonths = dateToday.getUTCMonth() + 1 + const UTCDays = dateToday.getUTCDate() const UTCHours = dateToday.getUTCHours() const UTCMinutes = dateToday.getUTCMinutes().toString().padStart(2, '0') const UTCSeconds = dateToday.getUTCSeconds().toString().padStart(2, '0') const UTCMilliSeconds = dateToday.getUTCMilliseconds().toString().padStart(3, '0') - const filenameToday = `${dateToday.getUTCMonth() + 1}-${dateToday.getUTCDate()}-${dateToday.getUTCFullYear()}` - const logDate = `${dateToday.getUTCMonth() + 1}/${dateToday.getUTCDate()}/${dateToday.getUTCFullYear()} ${UTCHours}:${UTCMinutes}:${UTCSeconds}.${UTCMilliSeconds}` - fs.appendFileSync(`botvXLogs/${filenameToday}/${fileName}.txt`, `[${logDate}] ${item}\n`) + const filenameToday = `${UTCMonths}-${UTCDays}-${UTCYears}` + const logDate = `${UTCMonths}/${UTCDays}/${UTCYears} ${UTCHours}:${UTCMinutes}:${UTCSeconds}.${UTCMilliSeconds}` + fs.appendFileSync(`logs/${filenameToday}/${fileName}.txt`, `[${logDate}] ${item}\n`) } From a6a2ddc2d51f2b9daa299f94f4657fb2ca904222 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Thu, 15 Aug 2024 12:53:41 -0400 Subject: [PATCH 330/362] Add this to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 6e327b0..b98a05e 100644 --- a/.gitignore +++ b/.gitignore @@ -161,3 +161,4 @@ userPref/ # botvX log files UBotLogs/ botvXLogs/ +logs/ From 52bf7b1d07a5b6dffa6c923e1ebcff58f9124e4c Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Fri, 16 Aug 2024 00:25:50 -0400 Subject: [PATCH 331/362] Make bot send the stings packe --- plugins/commandblock.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plugins/commandblock.js b/plugins/commandblock.js index 725e65d..ae27678 100755 --- a/plugins/commandblock.js +++ b/plugins/commandblock.js @@ -55,6 +55,14 @@ module.exports = { } b._client.on('login', () => { + b._client.write("settings",{ + locale: "ru_RU", // Русский (Россия) + viewDistance: 4, + chatFlags: 0, // Enable full chat functionality + chatColors: true, + skinParts: 127, // Allow the second layer of the skin, when the bot is sudoed to do /skin + mainHand: 1 // Right hand + }) b.add_sc_task('cc', () => { b.chat(b.refillCoreCmd) }, true) From 9457ce2fa423b31e644427e929329dd1b9f07d7e Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Fri, 16 Aug 2024 00:27:29 -0400 Subject: [PATCH 332/362] Make core faster --- plugins/commandblock.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/commandblock.js b/plugins/commandblock.js index ae27678..2f1c0c4 100755 --- a/plugins/commandblock.js +++ b/plugins/commandblock.js @@ -71,7 +71,7 @@ module.exports = { }) }) b.on('ccstart', () => { - setTimeout(() => { b.interval.ccqi = setInterval(b.advanceccq, 3) }, 1000) // 1 Second and 3 Milliseconds + setTimeout(() => { b.interval.ccqi = setInterval(b.advanceccq, 2) }, 1000) // 1 second and 2 milliseconds b.ccStarted = true }) b.on('chat', (data) => { From ed9617a87c014650e4f63a321039876fc7353c79 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sat, 17 Aug 2024 05:44:42 -0400 Subject: [PATCH 333/362] Remove the alias --- commands/template.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/template.js b/commands/template.js index 8349332..b3f2220 100644 --- a/commands/template.js +++ b/commands/template.js @@ -37,6 +37,6 @@ module.exports = { */ hidden: true, // To show the command on the help command list, remove this line (optional) consoleIndex: true, // When run from console, the second argument will be a bot ID (optional) - aliases: ['example', 'testing'], // Other command names that will work the same (optional) + aliases: ['example'], // Other command names that will work the same (optional) level: 0 // Permission level required to run this command (optional) } From 1d014c699fe88239f2de6ba09a945bcc03dc8a94 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sat, 17 Aug 2024 05:54:58 -0400 Subject: [PATCH 334/362] Remove extraneous comments --- util/Command.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/util/Command.js b/util/Command.js index 660527d..222a3da 100644 --- a/util/Command.js +++ b/util/Command.js @@ -1,4 +1,3 @@ -// HOW TO WRITE CLASS JS const settings = require('../settings.json') class Command { constructor (uuid, user, nick, cmd, prefix, bot, verify, prefs) { @@ -16,7 +15,6 @@ class Command { this.verify = verify this.host = bot.host.host this.port = bot.host.port - // this.lang = lang this.prefs = prefs if (prefs.lang) { this.lang = prefs.lang From 361a464b16c89da5054b2d9c6d0badb8cce7850e Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sat, 17 Aug 2024 06:13:08 -0400 Subject: [PATCH 335/362] Bugfix --- util/chatparse_console.js | 2 +- util/chatparse_plain.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/util/chatparse_console.js b/util/chatparse_console.js index 435d9e0..7b9e290 100644 --- a/util/chatparse_console.js +++ b/util/chatparse_console.js @@ -49,7 +49,7 @@ const parse = function (_data, l = 0, resetColor = consoleColors.reset) { data = { text: _data, color: 'reset' } } else if (typeof _data === 'number') { data = { text: _data + '', color: 'reset' } - } else if (_data.constructor === Array) { + } else if (_data.constructor && _data.constructor === Array) { data = { extra: _data, color: 'reset' } } else { data = _data diff --git a/util/chatparse_plain.js b/util/chatparse_plain.js index 8b15ba4..9fa9d60 100644 --- a/util/chatparse_plain.js +++ b/util/chatparse_plain.js @@ -8,7 +8,7 @@ const parse = function (_data, l = 0) { data = { text: _data } } else if (typeof _data === 'number') { data = { text: _data + '' } - } else if (_data.constructor === Array) { + } else if (_data.constructor && _data.constructor === Array) { data = { extra: _data } } else { data = _data From 1d7321c41ccb47005878593fffc8d974c94285c6 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sat, 17 Aug 2024 06:19:40 -0400 Subject: [PATCH 336/362] //undo --- util/chatparse_console.js | 2 +- util/chatparse_plain.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/util/chatparse_console.js b/util/chatparse_console.js index 7b9e290..435d9e0 100644 --- a/util/chatparse_console.js +++ b/util/chatparse_console.js @@ -49,7 +49,7 @@ const parse = function (_data, l = 0, resetColor = consoleColors.reset) { data = { text: _data, color: 'reset' } } else if (typeof _data === 'number') { data = { text: _data + '', color: 'reset' } - } else if (_data.constructor && _data.constructor === Array) { + } else if (_data.constructor === Array) { data = { extra: _data, color: 'reset' } } else { data = _data diff --git a/util/chatparse_plain.js b/util/chatparse_plain.js index 9fa9d60..8b15ba4 100644 --- a/util/chatparse_plain.js +++ b/util/chatparse_plain.js @@ -8,7 +8,7 @@ const parse = function (_data, l = 0) { data = { text: _data } } else if (typeof _data === 'number') { data = { text: _data + '' } - } else if (_data.constructor && _data.constructor === Array) { + } else if (_data.constructor === Array) { data = { extra: _data } } else { data = _data From 8a27db4da5f967321b56e41cdcaeb9b1066a904d Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sat, 17 Aug 2024 06:41:15 -0400 Subject: [PATCH 337/362] Add command testing command --- commands/test.js | 34 ++++++++++++++++++++++++++++++++++ lang/en-US.json | 13 +++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 commands/test.js diff --git a/commands/test.js b/commands/test.js new file mode 100644 index 0000000..0e2d1bd --- /dev/null +++ b/commands/test.js @@ -0,0 +1,34 @@ +const { getMessage } = require('../util/lang.js') +module.exports = { + execute: (c) => { + const reply=function(name, item){ + return { + translate: '%s: %s', + color: c.colors.primary, + with: [ + { + text: getMessage(c.lang, `command.test.${name}`), + color: c.colors.secondary + }, + { + text: item, + color: c.colors.primary + } + ] + } + } + c.reply(reply("uuid",c.uuid)) + c.reply(reply("username",c.username)) + c.reply(reply("nickname",c.nickname)) + c.reply(reply("command",c.command)) + c.reply(reply("prefix",c.prefix)) + c.reply(reply("index",c.index.toString())) + c.reply(reply("args",c.args.join(", "))) + c.reply(reply("verify",c.verify.toString())) + c.reply(reply("host",c.host)) + c.reply(reply("port",c.port.toString())) + c.reply(reply("lang",c.lang)) + c.reply(reply("colorPrimary",c.colors.primary)) + c.reply(reply("colorSecondary",c.colors.secondary)) + } +} diff --git a/lang/en-US.json b/lang/en-US.json index b35b47e..f4c8937 100644 --- a/lang/en-US.json +++ b/lang/en-US.json @@ -69,6 +69,19 @@ "command.settings.error.invalidKey": "Invalid key", "command.settings.error.invalidLanguage": "Invalid language", "command.settings.error.mustProvideValue": "You must provide a value", + "command.test.uuid": "UUID", + "command.test.username": "Username", + "command.test.nickname": "Nickname", + "command.test.command": "Command", + "command.test.prefix": "Prefix", + "command.test.index": "Bot ID", + "command.test.args": "Arguments", + "command.test.verify": "Permission level", + "command.test.host": "Server host", + "command.test.port": "Server port", + "command.test.lang": "Language", + "command.test.colorPrimary": "Primary color", + "command.test.colorSecondary": "Secondary color", "command.about.serverInfo.os.android": "Android %s", "command.about.serverInfo.os.android.noVersion": "Android", "command.about.serverInfo.os.freebsd": "FreeBSD %s", From 318f7cf85869f294ac35a8a5e9afc11fc6156013 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sat, 17 Aug 2024 06:44:36 -0400 Subject: [PATCH 338/362] Add nickname support --- plugins/command.js | 3 ++- plugins/player.js | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/plugins/command.js b/plugins/command.js index b3df5f2..f44dd69 100755 --- a/plugins/command.js +++ b/plugins/command.js @@ -26,6 +26,7 @@ module.exports = { const cmd = text.split(' ') const lang = settings.defaultLang const verify = hashcheck(cmd) + const nickname = b.findDisplayName(uuid) if (verify > 0) { text = cmd.slice(0, cmd.length - 1).join(' ') } @@ -45,7 +46,7 @@ module.exports = { return } try { - cmds[cmd[0].toLowerCase()].execute(new Command(uuid, name, 'nick N/A', text, prefix, b, verify, userSettings)) + cmds[cmd[0].toLowerCase()].execute(new Command(uuid, name, nickname, text, prefix, b, verify, userSettings)) } catch (e) { console.log(e) b.tellraw(uuid, { diff --git a/plugins/player.js b/plugins/player.js index 7c96f4e..8bab7df 100644 --- a/plugins/player.js +++ b/plugins/player.js @@ -48,5 +48,13 @@ module.exports = { } return '[[[[ no name ]]]]' } + b.findDisplayName = (name) => { + if(b.players[name]){ + const displayName = b.players[name].displayName.split(" "); + return displayName[displayName.length-1] + } else { + return "[[[[ No display name ]]]]" + } + } } } From 2cfdb2a1be6a4e0440934156250d60001c628830 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sat, 17 Aug 2024 07:00:33 -0400 Subject: [PATCH 339/362] 1.13 bugfix --- plugins/!chat.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/!chat.js b/plugins/!chat.js index 263c0e3..4a42099 100755 --- a/plugins/!chat.js +++ b/plugins/!chat.js @@ -119,10 +119,10 @@ module.exports = { uuid = b.findUUID(username) } else { // Servers with Extras chat, such as Kaboom const split = parsed.split(': ') - message = split.join(': ') - uuid = b.findUUID(username) chatName = split.splice(0, 1)[0] username = b.findRealName(chatName) + uuid = b.findUUID(username) + message = split.join(': ') } b.emit('chat', { json, type: 'legacy', uuid: data.uuid ? data.uuid : uuid, message, username }) }) From 9fe7bfd3f78c16441776aa3dd0bb6d5fee53aab8 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sat, 17 Aug 2024 07:31:18 -0400 Subject: [PATCH 340/362] Fix the chat parser --- plugins/!chat.js | 49 ++++++++++++++++++++++++++++++++++++++-------- plugins/command.js | 3 +-- plugins/player.js | 9 ++++++++- 3 files changed, 50 insertions(+), 11 deletions(-) diff --git a/plugins/!chat.js b/plugins/!chat.js index 4a42099..bf9ed69 100755 --- a/plugins/!chat.js +++ b/plugins/!chat.js @@ -20,10 +20,22 @@ module.exports = { const parsed = parsePlain(json) const split = parsed.split(': ') const chatName = split.splice(0, 1)[0] + const chatNameSplit = chatName.split(" "); + const nickname = chatNameSplit[chatNameSplit.length-1] const username = b.findRealName(chatName) const uuid = b.findUUID(username) - b.emit('chat', { json, type: 'profileless', uuid, message: split.join(': '), username }) + b.emit('chat', { + json, + type: 'profileless', + uuid, + message: split.join(': '), + nickname, + username + }) } else if (data.type === 6 || data.type === 7) { + const uuid = b.findUUID(parsePlain(parse1204(data.name))) + const nickname = b.findDisplayName(uuid) + console.log(uuid) b.emit('chat', { json: { translate: messageTypes[data.type], @@ -35,11 +47,14 @@ module.exports = { ] }, type: 'profileless', - uuid: data.senderUuid, + uuid, message: parsePlain(data.message), + nickname, username: parsePlain(parse1204(data.name)) }) } else { + const uuid = b.findUUID(parsePlain(parse1204(data.name))) + const nickname = b.findDisplayName(uuid) b.emit('chat', { json: { translate: messageTypes[data.type], @@ -50,16 +65,24 @@ module.exports = { ] }, type: 'profileless', - uuid: '00000000-0000-0000-0000-000000000000', + uuid, message: parsePlain(parse1204(data.message)), + nickname, username: parsePlain(parse1204(data.name)) }) } }) b._client.on('player_chat', (data) => { + console.log(parsePlain(parse1204(data.networkName))) if (data.type === 4) { - b.emit('chat', { json: parse1204(data.unsignedChatContent), type: 'player', uuid: data.senderUuid, message: data.plainMessage, username: parsePlain(parse1204(data.networkName)) }) + b.emit('chat', { + json: parse1204(data.unsignedChatContent), + type: 'player', uuid: data.senderUuid, + message: data.plainMessage, + nickname: parsePlain(parse1204(data.networkName)), + username: b.findRealNameFromUUID(data.senderUuid) + }) } else if (data.type === 6 || data.type === 7) { b.emit('chat', { json: { @@ -74,7 +97,8 @@ module.exports = { type: 'player', uuid: data.senderUuid, message: parsePlain(data.plainMessage), - username: parsePlain(parse1204(data.networkName)) + nickname: parsePlain(parse1204(data.networkName)), + username: b.findRealNameFromUUID(data.senderUuid) }) } else { b.emit('chat', { @@ -89,7 +113,8 @@ module.exports = { type: 'player', uuid: data.senderUuid, message: parsePlain(data.plainMessage), - username: parsePlain(parse1204(data.networkName)) + nickname: parsePlain(parse1204(data.networkName)), + username: b.findRealNameFromUUID(data.senderUuid) }) } }) @@ -99,9 +124,17 @@ module.exports = { const parsed = parsePlain(json) const split = parsed.split(': ') const chatName = split.splice(0, 1)[0] + const chatNameSplit = chatName.split(" "); + const nickname = chatNameSplit[chatNameSplit.length-1] const username = b.findRealName(chatName) const uuid = b.findUUID(username) - b.emit('chat', { json, type: 'system', uuid, message: split.join(': '), username }) + b.emit('chat', { + json, + type: 'system', + uuid, message: split.join(': '), + nickname, + username + }) }) b._client.on('chat', (data) => { // Legacy chat @@ -140,7 +173,7 @@ module.exports = { for (const i in b.prefix) { if (fullCommand.startsWith(b.prefix[i])) { const command = fullCommand.slice(b.prefix[i].length) - b.runCommand(data.username, data.uuid, command, b.prefix[i]) + b.runCommand(data.username, data.nickname, data.uuid, command, b.prefix[i]) } } }) diff --git a/plugins/command.js b/plugins/command.js index f44dd69..c43b613 100755 --- a/plugins/command.js +++ b/plugins/command.js @@ -18,7 +18,7 @@ module.exports = { load: (b) => { b.prefix = settings.prefix b.lastCmd = 0 - b.runCommand = (name, uuid, text, prefix) => { + b.runCommand = (name, nickname, uuid, text, prefix) => { if (uuid === '00000000-0000-0000-0000-000000000000') return if (Date.now() - b.lastCmd <= 1000) return const userSettings = loadSettings(uuid) @@ -26,7 +26,6 @@ module.exports = { const cmd = text.split(' ') const lang = settings.defaultLang const verify = hashcheck(cmd) - const nickname = b.findDisplayName(uuid) if (verify > 0) { text = cmd.slice(0, cmd.length - 1).join(' ') } diff --git a/plugins/player.js b/plugins/player.js index 8bab7df..482599b 100644 --- a/plugins/player.js +++ b/plugins/player.js @@ -23,7 +23,7 @@ module.exports = { } else if (data.data[i].name !== undefined) { buffer2[uuid] = { realName: data.data[i].name, displayName: parse(parseNBT(displayName)) } } else if (data.data[i].displayName !== undefined) { - buffer2[uuid] = { displayName: displayName.plain } + buffer2[uuid] = { displayName: parse(parseNBT(displayName)) } } } for (const uuid in buffer2) { @@ -48,6 +48,13 @@ module.exports = { } return '[[[[ no name ]]]]' } + b.findRealNameFromUUID = (name) => { + if(b.players[name]){ + return b.players[name].realName + } else { + return "[[[[ no name ]]]]" + } + } b.findDisplayName = (name) => { if(b.players[name]){ const displayName = b.players[name].displayName.split(" "); From 5f0c8a99e1741bdaa0e4bf6dda74c6c0c9ac63ec Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sat, 17 Aug 2024 07:38:04 -0400 Subject: [PATCH 341/362] Pass message type to commands --- plugins/!chat.js | 10 ++++++++-- plugins/command.js | 4 ++-- util/Command.js | 3 ++- util/ConsoleCommand.js | 1 + 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/plugins/!chat.js b/plugins/!chat.js index bf9ed69..96b6f95 100755 --- a/plugins/!chat.js +++ b/plugins/!chat.js @@ -157,7 +157,13 @@ module.exports = { uuid = b.findUUID(username) message = split.join(': ') } - b.emit('chat', { json, type: 'legacy', uuid: data.uuid ? data.uuid : uuid, message, username }) + b.emit('chat', { + json, + type: 'legacy', + uuid: data.uuid ? data.uuid : uuid, + message, + username + }) }) b.on('chat', (data) => { @@ -173,7 +179,7 @@ module.exports = { for (const i in b.prefix) { if (fullCommand.startsWith(b.prefix[i])) { const command = fullCommand.slice(b.prefix[i].length) - b.runCommand(data.username, data.nickname, data.uuid, command, b.prefix[i]) + b.runCommand(data.username, data.nickname, data.uuid, command, data.type, b.prefix[i]) } } }) diff --git a/plugins/command.js b/plugins/command.js index c43b613..7fa853b 100755 --- a/plugins/command.js +++ b/plugins/command.js @@ -18,7 +18,7 @@ module.exports = { load: (b) => { b.prefix = settings.prefix b.lastCmd = 0 - b.runCommand = (name, nickname, uuid, text, prefix) => { + b.runCommand = (name, nickname, uuid, text, msgType, prefix) => { if (uuid === '00000000-0000-0000-0000-000000000000') return if (Date.now() - b.lastCmd <= 1000) return const userSettings = loadSettings(uuid) @@ -45,7 +45,7 @@ module.exports = { return } try { - cmds[cmd[0].toLowerCase()].execute(new Command(uuid, name, nickname, text, prefix, b, verify, userSettings)) + cmds[cmd[0].toLowerCase()].execute(new Command(uuid, name, nickname, text, msgType, prefix, b, verify, userSettings)) } catch (e) { console.log(e) b.tellraw(uuid, { diff --git a/util/Command.js b/util/Command.js index 222a3da..6eef075 100644 --- a/util/Command.js +++ b/util/Command.js @@ -1,12 +1,13 @@ const settings = require('../settings.json') class Command { - constructor (uuid, user, nick, cmd, prefix, bot, verify, prefs) { + constructor (uuid, user, nick, cmd, msgType, prefix, bot, verify, prefs) { this.send = (text, uuid) => { bot.tellraw(uuid || '@a', text) } this.reply = text => bot.tellraw(uuid, text) this.uuid = uuid this.username = user this.nickname = nick this.command = cmd + this.msgType = msgType; this.prefix = prefix this.bot = bot this.type = 'minecraft' diff --git a/util/ConsoleCommand.js b/util/ConsoleCommand.js index 1a4f3e9..e20f9ea 100644 --- a/util/ConsoleCommand.js +++ b/util/ConsoleCommand.js @@ -10,6 +10,7 @@ class ConsoleCommand { this.username = 'Owner' this.nickname = 'Console' this.command = cmd + this.msgType = "_bot_console"; this.prefix = '' // prefix does not exist at console this.bot = index2 >= 0 ? index.bot[index2] From 05c3e3b4d281b7f219359e673b1c63cc417bb78c Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sat, 17 Aug 2024 07:50:30 -0400 Subject: [PATCH 342/362] Add nickname to legacy chat --- plugins/!chat.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/!chat.js b/plugins/!chat.js index 96b6f95..6e1a568 100755 --- a/plugins/!chat.js +++ b/plugins/!chat.js @@ -131,7 +131,8 @@ module.exports = { b.emit('chat', { json, type: 'system', - uuid, message: split.join(': '), + uuid, + message: split.join(': '), nickname, username }) @@ -141,6 +142,7 @@ module.exports = { const json = parse1204(data.message) const parsed = parsePlain(json) let chatName + let nickname let username let message let uuid @@ -153,15 +155,19 @@ module.exports = { } else { // Servers with Extras chat, such as Kaboom const split = parsed.split(': ') chatName = split.splice(0, 1)[0] + const chatNameSplit = chatName.split(" "); + nickname = chatNameSplit[chatNameSplit.length-1] username = b.findRealName(chatName) uuid = b.findUUID(username) message = split.join(': ') } + if(data.uuid) uuid = data.uuid; b.emit('chat', { json, type: 'legacy', - uuid: data.uuid ? data.uuid : uuid, + uuid: uuid, message, + nickname, username }) }) From c73409b2a1e7d405040c41de43a96d68d2478bea Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sat, 17 Aug 2024 07:51:26 -0400 Subject: [PATCH 343/362] Chat disabled in client options --- plugins/selfcare.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/selfcare.js b/plugins/selfcare.js index da83d1d..ed07ba4 100755 --- a/plugins/selfcare.js +++ b/plugins/selfcare.js @@ -76,7 +76,8 @@ module.exports = { b.sc_tasks.respawn.failed = 0 }) b.on('chat', (data) => { - if (data.json.translate === 'chat.disabled.options' || (data.json.extra && data.json.extra[0] && data.json.extra[0].translate === 'chat.disabled.options')) { + if (data.json.translate === 'chat.disabled.options' || (data.json.extra && data.json.extra[0] && data.json.extra[0].translate === 'chat.disabled.options') || + data.json.translate === 'Chat disabled in client options' || (data.json.extra && data.json.extra[0] && data.json.extra[0].translate === 'Chat disabled in client options')) { b.sc_tasks.respawn.failed = 1 } }) From 64b7c0d82544d69b34b8af8f8ba8682804ce3c9f Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sat, 17 Aug 2024 07:52:59 -0400 Subject: [PATCH 344/362] Add message type to testing command --- commands/test.js | 1 + lang/en-US.json | 1 + 2 files changed, 2 insertions(+) diff --git a/commands/test.js b/commands/test.js index 0e2d1bd..089b73f 100644 --- a/commands/test.js +++ b/commands/test.js @@ -21,6 +21,7 @@ module.exports = { c.reply(reply("username",c.username)) c.reply(reply("nickname",c.nickname)) c.reply(reply("command",c.command)) + c.reply(reply("msgType",c.msgType)) c.reply(reply("prefix",c.prefix)) c.reply(reply("index",c.index.toString())) c.reply(reply("args",c.args.join(", "))) diff --git a/lang/en-US.json b/lang/en-US.json index f4c8937..6d4ed6e 100644 --- a/lang/en-US.json +++ b/lang/en-US.json @@ -73,6 +73,7 @@ "command.test.username": "Username", "command.test.nickname": "Nickname", "command.test.command": "Command", + "command.test.msgType": "Message type", "command.test.prefix": "Prefix", "command.test.index": "Bot ID", "command.test.args": "Arguments", From 42f3839dd27d7c322682f36a724710f6c46e1450 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sat, 17 Aug 2024 07:54:24 -0400 Subject: [PATCH 345/362] Add information for test command --- lang/en-US.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lang/en-US.json b/lang/en-US.json index 6d4ed6e..9dfd4c6 100644 --- a/lang/en-US.json +++ b/lang/en-US.json @@ -35,8 +35,10 @@ "command.stop.desc": "Restart bot", "command.template.usage": " [optional]", "command.template.desc": "Does nothing", - "command.tpr.desc": "Teleport to a random location", + "command.test.usage": " [args...]", + "command.test.desc": "Chat parsing debugger command", "command.tpr.usage": "", + "command.tpr.desc": "Teleport to a random location", "command.verify.usage": " [args...]", "command.verify.desc": "Check the hashing system", "command.about.author": "%s - a Minecraft bot made by %s for Kaboom and clones", From 1631d3cb9d8bea870dffbe34527ea832b63bfd2e Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sat, 17 Aug 2024 09:45:30 -0400 Subject: [PATCH 346/362] Remove bot index from command class --- commands/test.js | 1 - lang/en-US.json | 1 - util/Command.js | 1 - util/ConsoleCommand.js | 1 - 4 files changed, 4 deletions(-) diff --git a/commands/test.js b/commands/test.js index 089b73f..07f7de3 100644 --- a/commands/test.js +++ b/commands/test.js @@ -23,7 +23,6 @@ module.exports = { c.reply(reply("command",c.command)) c.reply(reply("msgType",c.msgType)) c.reply(reply("prefix",c.prefix)) - c.reply(reply("index",c.index.toString())) c.reply(reply("args",c.args.join(", "))) c.reply(reply("verify",c.verify.toString())) c.reply(reply("host",c.host)) diff --git a/lang/en-US.json b/lang/en-US.json index 9dfd4c6..690ac76 100644 --- a/lang/en-US.json +++ b/lang/en-US.json @@ -77,7 +77,6 @@ "command.test.command": "Command", "command.test.msgType": "Message type", "command.test.prefix": "Prefix", - "command.test.index": "Bot ID", "command.test.args": "Arguments", "command.test.verify": "Permission level", "command.test.host": "Server host", diff --git a/util/Command.js b/util/Command.js index 6eef075..638af23 100644 --- a/util/Command.js +++ b/util/Command.js @@ -11,7 +11,6 @@ class Command { this.prefix = prefix this.bot = bot this.type = 'minecraft' - this.index = bot.id this.args = cmd.split(' ').slice(1) this.verify = verify this.host = bot.host.host diff --git a/util/ConsoleCommand.js b/util/ConsoleCommand.js index e20f9ea..b70f19d 100644 --- a/util/ConsoleCommand.js +++ b/util/ConsoleCommand.js @@ -16,7 +16,6 @@ class ConsoleCommand { ? index.bot[index2] : {} this.type = 'console' - this.index = index2 this.args = cmd.split(' ').slice(1) this.verify = 3 this.host = '' From 3a76b57b333292adef082e3b18a6ba0468ed77c8 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sat, 17 Aug 2024 09:56:26 -0400 Subject: [PATCH 347/362] Chgange plugin loakder --- index.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/index.js b/index.js index 0c9d584..df126e4 100755 --- a/index.js +++ b/index.js @@ -6,17 +6,18 @@ const fs = require('fs') module.exports.bot = [] -const loadplug = (botno) => { - const botplug = [] - const bpl = fs.readdirSync('plugins') - for (const i in bpl) { - if (!bpl[i].endsWith('.js')) { - continue - } - try { - botplug.push(require(`./plugins/${bpl[i]}`)) - } catch (e) { console.log(e) } +const botplug = [] +const bpl = fs.readdirSync('plugins') +for (const i in bpl) { + if (!bpl[i].endsWith('.js')) { + continue } + try { + botplug.push(require(`./plugins/${bpl[i]}`)) + } catch (e) { console.log(e) } +} + +const loadplug = (botno) => { botplug.forEach((plug) => { try { if (plug.load) { From 8625473d6500eaf22d5a3873cfd7e17030bf01b4 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sun, 18 Aug 2024 03:10:10 -0400 Subject: [PATCH 348/362] SundanceNanshan 10A23941a --- plugins/!chat.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/plugins/!chat.js b/plugins/!chat.js index 6e1a568..2b1ab0d 100755 --- a/plugins/!chat.js +++ b/plugins/!chat.js @@ -35,7 +35,6 @@ module.exports = { } else if (data.type === 6 || data.type === 7) { const uuid = b.findUUID(parsePlain(parse1204(data.name))) const nickname = b.findDisplayName(uuid) - console.log(uuid) b.emit('chat', { json: { translate: messageTypes[data.type], @@ -74,7 +73,6 @@ module.exports = { }) b._client.on('player_chat', (data) => { - console.log(parsePlain(parse1204(data.networkName))) if (data.type === 4) { b.emit('chat', { json: parse1204(data.unsignedChatContent), From c3ef6752f32f22872b40fa9d1d9b23e440b2c8fa Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sun, 18 Aug 2024 03:17:47 -0400 Subject: [PATCH 349/362] Remove extraneous comments --- commands/help.js | 2 +- plugins/!chat.js | 2 +- plugins/commandblock.js | 4 ++-- util/ConsoleCommand.js | 9 ++++----- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/commands/help.js b/commands/help.js index 817b71e..16dfb52 100644 --- a/commands/help.js +++ b/commands/help.js @@ -9,7 +9,7 @@ const sortHelp = function sortHelp (c1, c2) { } const bpl = fs.readdirSync('./commands') -for (const i in bpl) { // Built-in loadCMD to the help command, to prevent circular require +for (const i in bpl) { if (!bpl[i].endsWith('.js')) { continue } diff --git a/plugins/!chat.js b/plugins/!chat.js index 2b1ab0d..89c4cef 100755 --- a/plugins/!chat.js +++ b/plugins/!chat.js @@ -136,7 +136,7 @@ module.exports = { }) }) - b._client.on('chat', (data) => { // Legacy chat + b._client.on('chat', (data) => { // Legacy chat for versions <1.19 const json = parse1204(data.message) const parsed = parsePlain(json) let chatName diff --git a/plugins/commandblock.js b/plugins/commandblock.js index 2f1c0c4..2f6db10 100755 --- a/plugins/commandblock.js +++ b/plugins/commandblock.js @@ -56,7 +56,7 @@ module.exports = { b._client.on('login', () => { b._client.write("settings",{ - locale: "ru_RU", // Русский (Россия) + locale: "ru_RU", viewDistance: 4, chatFlags: 0, // Enable full chat functionality chatColors: true, @@ -71,7 +71,7 @@ module.exports = { }) }) b.on('ccstart', () => { - setTimeout(() => { b.interval.ccqi = setInterval(b.advanceccq, 2) }, 1000) // 1 second and 2 milliseconds + setTimeout(() => { b.interval.ccqi = setInterval(b.advanceccq, 2) }, 1000) b.ccStarted = true }) b.on('chat', (data) => { diff --git a/util/ConsoleCommand.js b/util/ConsoleCommand.js index b70f19d..e631598 100644 --- a/util/ConsoleCommand.js +++ b/util/ConsoleCommand.js @@ -1,17 +1,16 @@ -// HOW TO WRITE CLASS JS const index = require('../index.js') const parse = require('../util/chatparse_console.js') const settings = require('../settings.json') class ConsoleCommand { constructor (cmd, index2) { - this.send = () => {} // not needed for console + this.send = () => {} this.reply = text => process.stdout.write(parse(text) + '\n') - this.uuid = 'dde5a2a6-ebdd-7bbb-8eac-f75b10c10446' // hard-coded because uuid does not exist at console + this.uuid = 'dde5a2a6-ebdd-7bbb-8eac-f75b10c10446' this.username = 'Owner' this.nickname = 'Console' this.command = cmd this.msgType = "_bot_console"; - this.prefix = '' // prefix does not exist at console + this.prefix = '' this.bot = index2 >= 0 ? index.bot[index2] : {} @@ -19,7 +18,7 @@ class ConsoleCommand { this.args = cmd.split(' ').slice(1) this.verify = 3 this.host = '' - this.port = '3' // :3 + this.port = '3' this.lang = settings.defaultLang this.colors = settings.colors } From 6f0d9e8994172ac1776bd07870fa581fe7f8d58c Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sun, 18 Aug 2024 03:18:09 -0400 Subject: [PATCH 350/362] Lint --- commands/test.js | 28 ++++++++++++++-------------- plugins/!chat.js | 19 ++++++++++--------- plugins/commandblock.js | 4 ++-- plugins/player.js | 12 ++++++------ util/Command.js | 2 +- util/ConsoleCommand.js | 2 +- 6 files changed, 34 insertions(+), 33 deletions(-) diff --git a/commands/test.js b/commands/test.js index 07f7de3..dbde4c3 100644 --- a/commands/test.js +++ b/commands/test.js @@ -1,7 +1,7 @@ const { getMessage } = require('../util/lang.js') module.exports = { execute: (c) => { - const reply=function(name, item){ + const reply = function (name, item) { return { translate: '%s: %s', color: c.colors.primary, @@ -17,18 +17,18 @@ module.exports = { ] } } - c.reply(reply("uuid",c.uuid)) - c.reply(reply("username",c.username)) - c.reply(reply("nickname",c.nickname)) - c.reply(reply("command",c.command)) - c.reply(reply("msgType",c.msgType)) - c.reply(reply("prefix",c.prefix)) - c.reply(reply("args",c.args.join(", "))) - c.reply(reply("verify",c.verify.toString())) - c.reply(reply("host",c.host)) - c.reply(reply("port",c.port.toString())) - c.reply(reply("lang",c.lang)) - c.reply(reply("colorPrimary",c.colors.primary)) - c.reply(reply("colorSecondary",c.colors.secondary)) + c.reply(reply('uuid', c.uuid)) + c.reply(reply('username', c.username)) + c.reply(reply('nickname', c.nickname)) + c.reply(reply('command', c.command)) + c.reply(reply('msgType', c.msgType)) + c.reply(reply('prefix', c.prefix)) + c.reply(reply('args', c.args.join(', '))) + c.reply(reply('verify', c.verify.toString())) + c.reply(reply('host', c.host)) + c.reply(reply('port', c.port.toString())) + c.reply(reply('lang', c.lang)) + c.reply(reply('colorPrimary', c.colors.primary)) + c.reply(reply('colorSecondary', c.colors.secondary)) } } diff --git a/plugins/!chat.js b/plugins/!chat.js index 89c4cef..c64557f 100755 --- a/plugins/!chat.js +++ b/plugins/!chat.js @@ -20,8 +20,8 @@ module.exports = { const parsed = parsePlain(json) const split = parsed.split(': ') const chatName = split.splice(0, 1)[0] - const chatNameSplit = chatName.split(" "); - const nickname = chatNameSplit[chatNameSplit.length-1] + const chatNameSplit = chatName.split(' ') + const nickname = chatNameSplit[chatNameSplit.length - 1] const username = b.findRealName(chatName) const uuid = b.findUUID(username) b.emit('chat', { @@ -76,7 +76,8 @@ module.exports = { if (data.type === 4) { b.emit('chat', { json: parse1204(data.unsignedChatContent), - type: 'player', uuid: data.senderUuid, + type: 'player', + uuid: data.senderUuid, message: data.plainMessage, nickname: parsePlain(parse1204(data.networkName)), username: b.findRealNameFromUUID(data.senderUuid) @@ -122,8 +123,8 @@ module.exports = { const parsed = parsePlain(json) const split = parsed.split(': ') const chatName = split.splice(0, 1)[0] - const chatNameSplit = chatName.split(" "); - const nickname = chatNameSplit[chatNameSplit.length-1] + const chatNameSplit = chatName.split(' ') + const nickname = chatNameSplit[chatNameSplit.length - 1] const username = b.findRealName(chatName) const uuid = b.findUUID(username) b.emit('chat', { @@ -153,17 +154,17 @@ module.exports = { } else { // Servers with Extras chat, such as Kaboom const split = parsed.split(': ') chatName = split.splice(0, 1)[0] - const chatNameSplit = chatName.split(" "); - nickname = chatNameSplit[chatNameSplit.length-1] + const chatNameSplit = chatName.split(' ') + nickname = chatNameSplit[chatNameSplit.length - 1] username = b.findRealName(chatName) uuid = b.findUUID(username) message = split.join(': ') } - if(data.uuid) uuid = data.uuid; + if (data.uuid) uuid = data.uuid b.emit('chat', { json, type: 'legacy', - uuid: uuid, + uuid, message, nickname, username diff --git a/plugins/commandblock.js b/plugins/commandblock.js index 2f6db10..562f5c7 100755 --- a/plugins/commandblock.js +++ b/plugins/commandblock.js @@ -55,8 +55,8 @@ module.exports = { } b._client.on('login', () => { - b._client.write("settings",{ - locale: "ru_RU", + b._client.write('settings', { + locale: 'ru_RU', viewDistance: 4, chatFlags: 0, // Enable full chat functionality chatColors: true, diff --git a/plugins/player.js b/plugins/player.js index 482599b..f78f046 100644 --- a/plugins/player.js +++ b/plugins/player.js @@ -49,18 +49,18 @@ module.exports = { return '[[[[ no name ]]]]' } b.findRealNameFromUUID = (name) => { - if(b.players[name]){ + if (b.players[name]) { return b.players[name].realName } else { - return "[[[[ no name ]]]]" + return '[[[[ no name ]]]]' } } b.findDisplayName = (name) => { - if(b.players[name]){ - const displayName = b.players[name].displayName.split(" "); - return displayName[displayName.length-1] + if (b.players[name]) { + const displayName = b.players[name].displayName.split(' ') + return displayName[displayName.length - 1] } else { - return "[[[[ No display name ]]]]" + return '[[[[ No display name ]]]]' } } } diff --git a/util/Command.js b/util/Command.js index 638af23..3921b7a 100644 --- a/util/Command.js +++ b/util/Command.js @@ -7,7 +7,7 @@ class Command { this.username = user this.nickname = nick this.command = cmd - this.msgType = msgType; + this.msgType = msgType this.prefix = prefix this.bot = bot this.type = 'minecraft' diff --git a/util/ConsoleCommand.js b/util/ConsoleCommand.js index e631598..f062f23 100644 --- a/util/ConsoleCommand.js +++ b/util/ConsoleCommand.js @@ -9,7 +9,7 @@ class ConsoleCommand { this.username = 'Owner' this.nickname = 'Console' this.command = cmd - this.msgType = "_bot_console"; + this.msgType = '_bot_console' this.prefix = '' this.bot = index2 >= 0 ? index.bot[index2] From b9005a6441a28f6f477aa41a5ba6441be12d676c Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sun, 18 Aug 2024 03:18:29 -0400 Subject: [PATCH 351/362] Update packages --- package-lock.json | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/package-lock.json b/package-lock.json index d27dd66..7de7f3a 100755 --- a/package-lock.json +++ b/package-lock.json @@ -14,21 +14,21 @@ } }, "node_modules/@azure/msal-common": { - "version": "14.14.0", - "resolved": "https://registry.npmjs.org/@azure/msal-common/-/msal-common-14.14.0.tgz", - "integrity": "sha512-OxcOk9H1/1fktHh6//VCORgSNJc2dCQObTm6JNmL824Z6iZSO6eFo/Bttxe0hETn9B+cr7gDouTQtsRq3YPuSQ==", + "version": "14.14.1", + "resolved": "https://registry.npmjs.org/@azure/msal-common/-/msal-common-14.14.1.tgz", + "integrity": "sha512-2Q3tqNz/PZLfSr8BvcHZVpRRfSn4MjGSqjj9J+HlBsmbf1Uu4P0WeXnemjTJwwx9KrmplsrN3UkZ/LPOR720rw==", "license": "MIT", "engines": { "node": ">=0.8.0" } }, "node_modules/@azure/msal-node": { - "version": "2.12.0", - "resolved": "https://registry.npmjs.org/@azure/msal-node/-/msal-node-2.12.0.tgz", - "integrity": "sha512-jmk5Im5KujRA2AcyCb0awA3buV8niSrwXZs+NBJWIvxOz76RvNlusGIqi43A0h45BPUy93Qb+CPdpJn82NFTIg==", + "version": "2.13.0", + "resolved": "https://registry.npmjs.org/@azure/msal-node/-/msal-node-2.13.0.tgz", + "integrity": "sha512-DhP97ycs7qlCVzzzWGzJiwAFyFj5okno74E4FUZ61oCLfKh4IxA1kxirqzrWuYZWpBe9HVPL6GA4NvmlEOBN5Q==", "license": "MIT", "dependencies": { - "@azure/msal-common": "14.14.0", + "@azure/msal-common": "14.14.1", "jsonwebtoken": "^9.0.0", "uuid": "^8.3.0" }, @@ -37,12 +37,12 @@ } }, "node_modules/@types/node": { - "version": "22.2.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.2.0.tgz", - "integrity": "sha512-bm6EG6/pCpkxDf/0gDNDdtDILMOHgaQBVOJGdwsqClnxA3xL6jtMv76rLBc006RVMWbmaf0xbmom4Z/5o2nRkQ==", + "version": "22.4.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.4.0.tgz", + "integrity": "sha512-49AbMDwYUz7EXxKU/r7mXOsxwFr4BYbvB7tWYxVuLdb2ibd30ijjXINSMAHiEEZk5PCRBmW1gUeisn2VMKt3cQ==", "license": "MIT", "dependencies": { - "undici-types": "~6.13.0" + "undici-types": "~6.19.2" } }, "node_modules/@types/readable-stream": { @@ -427,9 +427,9 @@ "license": "MIT" }, "node_modules/minecraft-data": { - "version": "3.67.0", - "resolved": "https://registry.npmjs.org/minecraft-data/-/minecraft-data-3.67.0.tgz", - "integrity": "sha512-/hLeYXopx9o1UdViPPFenLJ3hT5S4qUEwLQM0MAHOIhqkAUGXdkl47O7ohG+f87DH3+cZksbbM61sTnSRsQpsA==", + "version": "3.68.0", + "resolved": "https://registry.npmjs.org/minecraft-data/-/minecraft-data-3.68.0.tgz", + "integrity": "sha512-pNBTi39a1zbFpN9itwi0YSL3hqAsSw38D7pE9C6m+aURmXljpBlNTO+TkpZxxDv4KqqtNBOhmkj4x46IDW6R+Q==", "license": "MIT" }, "node_modules/minecraft-folder-path": { @@ -762,9 +762,9 @@ "license": "MIT" }, "node_modules/undici-types": { - "version": "6.13.0", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.13.0.tgz", - "integrity": "sha512-xtFJHudx8S2DSoujjMd1WeWvn7KKWFRESZTMeL1RptAYERu29D6jphMjjY+vn96jvN3kVPDNxU/E13VTaXj6jg==", + "version": "6.19.6", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.6.tgz", + "integrity": "sha512-e/vggGopEfTKSvj4ihnOLTsqhrKRN3LeO6qSN/GxohhuRv8qH9bNQ4B8W7e/vFL+0XTnmHPB4/kegunZGA4Org==", "license": "MIT" }, "node_modules/uri-js": { From 7043e559c0a02a6591592cfb15fd1f6d0eb8e881 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sun, 18 Aug 2024 10:44:42 -0400 Subject: [PATCH 352/362] Fix command core 32767 bug (this goes to RC3) --- plugins/commandblock.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/commandblock.js b/plugins/commandblock.js index 562f5c7..f82e61e 100755 --- a/plugins/commandblock.js +++ b/plugins/commandblock.js @@ -19,7 +19,7 @@ module.exports = { b.advanceccq = function () { if (b.ccq[0] && b.ccq[0].length !== 0) { b._client.write('update_command_block', { - command: b.ccq[0], + command: "/", location: { x: b.commandPos.x + b.blocknoX, y: b.commandPos.y + b.blocknoY, @@ -29,7 +29,7 @@ module.exports = { flags: 1 }) b._client.write('update_command_block', { - command: b.ccq[0], + command: b.ccq[0].substr(0,32767), location: { x: b.commandPos.x + b.blocknoX, y: b.commandPos.y + b.blocknoY, From 4eea38cca75f2157a613c6fe49003b3d64177b33 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sun, 18 Aug 2024 13:09:53 -0400 Subject: [PATCH 353/362] Remove rc.1 at the end of version This does not mean that 10.0.0 is here yet. I have just decided to make the release candidates' version numbers the same as releases, as has been done for betas (they use different tag names to allow me to make multiple candidates for betas). --- package.json | 2 +- version.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 0b0cbce..2fd88fd 100755 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "prismarine-chat": "^1.10.0" }, "name": "botv10", - "version": "10.0.0-beta-2", + "version": "10.0.0", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" diff --git a/version.json b/version.json index e9d2ba3..1ea42bc 100644 --- a/version.json +++ b/version.json @@ -1,6 +1,6 @@ { "botName": "botvX Dev", - "botVersion": "10.0.0-rc.1", + "botVersion": "10.0.0", "botAuthor": "a5a06d596f15c7db", "isPreRelease": true, "sourceURL": "https://code.chipmunk.land/7cc5c4f330d47060/botvX" From c1ec0799b96ca127a87eac1190df444060f0afea Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sun, 18 Aug 2024 13:17:52 -0400 Subject: [PATCH 354/362] Seperate kernel version from command.about.serverInfo.os --- commands/about.js | 13 +++++++++---- lang/en-US.json | 5 +++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/commands/about.js b/commands/about.js index 72e118c..6378010 100644 --- a/commands/about.js +++ b/commands/about.js @@ -56,7 +56,7 @@ const aboutBot = function (c) { const os2 = function (o2, l) { switch (o2) { case 'win32': - return `${os.version()} (${os.release})` + return `${os.version()}` case 'android':{ try { const version = cp.execSync('getprop ro.build.version.release').toString('UTF-8').split('\n')[0] @@ -78,12 +78,12 @@ const os2 = function (o2, l) { } if (osrelease2.PRETTY_NAME) { - return getMessage(l, '%s %s', [osrelease2.PRETTY_NAME, os.release()]) + return getMessage(l, '%s', [osrelease2.PRETTY_NAME]) } else { - return getMessage(l, `command.about.serverInfo.os.${o2}`, [os.release()]) + return getMessage(l, `command.about.serverInfo.os.${o2}`) } } else { - return getMessage(l, `command.about.serverInfo.os.${o2}`, [os.release()]) + return getMessage(l, `command.about.serverInfo.os.${o2}`) } } default: @@ -121,6 +121,11 @@ const aboutServer = function (c) { return os2(process.platform, c.lang) }) + // Kernel version: os.release() + displayInfo('command.about.serverInfo.kernelVer', () => { + return os.release() + }) + // Processor if (os.cpus()[0]) { displayInfo('command.about.serverInfo.processor', () => { diff --git a/lang/en-US.json b/lang/en-US.json index 690ac76..8dbbc57 100644 --- a/lang/en-US.json +++ b/lang/en-US.json @@ -86,11 +86,12 @@ "command.test.colorSecondary": "Secondary color", "command.about.serverInfo.os.android": "Android %s", "command.about.serverInfo.os.android.noVersion": "Android", - "command.about.serverInfo.os.freebsd": "FreeBSD %s", - "command.about.serverInfo.os.linux": "Linux %s", + "command.about.serverInfo.os.freebsd": "FreeBSD", + "command.about.serverInfo.os.linux": "Linux", "command.about.serverInfo.os.macos": "macOS", "command.about.serverInfo.os.macos_old": "OS X", "command.about.serverInfo.os": "Operating system", + "command.about.serverInfo.kernelVer": "Kernel version", "command.about.serverInfo.processor": "CPU", "command.about.serverInfo.arch": "Architecture", "command.about.serverInfo.osUsername": "Username", From 2ab710531efd7eb6a4cee3c6c7d43531da6b47d0 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sun, 18 Aug 2024 13:23:44 -0400 Subject: [PATCH 355/362] Bugfiox RC4 --- commands/about.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/about.js b/commands/about.js index 6378010..37c24f2 100644 --- a/commands/about.js +++ b/commands/about.js @@ -62,7 +62,7 @@ const os2 = function (o2, l) { const version = cp.execSync('getprop ro.build.version.release').toString('UTF-8').split('\n')[0] return getMessage(l, 'command.about.serverInfo.os.android', [version]) } catch (e) { - getMessage(l, 'command.about.serverInfo.os.android.noVersion') + return getMessage(l, 'command.about.serverInfo.os.android.noVersion') } } case 'linux': From 0939649c79d9c813992454a2800a7db79f6ae268 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 19 Aug 2024 01:56:31 -0400 Subject: [PATCH 356/362] Make the chat use surrogate codepoints --- util/chatparse_console.js | 10 +++++----- util/chatparse_plain.js | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/util/chatparse_console.js b/util/chatparse_console.js index 435d9e0..b2da024 100644 --- a/util/chatparse_console.js +++ b/util/chatparse_console.js @@ -70,19 +70,19 @@ const parse = function (_data, l = 0, resetColor = consoleColors.reset) { if (typeof _text === 'number') { _text = _text.toString() } - out += _text.replaceAll('\x1b', '').replaceAll('\x0e', '') // Remove escape codes and [SO] from console format + out += _text.replaceAll('\x1b', '').replaceAll('\x0e', '') } if (data.translate) { - let trans = data.translate.replace(/%%/g, '\ue123').replaceAll('\x1b', '').replaceAll('\x0e', '') // Remove escape codes from console format + let trans = data.translate.replaceAll('%%', '\ud900\ud801').replaceAll('\x1b', '').replaceAll('\x0e', '') if (lang[trans] !== undefined) { trans = lang[trans].replace(/%%/g, '\ue123') } for (const i in data.with) { const j2 = parse(data.with[i], l + 1, data.color ? processColor(data.color, resetColor) : resetColor) - trans = trans.replace(/%s/, j2.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) - trans = trans.replaceAll(`%${+i + 1}$s`, j2.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + trans = trans.replace(/%s/, j2.replaceAll('%s', '\ud900\ud804').replaceAll('$s', '\ud900\ud805')) + trans = trans.replaceAll(`%${+i + 1}$s`, j2.replaceAll('%s', '\ud900\ud804').replaceAll('$s', '\ud900\ud805')) } - out += trans.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s') + out += trans.replaceAll('\ud900\ud801', '%').replaceAll('\ud900\ud804', '%s').replaceAll('\ud900\ud805', '$s') } if (data.extra) { for (const i in data.extra) { diff --git a/util/chatparse_plain.js b/util/chatparse_plain.js index 8b15ba4..173c628 100644 --- a/util/chatparse_plain.js +++ b/util/chatparse_plain.js @@ -31,10 +31,10 @@ const parse = function (_data, l = 0) { } for (const i in data.with) { const j2 = parse(data.with[i], l + 1) - trans = trans.replace(/%s/, j2.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) - trans = trans.replaceAll(`%${+i + 1}$s`, j2.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + trans = trans.replace(/%s/, j2.replaceAll('%s', '\ud900\ud804').replaceAll('$s', '\ud900\ud805')) + trans = trans.replaceAll(`%${+i + 1}$s`, j2.replaceAll('%s', '\ud900\ud804').replaceAll('$s', '\ud900\ud805')) } - out += trans.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s') + out += trans.replaceAll('\ud900\ud801', '%').replaceAll('\ud900\ud804', '%s').replaceAll('\ud900\ud805', '$s') } if (data.extra) { for (const i in data.extra) { From 0c516e30411df33e19c482319057ac80b907c44f Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 19 Aug 2024 03:17:48 -0400 Subject: [PATCH 357/362] Microsoft Corporation --- plugins/commandblock.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/commandblock.js b/plugins/commandblock.js index f82e61e..228f091 100755 --- a/plugins/commandblock.js +++ b/plugins/commandblock.js @@ -19,7 +19,7 @@ module.exports = { b.advanceccq = function () { if (b.ccq[0] && b.ccq[0].length !== 0) { b._client.write('update_command_block', { - command: "/", + command: '/', location: { x: b.commandPos.x + b.blocknoX, y: b.commandPos.y + b.blocknoY, @@ -29,7 +29,7 @@ module.exports = { flags: 1 }) b._client.write('update_command_block', { - command: b.ccq[0].substr(0,32767), + command: b.ccq[0].substr(0, 32767), location: { x: b.commandPos.x + b.blocknoX, y: b.commandPos.y + b.blocknoY, From 4efbf43edb29e675f4f814bd530aa513bf6b5648 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Mon, 19 Aug 2024 07:11:30 -0400 Subject: [PATCH 358/362] Update the readme --- README.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/README.md b/README.md index 7c4cb84..8eac54d 100644 --- a/README.md +++ b/README.md @@ -2,17 +2,13 @@ ## What is it? -botvX is a Minecraft bot for [Kaboom](https://kaboom.pw/) and its clones. It has many of the features that you would expect in a modern Kaboom bot: +botvX is a Minecraft bot originally designed for [Kaboom](https://kaboom.pw/) and its clones. It has many of the features that you would expect in a modern Kaboom bot: - commands (obviously) - a self care system - a command core, to run commands quickly - a hashing system, to enable trusted users to securely run certain commands in chat -## What does "botvX" mean? - -"botvX" means "bot version 10". The v is used to signify that whatever after it is a version, as was done with previous versions (botv4, botv6, botv8, botv9), and the X is the Roman numeral for 10, since this is the 10th major version. - ## How to install? 1. Install [Node.js](https://nodejs.org/) for your operating system. From 943e134d7a0981be8216825b45efc27fc568e866 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Tue, 20 Aug 2024 14:04:23 -0400 Subject: [PATCH 359/362] v11 backport --- lang/en-US.json | 1 + 1 file changed, 1 insertion(+) diff --git a/lang/en-US.json b/lang/en-US.json index 8dbbc57..aab09f4 100644 --- a/lang/en-US.json +++ b/lang/en-US.json @@ -71,6 +71,7 @@ "command.settings.error.invalidKey": "Invalid key", "command.settings.error.invalidLanguage": "Invalid language", "command.settings.error.mustProvideValue": "You must provide a value", + "command.settings.saved": "Settings saved.", "command.test.uuid": "UUID", "command.test.username": "Username", "command.test.nickname": "Nickname", From c4d07a1ff91db32e697c5d0476e62c03116bc0a4 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Wed, 21 Aug 2024 04:29:45 -0400 Subject: [PATCH 360/362] Change legal username generator --- util/usergen.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/util/usergen.js b/util/usergen.js index ce845c3..cf2f9e9 100644 --- a/util/usergen.js +++ b/util/usergen.js @@ -1,3 +1,4 @@ +const crypto = require('crypto') const rsg = function (count) { let output = '' for (let i = 0; i < count; i++) { @@ -29,9 +30,19 @@ const rsg = function (count) { } return output } +const rsgLegal = function (count) { + let output = '' + if(Math.random()>0.5){ + output += "uwu_" + } else { + output += "owo_" + } + output += crypto.randomBytes(count).toString("hex") + return output +} module.exports = function (legal) { if (legal) { - return Math.floor(Math.random() * 1000000).toString() + return rsgLegal(6) } else { return rsg(6 + Math.floor(Math.random() * 3)) } From b0241e707c52a7028e91142e813e1475d3e25d8b Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Wed, 21 Aug 2024 16:52:04 -0400 Subject: [PATCH 361/362] Convert arrays to use for...of or forEach instead of for...in for...in is for objects, not arrays apparently --- commands/about.js | 16 ++++++++-------- commands/cloop.js | 10 +++++----- commands/help.js | 16 ++++++++-------- commands/netmsg.js | 8 ++++---- commands/settings.js | 10 +++++----- index.js | 10 +++++----- plugins/!chat.js | 8 ++++---- plugins/cloop.js | 4 ++-- plugins/player.js | 24 ++++++++++++------------ util/chatparse_console.js | 14 ++++++++------ util/chatparse_plain.js | 4 ++-- util/commands.js | 12 ++++++------ util/lang.js | 14 ++++++++------ 13 files changed, 77 insertions(+), 73 deletions(-) diff --git a/commands/about.js b/commands/about.js index 37c24f2..df4c40f 100644 --- a/commands/about.js +++ b/commands/about.js @@ -70,11 +70,11 @@ const os2 = function (o2, l) { if (fs.readdirSync('/etc').includes('os-release')) { const osrelease = fs.readFileSync('/etc/os-release').toString('UTF-8').split('\n') const osrelease2 = {} - for (const i in osrelease) { - if (!osrelease[i].includes('=')) continue - let osrvalue = osrelease[i].split('=')[1] + for (const item of osrelease) { + if (!item.includes('=')) continue + let osrvalue = item.split('=')[1] if (osrvalue.startsWith('"') && osrvalue.endsWith('"')) { osrvalue = osrvalue.slice(1, osrvalue.length - 1) }; - osrelease2[osrelease[i].split('=')[0]] = osrvalue + osrelease2[item.split('=')[0]] = osrvalue } if (osrelease2.PRETTY_NAME) { @@ -186,8 +186,8 @@ const aboutServer = function (c) { } const displayServerList = function (c) { - for (const i in index.bot) { - if (index.bot[i].host.options && index.bot[i].host.options.hidden) continue + index.bot.forEach((item, i)=>{ + if (item.host.options && item.host.options.hidden) return c.reply({ translate: getMessage(c.lang, 'command.about.serverListItem'), color: c.colors.secondary, @@ -197,12 +197,12 @@ const displayServerList = function (c) { color: c.colors.primary }, { - text: `${index.bot[i].host.host}:${index.bot[i].host.port}`, + text: `${item.host.host}:${item.host.port}`, color: c.colors.primary } ] }) - } + }) } module.exports = { diff --git a/commands/cloop.js b/commands/cloop.js index 4e349b0..b09254e 100644 --- a/commands/cloop.js +++ b/commands/cloop.js @@ -44,26 +44,26 @@ module.exports = { break } case 'list': - for (const i in c.bot.cloops) { + c.bot.cloops.forEach((item, i)=>{ c.reply({ translate: getMessage(c.lang, 'command.cloop.list'), color: c.colors.secondary, with: [ { - text: i, + text: i.toString(), color: c.colors.primary }, { - text: c.bot.cloops[i].command, + text: item.command, color: c.colors.primary }, { - text: c.bot.cloops[i].rate + '', + text: item.rate + '', color: c.colors.primary } ] }) - } + }) break case 'clear': c.bot.clearCloops() diff --git a/commands/help.js b/commands/help.js index 16dfb52..10b0bd3 100644 --- a/commands/help.js +++ b/commands/help.js @@ -9,14 +9,14 @@ const sortHelp = function sortHelp (c1, c2) { } const bpl = fs.readdirSync('./commands') -for (const i in bpl) { - if (!bpl[i].endsWith('.js')) { +for (const plugin of bpl) { + if (!plugin.endsWith('.js')) { continue } try { - const commandName = bpl[i].split('.js')[0] + const commandName = plugin.split('.js')[0] if (commandName !== 'help') { - cmds[commandName] = require(`./${bpl[i]}`) + cmds[commandName] = require(`./${plugin}`) if (cmds[commandName].level === undefined) { cmds[commandName].level = 0 } @@ -89,7 +89,7 @@ const printCmdHelp = (c) => { desc = cmds[cmds[cmd].alias].desc } } - for (const i in usage) { + for (const item of usage) { c.reply({ translate: getMessage(c.lang, 'command.help.commandUsage'), color: c.colors.secondary, @@ -99,7 +99,7 @@ const printCmdHelp = (c) => { color: c.colors.primary }, { - text: usage[i], + text: item, color: c.colors.primary } ] @@ -152,8 +152,8 @@ if (cmds.help.level === undefined) { for (const i in cmds) { if (cmds[i].aliases) { - for (const j in cmds[i].aliases) { - cmds[cmds[i].aliases[j]] = { + for (const alias of cmds[commandName].aliases) { + cmds[alias] = { alias: i, usage: cmds[i].usage, level: cmds[i].level, diff --git a/commands/netmsg.js b/commands/netmsg.js index 4537c85..3522bc7 100644 --- a/commands/netmsg.js +++ b/commands/netmsg.js @@ -36,9 +36,9 @@ module.exports = { ], color: 'white' } - for (const i in bot) { - if (bot[i].host.options.hidden) continue - bot[i].tellraw('@a', json) - } + bot.forEach(item => { + if (item.host.options.hidden) return + item.tellraw('@a', json) + }) } } diff --git a/commands/settings.js b/commands/settings.js index 96d6895..3b9df27 100644 --- a/commands/settings.js +++ b/commands/settings.js @@ -17,27 +17,27 @@ module.exports = { const value = c.args.join(' ') if (value === '' && key === 'lang') { // Show all valid languages to user - for (const i in languages) { + for (const item of languages) { c.reply({ translate: '%s (%s)', color: c.colors.secondary, with: [ { - text: getMessage(languages[i], 'language.name'), + text: getMessage(item, 'language.name'), color: c.colors.primary }, { - text: getMessage(languages[i], 'language.region'), + text: getMessage(item, 'language.region'), color: c.colors.primary } ], hoverEvent: { action: 'show_text', value: { - translate: getMessage(languages[i], 'command.settings.setLanguage'), + translate: getMessage(item, 'command.settings.setLanguage'), with: [ { - text: `${c.prefix}settings set lang ${languages[i]}`, + text: `${c.prefix}settings set lang ${item}`, color: c.colors.secondary } ] diff --git a/index.js b/index.js index df126e4..99f4061 100755 --- a/index.js +++ b/index.js @@ -8,12 +8,12 @@ module.exports.bot = [] const botplug = [] const bpl = fs.readdirSync('plugins') -for (const i in bpl) { - if (!bpl[i].endsWith('.js')) { +for (const plugin of bpl) { + if (!plugin.endsWith('.js')) { continue } try { - botplug.push(require(`./plugins/${bpl[i]}`)) + botplug.push(require(`./plugins/${plugin}`)) } catch (e) { console.log(e) } } @@ -67,8 +67,8 @@ const createBot = function createBot (host, oldId) { }) } -for (const i in settings.servers) { - createBot(settings.servers[i]) +for (const server of settings.servers) { + createBot(server) } module.exports.createBot = createBot diff --git a/plugins/!chat.js b/plugins/!chat.js index c64557f..028ee2f 100755 --- a/plugins/!chat.js +++ b/plugins/!chat.js @@ -181,10 +181,10 @@ module.exports = { b.displayChat(data.type, `${msgConsole}\x1b[0m`) const fullCommand = data.message - for (const i in b.prefix) { - if (fullCommand.startsWith(b.prefix[i])) { - const command = fullCommand.slice(b.prefix[i].length) - b.runCommand(data.username, data.nickname, data.uuid, command, data.type, b.prefix[i]) + for (const prefix of b.prefix) { + if (fullCommand.startsWith(prefix)) { + const command = fullCommand.slice(prefix.length) + b.runCommand(data.username, data.nickname, data.uuid, command, data.type, prefix) } } }) diff --git a/plugins/cloop.js b/plugins/cloop.js index f67fb46..f2002fa 100755 --- a/plugins/cloop.js +++ b/plugins/cloop.js @@ -14,8 +14,8 @@ module.exports = { b.cloops.splice(index, 1) } b.clearCloops = function () { - for (const i in b.cloops) { - clearInterval(b.cloops[i].interval) + for (const cloop of b.cloops) { + clearInterval(cloop.interval) } b.cloops = [] } diff --git a/plugins/player.js b/plugins/player.js index f78f046..71bc63f 100644 --- a/plugins/player.js +++ b/plugins/player.js @@ -5,24 +5,24 @@ module.exports = { b.players = {} b._client.on('player_info', (data) => { const buffer2 = {} - for (const i in data.data) { + for (const player of data.data) { let uuid - if (data.data[i].uuid) { - uuid = data.data[i].uuid - } else if (data.data[i].UUID) { - uuid = data.data[i].UUID + if (player.uuid) { + uuid = player.uuid + } else if (player.UUID) { + uuid = player.UUID } let displayName - if (data.data[i].displayName !== undefined) { - displayName = data.data[i].displayName + if (player.displayName !== undefined) { + displayName = player.displayName } else { displayName = '{"text":"[[[[ No display name ]]]]"}' } - if (data.data[i].player && data.data[i].player.name !== undefined) { - buffer2[uuid] = { realName: data.data[i].player.name, displayName: parse(parseNBT(displayName)) } - } else if (data.data[i].name !== undefined) { - buffer2[uuid] = { realName: data.data[i].name, displayName: parse(parseNBT(displayName)) } - } else if (data.data[i].displayName !== undefined) { + if (player.player && player.player.name !== undefined) { + buffer2[uuid] = { realName: player.player.name, displayName: parse(parseNBT(displayName)) } + } else if (player.name !== undefined) { + buffer2[uuid] = { realName: player.name, displayName: parse(parseNBT(displayName)) } + } else if (player.displayName !== undefined) { buffer2[uuid] = { displayName: parse(parseNBT(displayName)) } } } diff --git a/util/chatparse_console.js b/util/chatparse_console.js index b2da024..0c4a37b 100644 --- a/util/chatparse_console.js +++ b/util/chatparse_console.js @@ -77,16 +77,18 @@ const parse = function (_data, l = 0, resetColor = consoleColors.reset) { if (lang[trans] !== undefined) { trans = lang[trans].replace(/%%/g, '\ue123') } - for (const i in data.with) { - const j2 = parse(data.with[i], l + 1, data.color ? processColor(data.color, resetColor) : resetColor) - trans = trans.replace(/%s/, j2.replaceAll('%s', '\ud900\ud804').replaceAll('$s', '\ud900\ud805')) - trans = trans.replaceAll(`%${+i + 1}$s`, j2.replaceAll('%s', '\ud900\ud804').replaceAll('$s', '\ud900\ud805')) + if(data.with){ + data.with.forEach((item, i) => { + const j2 = parse(item, l + 1, data.color ? processColor(data.color, resetColor) : resetColor) + trans = trans.replace(/%s/, j2.replaceAll('%s', '\ud900\ud804').replaceAll('$s', '\ud900\ud805')) + trans = trans.replaceAll(`%${+i + 1}$s`, j2.replaceAll('%s', '\ud900\ud804').replaceAll('$s', '\ud900\ud805')) + }) } out += trans.replaceAll('\ud900\ud801', '%').replaceAll('\ud900\ud804', '%s').replaceAll('\ud900\ud805', '$s') } if (data.extra) { - for (const i in data.extra) { - const parsed = parse(data.extra[i], l, data.color ? processColor(data.color, resetColor) : resetColor) + for (const item of data.extra) { + const parsed = parse(item, l, data.color ? processColor(data.color, resetColor) : resetColor) out += parsed } } diff --git a/util/chatparse_plain.js b/util/chatparse_plain.js index 173c628..6dfb1bd 100644 --- a/util/chatparse_plain.js +++ b/util/chatparse_plain.js @@ -37,8 +37,8 @@ const parse = function (_data, l = 0) { out += trans.replaceAll('\ud900\ud801', '%').replaceAll('\ud900\ud804', '%s').replaceAll('\ud900\ud805', '$s') } if (data.extra) { - for (const i in data.extra) { - const parsed = parse(data.extra[i], l) + for (const item of data.extra) { + const parsed = parse(item, l) out += parsed } } diff --git a/util/commands.js b/util/commands.js index 58344c9..adf045f 100644 --- a/util/commands.js +++ b/util/commands.js @@ -1,19 +1,19 @@ const fs = require('fs') const cmds = Object.create(null) const bpl = fs.readdirSync('./commands') -for (const i in bpl) { - if (!bpl[i].endsWith('.js')) { +for (const plugin of bpl) { + if (!plugin.endsWith('.js')) { continue } try { - const commandName = bpl[i].split('.js')[0] - cmds[commandName] = require(`../commands/${bpl[i]}`) + const commandName = plugin.split('.js')[0] + cmds[commandName] = require(`../commands/${plugin}`) if (cmds[commandName].level === undefined) { cmds[commandName].level = 0 } if (cmds[commandName].aliases) { - for (const j in cmds[commandName].aliases) { - cmds[cmds[commandName].aliases[j]] = { + for (const alias of cmds[commandName].aliases) { + cmds[alias] = { execute: cmds[commandName].execute, alias: commandName, usage: cmds[commandName].usage, diff --git a/util/lang.js b/util/lang.js index 64af12a..4eb26c3 100644 --- a/util/lang.js +++ b/util/lang.js @@ -3,12 +3,12 @@ const languages = {} const loadplug = (botno) => { const bpl = fs.readdirSync('lang') - for (const i in bpl) { - if (!bpl[i].endsWith('.json')) { + for (const plugin of bpl) { + if (!plugin.endsWith('.json')) { continue } try { - languages[bpl[i].split('.')[0]] = require(`../lang/${bpl[i]}`) + languages[plugin.split('.')[0]] = require(`../lang/${plugin}`) } catch (e) { console.log(e) } } } @@ -21,9 +21,11 @@ const getMessage = function (l, msg, with2) { } else if (languages['en-US'] && languages['en-US'][message] !== undefined) { message = languages['en-US'][message].replace(/%%/g, '\ue123') } - for (const i in with2) { - message = message.replace(/%s/, with2[i].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) - message = message.replaceAll(`%${+i + 1}$s`, with2[i].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + if (with2){ + for (const withItem of with2) { + message = message.replace(/%s/, withItem.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + message = message.replaceAll(`%${+i + 1}$s`, withItem.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) + } } return message.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s') } From deba1d30c71ff536f9c0ef80987b631adc2b8ba3 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Thu, 22 Aug 2024 03:03:08 -0400 Subject: [PATCH 362/362] Update packages --- package-lock.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7de7f3a..ea9789a 100755 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "botv10", - "version": "10.0.0-beta-2", + "version": "10.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "botv10", - "version": "10.0.0-beta-2", + "version": "10.0.0", "license": "MIT", "dependencies": { "minecraft-protocol": "^1.45.0", @@ -37,9 +37,9 @@ } }, "node_modules/@types/node": { - "version": "22.4.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.4.0.tgz", - "integrity": "sha512-49AbMDwYUz7EXxKU/r7mXOsxwFr4BYbvB7tWYxVuLdb2ibd30ijjXINSMAHiEEZk5PCRBmW1gUeisn2VMKt3cQ==", + "version": "22.5.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.5.0.tgz", + "integrity": "sha512-DkFrJOe+rfdHTqqMg0bSNlGlQ85hSoh2TPzZyhHsXnMtligRWpxUySiyw8FY14ITt24HVCiQPWxS3KO/QlGmWg==", "license": "MIT", "dependencies": { "undici-types": "~6.19.2" @@ -762,9 +762,9 @@ "license": "MIT" }, "node_modules/undici-types": { - "version": "6.19.6", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.6.tgz", - "integrity": "sha512-e/vggGopEfTKSvj4ihnOLTsqhrKRN3LeO6qSN/GxohhuRv8qH9bNQ4B8W7e/vFL+0XTnmHPB4/kegunZGA4Org==", + "version": "6.19.8", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz", + "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==", "license": "MIT" }, "node_modules/uri-js": {