Initial commit

This commit is contained in:
7cc5c4f330d47060 2024-07-06 11:02:11 -04:00
parent f6ab36973c
commit de78065438
26 changed files with 1654 additions and 0 deletions

80
index.js Executable file
View file

@ -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;

830
package-lock.json generated Executable file
View file

@ -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"
}
}
}
}

15
package.json Executable file
View file

@ -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": ""
}

50
plugins/!chat.js Executable file
View file

@ -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
}

50
plugins/command.js Executable file
View file

@ -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
}

107
plugins/commandblock.js Executable file
View file

@ -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}`)
}
}
}

15
plugins/commands/about.js Normal file
View file

@ -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: ''
}

11
plugins/commands/help.js Normal file
View file

@ -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]'
}

View file

@ -0,0 +1,9 @@
module.exports={
execute: (c)=>{
c.bot._client.end();
},
desc: "Does nothing", // Command description
usage: ' <required> [optional]', // Command usage
hidden: true,
consoleIndex: true
}

23
plugins/commands/say.js Normal file
View file

@ -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: ' <message>', // Command usage
hidden: true,
consoleIndex: true //To show the command on the help command list, remove this line
}

86
plugins/commands/serverinfo.js Executable file
View file

@ -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: ''
}

View file

@ -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: ' <required> [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
}

8
plugins/commands/testing.js Executable file
View file

@ -0,0 +1,8 @@
module.exports={
load:()=>{
console.log("Loaded on global")
},
loadBot:(b)=>{
console.log(`Loaded on bot ${b.id}`)
}
}

55
plugins/console.js Normal file
View file

@ -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)
}
}

25
plugins/cq.js Executable file
View file

@ -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)
});
}
}
}

19
plugins/rejoin.js Executable file
View file

@ -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)
})
}
}

34
plugins/sc.js Executable file
View file

@ -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);
}
}
}

19
plugins/sc_op.js Executable file
View file

@ -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
}
})
}
}

8
plugins/testing.js Executable file
View file

@ -0,0 +1,8 @@
module.exports={
load:()=>{
console.log("Loaded on global")
},
loadBot:(b)=>{
console.log(`Loaded on bot ${b.id}`)
}
}

22
settings.json Executable file
View file

@ -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"
}
}
]
}

22
util/Command.js Normal file
View file

@ -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;

36
util/ConsoleCommand.js Normal file
View file

@ -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;

71
util/chatparse.js Normal file
View file

@ -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

9
util/chatparse_1204.js Normal file
View file

@ -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

24
util/timeformat.js Executable file
View file

@ -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
}

5
util/uuidtoint.js Normal file
View file

@ -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
}