Rewrite in typescrypt #327
3
.github/workflows/publish_docker_main.yml
vendored
3
.github/workflows/publish_docker_main.yml
vendored
@ -20,9 +20,6 @@ jobs:
|
||||
latestDeploy:
|
||||
runs-on: ubuntu-latest
|
||||
name: Publish latest
|
||||
environment:
|
||||
name: PublishImage
|
||||
url: "ghcr.io/ofvp-project/deamonmaneger"
|
||||
steps:
|
||||
- uses: actions/checkout@v2.4.0
|
||||
with:
|
||||
|
3
.github/workflows/publish_docker_release.yml
vendored
3
.github/workflows/publish_docker_release.yml
vendored
@ -13,9 +13,6 @@ jobs:
|
||||
latestDeploy:
|
||||
runs-on: ubuntu-latest
|
||||
name: Publish latest
|
||||
environment:
|
||||
name: PublishImage
|
||||
url: "ghcr.io/ofvp-project/deamonmaneger"
|
||||
steps:
|
||||
- uses: actions/checkout@v2.4.0
|
||||
with:
|
||||
|
387
package-lock.json
generated
387
package-lock.json
generated
@ -18,16 +18,19 @@
|
||||
"adm-zip": "^0.5.9",
|
||||
"axios": "^0.26.1",
|
||||
"cors": "^2.8.5",
|
||||
"cron": "^1.8.2",
|
||||
"express": "^4.17.3",
|
||||
"strip-json-comments": "^4.0.0",
|
||||
"prismarine-nbt": "^2.2.1",
|
||||
"properties-to-json": "^0.2.1",
|
||||
"typescript": "^4.6.2",
|
||||
"yargs": "^17.4.0"
|
||||
},
|
||||
"bin": {
|
||||
"bds_maneger": "bin/BdsManeger.js"
|
||||
"bds_maneger": "dist/cjs/index.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/adm-zip": "^0.4.34",
|
||||
"@types/cron": "^1.7.3",
|
||||
"@types/express": "^4.17.13",
|
||||
"@types/node": "^17.0.22",
|
||||
"@types/yargs": "^17.0.10",
|
||||
@ -65,6 +68,16 @@
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/cron": {
|
||||
"version": "1.7.3",
|
||||
"resolved": "https://registry.npmjs.org/@types/cron/-/cron-1.7.3.tgz",
|
||||
"integrity": "sha512-iPmUXyIJG1Js+ldPYhOQcYU3kCAQ2FWrSkm1FJPoii2eYSn6wEW6onPukNTT0bfiflexNSRPl6KWmAIqS+36YA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@types/node": "*",
|
||||
"moment": ">=2.14.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/express": {
|
||||
"version": "4.17.13",
|
||||
"resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.13.tgz",
|
||||
@ -157,6 +170,21 @@
|
||||
"node": ">=6.0"
|
||||
}
|
||||
},
|
||||
"node_modules/ajv": {
|
||||
"version": "6.12.6",
|
||||
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz",
|
||||
"integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==",
|
||||
"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/ansi-regex": {
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
|
||||
@ -292,25 +320,6 @@
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/content-disposition/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"
|
||||
}
|
||||
]
|
||||
},
|
||||
"node_modules/content-type": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz",
|
||||
@ -344,6 +353,14 @@
|
||||
"node": ">= 0.10"
|
||||
}
|
||||
},
|
||||
"node_modules/cron": {
|
||||
"version": "1.8.2",
|
||||
"resolved": "https://registry.npmjs.org/cron/-/cron-1.8.2.tgz",
|
||||
"integrity": "sha512-Gk2c4y6xKEO8FSAUTklqtfSr7oTq0CiPQeLBG5Fl0qoXpZyMcj1SG59YL+hqq04bu6/IuEA7lMkYDAplQNKkyg==",
|
||||
"dependencies": {
|
||||
"moment-timezone": "^0.5.x"
|
||||
}
|
||||
},
|
||||
"node_modules/debug": {
|
||||
"version": "2.6.9",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
|
||||
@ -516,24 +533,15 @@
|
||||
"node": ">= 0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/express/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"
|
||||
"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=="
|
||||
},
|
||||
{
|
||||
"type": "patreon",
|
||||
"url": "https://www.patreon.com/feross"
|
||||
},
|
||||
{
|
||||
"type": "consulting",
|
||||
"url": "https://feross.org/support"
|
||||
}
|
||||
]
|
||||
"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=="
|
||||
},
|
||||
"node_modules/finalhandler": {
|
||||
"version": "1.1.2",
|
||||
@ -931,6 +939,11 @@
|
||||
"integrity": "sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw==",
|
||||
"dev": true
|
||||
},
|
||||
"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=="
|
||||
},
|
||||
"node_modules/load-json-file": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-4.0.0.tgz",
|
||||
@ -955,6 +968,16 @@
|
||||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/lodash.get": {
|
||||
"version": "4.4.2",
|
||||
"resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz",
|
||||
"integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk="
|
||||
},
|
||||
"node_modules/lodash.reduce": {
|
||||
"version": "4.6.0",
|
||||
"resolved": "https://registry.npmjs.org/lodash.reduce/-/lodash.reduce-4.6.0.tgz",
|
||||
"integrity": "sha1-8atrg5KZrUj3hKu/R2WW8DuRTTs="
|
||||
},
|
||||
"node_modules/media-typer": {
|
||||
"version": "0.3.0",
|
||||
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
|
||||
@ -1027,6 +1050,25 @@
|
||||
"node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/moment": {
|
||||
"version": "2.29.1",
|
||||
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz",
|
||||
"integrity": "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ==",
|
||||
"engines": {
|
||||
"node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/moment-timezone": {
|
||||
"version": "0.5.34",
|
||||
"resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.34.tgz",
|
||||
"integrity": "sha512-3zAEHh2hKUs3EXLESx/wsgw6IQdusOT8Bxm3D9UrHPQR7zlMmzwybC8zHEM1tQ4LJwP7fcxrWr8tuBg05fFCbg==",
|
||||
"dependencies": {
|
||||
"moment": ">= 2.9.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/ms": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
||||
@ -1329,6 +1371,44 @@
|
||||
"node": ">=0.10"
|
||||
}
|
||||
},
|
||||
"node_modules/prismarine-nbt": {
|
||||
"version": "2.2.1",
|
||||
"resolved": "https://registry.npmjs.org/prismarine-nbt/-/prismarine-nbt-2.2.1.tgz",
|
||||
"integrity": "sha512-Mb50c58CPnuZ+qvM31DBa08tf9UumlTq1LkvpMoUpKfCuN05GZHTqCUwER3lxTSHLL0GZKghIPbYR/JQkINijQ==",
|
||||
"dependencies": {
|
||||
"protodef": "^1.9.0"
|
||||
}
|
||||
},
|
||||
"node_modules/properties-to-json": {
|
||||
"version": "0.2.1",
|
||||
"resolved": "https://registry.npmjs.org/properties-to-json/-/properties-to-json-0.2.1.tgz",
|
||||
"integrity": "sha512-JNrxz39D56CF50mw8T95AhJ3xTvl0ZjmO22KTFMnqDoP0TZzOtUneCOW0H/vE62FkIafUPavWPLHJs33sz7zBg=="
|
||||
},
|
||||
"node_modules/protodef": {
|
||||
"version": "1.15.0",
|
||||
"resolved": "https://registry.npmjs.org/protodef/-/protodef-1.15.0.tgz",
|
||||
"integrity": "sha512-bZ2Omw8dT+DACjJHLrBWZlqN4MlT9g9oSpJDdkUAJOStUzgJp+Zn42FJfPUdwutUxjaxA0PftN0PDlNa2XbneA==",
|
||||
"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==",
|
||||
"dependencies": {
|
||||
"ajv": "^6.5.4"
|
||||
},
|
||||
"bin": {
|
||||
"protodef-validator": "cli.js"
|
||||
}
|
||||
},
|
||||
"node_modules/proxy-addr": {
|
||||
"version": "2.0.7",
|
||||
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz",
|
||||
@ -1341,6 +1421,14 @@
|
||||
"node": ">= 0.10"
|
||||
}
|
||||
},
|
||||
"node_modules/punycode": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",
|
||||
"integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==",
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/qs": {
|
||||
"version": "6.9.7",
|
||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.9.7.tgz",
|
||||
@ -1409,6 +1497,19 @@
|
||||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/readable-stream": {
|
||||
"version": "3.6.0",
|
||||
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz",
|
||||
"integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==",
|
||||
"dependencies": {
|
||||
"inherits": "^2.0.3",
|
||||
"string_decoder": "^1.1.1",
|
||||
"util-deprecate": "^1.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 6"
|
||||
}
|
||||
},
|
||||
"node_modules/require-directory": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",
|
||||
@ -1434,6 +1535,25 @@
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"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"
|
||||
}
|
||||
]
|
||||
},
|
||||
"node_modules/safer-buffer": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
|
||||
@ -1546,6 +1666,14 @@
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"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==",
|
||||
"dependencies": {
|
||||
"safe-buffer": "~5.2.0"
|
||||
}
|
||||
},
|
||||
"node_modules/string-width": {
|
||||
"version": "4.2.3",
|
||||
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz",
|
||||
@ -1622,17 +1750,6 @@
|
||||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/strip-json-comments": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-4.0.0.tgz",
|
||||
"integrity": "sha512-LzWcbfMbAsEDTRmhjWIioe8GcDRl0fa35YMXFoJKDdiD/quGFmjJjdgPjFJJNwCMaLyQqFIDqCdHD2V4HfLgYA==",
|
||||
"engines": {
|
||||
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/supports-preserve-symlinks-flag": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz",
|
||||
@ -1700,6 +1817,19 @@
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/uri-js": {
|
||||
"version": "4.4.1",
|
||||
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz",
|
||||
"integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==",
|
||||
"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": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
|
||||
},
|
||||
"node_modules/utils-merge": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
|
||||
@ -1821,6 +1951,16 @@
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"@types/cron": {
|
||||
"version": "1.7.3",
|
||||
"resolved": "https://registry.npmjs.org/@types/cron/-/cron-1.7.3.tgz",
|
||||
"integrity": "sha512-iPmUXyIJG1Js+ldPYhOQcYU3kCAQ2FWrSkm1FJPoii2eYSn6wEW6onPukNTT0bfiflexNSRPl6KWmAIqS+36YA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/node": "*",
|
||||
"moment": ">=2.14.0"
|
||||
}
|
||||
},
|
||||
"@types/express": {
|
||||
"version": "4.17.13",
|
||||
"resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.13.tgz",
|
||||
@ -1907,6 +2047,17 @@
|
||||
"resolved": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.5.9.tgz",
|
||||
"integrity": "sha512-s+3fXLkeeLjZ2kLjCBwQufpI5fuN+kIGBxu6530nVQZGVol0d7Y/M88/xw9HGGUcJjKf8LutN3VPRUBq6N7Ajg=="
|
||||
},
|
||||
"ajv": {
|
||||
"version": "6.12.6",
|
||||
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz",
|
||||
"integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==",
|
||||
"requires": {
|
||||
"fast-deep-equal": "^3.1.1",
|
||||
"fast-json-stable-stringify": "^2.0.0",
|
||||
"json-schema-traverse": "^0.4.1",
|
||||
"uri-js": "^4.2.2"
|
||||
}
|
||||
},
|
||||
"ansi-regex": {
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
|
||||
@ -2016,13 +2167,6 @@
|
||||
"integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==",
|
||||
"requires": {
|
||||
"safe-buffer": "5.2.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"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=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"content-type": {
|
||||
@ -2049,6 +2193,14 @@
|
||||
"vary": "^1"
|
||||
}
|
||||
},
|
||||
"cron": {
|
||||
"version": "1.8.2",
|
||||
"resolved": "https://registry.npmjs.org/cron/-/cron-1.8.2.tgz",
|
||||
"integrity": "sha512-Gk2c4y6xKEO8FSAUTklqtfSr7oTq0CiPQeLBG5Fl0qoXpZyMcj1SG59YL+hqq04bu6/IuEA7lMkYDAplQNKkyg==",
|
||||
"requires": {
|
||||
"moment-timezone": "^0.5.x"
|
||||
}
|
||||
},
|
||||
"debug": {
|
||||
"version": "2.6.9",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
|
||||
@ -2189,14 +2341,17 @@
|
||||
"type-is": "~1.6.18",
|
||||
"utils-merge": "1.0.1",
|
||||
"vary": "~1.1.2"
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"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=="
|
||||
}
|
||||
}
|
||||
"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=="
|
||||
},
|
||||
"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=="
|
||||
},
|
||||
"finalhandler": {
|
||||
"version": "1.1.2",
|
||||
@ -2466,6 +2621,11 @@
|
||||
"integrity": "sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw==",
|
||||
"dev": true
|
||||
},
|
||||
"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=="
|
||||
},
|
||||
"load-json-file": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-4.0.0.tgz",
|
||||
@ -2486,6 +2646,16 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"lodash.get": {
|
||||
"version": "4.4.2",
|
||||
"resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz",
|
||||
"integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk="
|
||||
},
|
||||
"lodash.reduce": {
|
||||
"version": "4.6.0",
|
||||
"resolved": "https://registry.npmjs.org/lodash.reduce/-/lodash.reduce-4.6.0.tgz",
|
||||
"integrity": "sha1-8atrg5KZrUj3hKu/R2WW8DuRTTs="
|
||||
},
|
||||
"media-typer": {
|
||||
"version": "0.3.0",
|
||||
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
|
||||
@ -2534,6 +2704,19 @@
|
||||
"brace-expansion": "^1.1.7"
|
||||
}
|
||||
},
|
||||
"moment": {
|
||||
"version": "2.29.1",
|
||||
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz",
|
||||
"integrity": "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ=="
|
||||
},
|
||||
"moment-timezone": {
|
||||
"version": "0.5.34",
|
||||
"resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.34.tgz",
|
||||
"integrity": "sha512-3zAEHh2hKUs3EXLESx/wsgw6IQdusOT8Bxm3D9UrHPQR7zlMmzwybC8zHEM1tQ4LJwP7fcxrWr8tuBg05fFCbg==",
|
||||
"requires": {
|
||||
"moment": ">= 2.9.0"
|
||||
}
|
||||
},
|
||||
"ms": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
||||
@ -2763,6 +2946,38 @@
|
||||
"integrity": "sha512-qQbW94hLHEqCg7nhby4yRC7G2+jYHY4Rguc2bjw7Uug4GIJuu1tvf2uHaZv5Q8zdt+WKJ6qK1FOI6amaWUo5FA==",
|
||||
"dev": true
|
||||
},
|
||||
"prismarine-nbt": {
|
||||
"version": "2.2.1",
|
||||
"resolved": "https://registry.npmjs.org/prismarine-nbt/-/prismarine-nbt-2.2.1.tgz",
|
||||
"integrity": "sha512-Mb50c58CPnuZ+qvM31DBa08tf9UumlTq1LkvpMoUpKfCuN05GZHTqCUwER3lxTSHLL0GZKghIPbYR/JQkINijQ==",
|
||||
"requires": {
|
||||
"protodef": "^1.9.0"
|
||||
}
|
||||
},
|
||||
"properties-to-json": {
|
||||
"version": "0.2.1",
|
||||
"resolved": "https://registry.npmjs.org/properties-to-json/-/properties-to-json-0.2.1.tgz",
|
||||
"integrity": "sha512-JNrxz39D56CF50mw8T95AhJ3xTvl0ZjmO22KTFMnqDoP0TZzOtUneCOW0H/vE62FkIafUPavWPLHJs33sz7zBg=="
|
||||
},
|
||||
"protodef": {
|
||||
"version": "1.15.0",
|
||||
"resolved": "https://registry.npmjs.org/protodef/-/protodef-1.15.0.tgz",
|
||||
"integrity": "sha512-bZ2Omw8dT+DACjJHLrBWZlqN4MlT9g9oSpJDdkUAJOStUzgJp+Zn42FJfPUdwutUxjaxA0PftN0PDlNa2XbneA==",
|
||||
"requires": {
|
||||
"lodash.get": "^4.4.2",
|
||||
"lodash.reduce": "^4.6.0",
|
||||
"protodef-validator": "^1.3.0",
|
||||
"readable-stream": "^3.0.3"
|
||||
}
|
||||
},
|
||||
"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==",
|
||||
"requires": {
|
||||
"ajv": "^6.5.4"
|
||||
}
|
||||
},
|
||||
"proxy-addr": {
|
||||
"version": "2.0.7",
|
||||
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz",
|
||||
@ -2772,6 +2987,11 @@
|
||||
"ipaddr.js": "1.9.1"
|
||||
}
|
||||
},
|
||||
"punycode": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",
|
||||
"integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A=="
|
||||
},
|
||||
"qs": {
|
||||
"version": "6.9.7",
|
||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.9.7.tgz",
|
||||
@ -2821,6 +3041,16 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"readable-stream": {
|
||||
"version": "3.6.0",
|
||||
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz",
|
||||
"integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==",
|
||||
"requires": {
|
||||
"inherits": "^2.0.3",
|
||||
"string_decoder": "^1.1.1",
|
||||
"util-deprecate": "^1.0.1"
|
||||
}
|
||||
},
|
||||
"require-directory": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",
|
||||
@ -2837,6 +3067,11 @@
|
||||
"supports-preserve-symlinks-flag": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"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=="
|
||||
},
|
||||
"safer-buffer": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
|
||||
@ -2939,6 +3174,14 @@
|
||||
"resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz",
|
||||
"integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow="
|
||||
},
|
||||
"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==",
|
||||
"requires": {
|
||||
"safe-buffer": "~5.2.0"
|
||||
}
|
||||
},
|
||||
"string-width": {
|
||||
"version": "4.2.3",
|
||||
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz",
|
||||
@ -2994,11 +3237,6 @@
|
||||
"integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=",
|
||||
"dev": true
|
||||
},
|
||||
"strip-json-comments": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-4.0.0.tgz",
|
||||
"integrity": "sha512-LzWcbfMbAsEDTRmhjWIioe8GcDRl0fa35YMXFoJKDdiD/quGFmjJjdgPjFJJNwCMaLyQqFIDqCdHD2V4HfLgYA=="
|
||||
},
|
||||
"supports-preserve-symlinks-flag": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz",
|
||||
@ -3041,6 +3279,19 @@
|
||||
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
|
||||
"integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw="
|
||||
},
|
||||
"uri-js": {
|
||||
"version": "4.4.1",
|
||||
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz",
|
||||
"integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==",
|
||||
"requires": {
|
||||
"punycode": "^2.1.0"
|
||||
}
|
||||
},
|
||||
"util-deprecate": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
|
||||
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
|
||||
},
|
||||
"utils-merge": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
|
||||
|
@ -28,10 +28,10 @@
|
||||
"package.json",
|
||||
"package-lock.json"
|
||||
],
|
||||
"exec": "node --trace-warnings ./bin/BdsManeger.js start --Develop"
|
||||
"exec": "npm run build:cjs && node --trace-warnings ./dist/cjs/index.js start --Develop"
|
||||
},
|
||||
"bin": {
|
||||
"bds_maneger": "bin/BdsManeger.js"
|
||||
"bds_maneger": "dist/cjs/index.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@ -66,13 +66,16 @@
|
||||
"adm-zip": "^0.5.9",
|
||||
"axios": "^0.26.1",
|
||||
"cors": "^2.8.5",
|
||||
"cron": "^1.8.2",
|
||||
"express": "^4.17.3",
|
||||
"strip-json-comments": "^4.0.0",
|
||||
"prismarine-nbt": "^2.2.1",
|
||||
"properties-to-json": "^0.2.1",
|
||||
"typescript": "^4.6.2",
|
||||
"yargs": "^17.4.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/adm-zip": "^0.4.34",
|
||||
"@types/cron": "^1.7.3",
|
||||
"@types/express": "^4.17.13",
|
||||
"@types/node": "^17.0.22",
|
||||
"@types/yargs": "^17.0.10",
|
||||
|
@ -9,7 +9,9 @@ import os from "os";
|
||||
import path from "path";
|
||||
import admZip from "adm-zip";
|
||||
import fs from "fs";
|
||||
import stripJsonComments from "strip-json-comments";
|
||||
// import stripJsonComments from "strip-json-comments";
|
||||
|
||||
const stripJsonComments = (data) => data.replace(/\\"|"(?:\\"|[^"])*"|(\/\/.*|\/\*[\s\S]*?\*\/)/g, (m, g) => g ? "" : m);
|
||||
|
||||
function ensureFileSync(pathFile: string){
|
||||
if (!fs.existsSync(pathFile)){
|
||||
@ -116,7 +118,7 @@ export function addonInstaller() {
|
||||
|
||||
// Gather pack details from the manifest.json file
|
||||
let manifest = await extractPackManifest(packPath);
|
||||
let name = manifest.header.name.replace(/\W/g, "");
|
||||
// let name = manifest.header.name.replace(/\W/g, "");
|
||||
let uuid = manifest.header.uuid;
|
||||
let version = manifest.header.version;
|
||||
if (!version) version = manifest.header.modules[0].version;
|
||||
@ -129,7 +131,7 @@ export function addonInstaller() {
|
||||
throw new Error("Unable to install pack. Unknown pack manifest format.\n" + packPath);
|
||||
}
|
||||
|
||||
console.log("BDSAddonInstaller - Installing " + name + "...");
|
||||
// console.log("BDSAddonInstaller - Installing " + name + "...");
|
||||
|
||||
// Check if already installed
|
||||
let installedWorldPack, installedServerPack = null;
|
||||
@ -147,11 +149,11 @@ export function addonInstaller() {
|
||||
if (installedWorldPack && installedWorldPack.version.toString() != version.toString()) upToDate = false;
|
||||
if (installedServerPack && installedServerPack.version.toString() != version.toString()) upToDate = false;
|
||||
if (upToDate) {
|
||||
console.log(`BDSAddonInstaller - The ${name} pack is already installed and up to date.`);
|
||||
// console.log(`BDSAddonInstaller - The ${name} pack is already installed and up to date.`);
|
||||
return;
|
||||
}else{
|
||||
// uninstall pack if not up to date
|
||||
console.log("BDSAddonInstaller - Uninstalling old version of pack");
|
||||
// console.log("BDSAddonInstaller - Uninstalling old version of pack");
|
||||
if (installedServerPack) await uninstallServerPack(uuid, installedServerPack.location);
|
||||
if (installedWorldPack && type == "resources") await uninstallWorldResource(uuid, installedWorldPack.location);
|
||||
if (installedWorldPack && type == "data") await uninstallWorldBehavior(uuid, installedWorldPack.location);
|
||||
@ -159,7 +161,7 @@ export function addonInstaller() {
|
||||
}
|
||||
|
||||
await installPack(packPath, manifest);
|
||||
console.log("BDSAddonInstaller - Successfully installed the " + name + " pack.");
|
||||
// console.log("BDSAddonInstaller - Successfully installed the " + name + " pack.");
|
||||
|
||||
}
|
||||
|
||||
@ -180,7 +182,7 @@ export function addonInstaller() {
|
||||
let location = path.join(addonPath, pack);
|
||||
await this.installAddon(location);
|
||||
}catch(err) {
|
||||
console.error("BDSAddonInstaller - " + err);
|
||||
// console.error("BDSAddonInstaller - " + err);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -254,7 +256,7 @@ async function installPack(packPath, manifest) {
|
||||
* NOTE: This is why only packs found installed to the world will be removed from the server.
|
||||
*/
|
||||
async function uninstallAllWorldPacks() {
|
||||
console.log("BDSAddonInstaller - Uninstalling all packs found saved to world.");
|
||||
// console.log("BDSAddonInstaller - Uninstalling all packs found saved to world.");
|
||||
|
||||
// Uninstall all cached world resource packs.
|
||||
for (let pack of installedWorldResources.values()) {
|
||||
@ -295,13 +297,13 @@ async function uninstallWorldResource(uuid, location) {
|
||||
if (packIndex != -1) {
|
||||
worldResourcesJSON.splice(packIndex, 1);
|
||||
fs.writeFileSync(worldResourcesJsonPath, JSON.stringify(worldResourcesJSON, undefined, 2));
|
||||
console.log(`BDSAddonInstaller - Removed ${uuid} from world resource packs JSON.`);
|
||||
// console.log(`BDSAddonInstaller - Removed ${uuid} from world resource packs JSON.`);
|
||||
}
|
||||
|
||||
// Delete the provided pack path.
|
||||
if (fs.existsSync(location)) {
|
||||
await fs.promises.rm(location, {recursive: true});
|
||||
console.log(`BDSAddonInstaller - Removed ${location}`);
|
||||
// console.log(`BDSAddonInstaller - Removed ${location}`);
|
||||
}
|
||||
}
|
||||
|
||||
@ -319,13 +321,13 @@ async function uninstallWorldBehavior(uuid, location) {
|
||||
if (packIndex != -1) {
|
||||
worldBehaviorsJSON.splice(packIndex, 1);
|
||||
fs.writeFileSync(worldBehaviorsJsonPath, JSON.stringify(worldBehaviorsJSON, undefined, 2));
|
||||
console.log(`BDSAddonInstaller - Removed ${uuid} from world behavior packs JSON.`);
|
||||
// console.log(`BDSAddonInstaller - Removed ${uuid} from world behavior packs JSON.`);
|
||||
}
|
||||
|
||||
// Delete the provided pack path.
|
||||
if (fs.existsSync(location)) {
|
||||
fs.promises.rm(location);
|
||||
console.log(`BDSAddonInstaller - Removed ${location}`);
|
||||
// console.log(`BDSAddonInstaller - Removed ${location}`);
|
||||
}
|
||||
}
|
||||
|
||||
@ -343,13 +345,13 @@ async function uninstallServerPack (uuid, location) {
|
||||
if (packIndex != -1) {
|
||||
serverPacksJSON.splice(packIndex, 1);
|
||||
fs.writeFileSync(serverPacksJsonPath, JSON.stringify(serverPacksJSON, undefined, 2));
|
||||
console.log(`BDSAddonInstaller - Removed ${uuid} from server packs JSON.`);
|
||||
// console.log(`BDSAddonInstaller - Removed ${uuid} from server packs JSON.`);
|
||||
}
|
||||
|
||||
// Delete the provided pack path.
|
||||
if (fs.existsSync(location)) {
|
||||
fs.promises.rm(location);
|
||||
console.log(`BDSAddonInstaller - Removed ${location}`);
|
||||
// console.log(`BDSAddonInstaller - Removed ${location}`);
|
||||
}
|
||||
}
|
||||
|
||||
@ -365,7 +367,7 @@ async function extractAddonPacks(addonPath) {
|
||||
// Validate the provided path is to an addon.
|
||||
if (!fs.existsSync(addonPath)) throw new Error("Unable to extract packs from addon. Invalid file path provided: " + addonPath);
|
||||
if (!addonPath.endsWith('.mcaddon')) throw new Error('Unable to extract packs from addon. The provided file is not an addon. ' + addonPath);
|
||||
console.log("BDSAddonInstaller - Extracting packs from " + addonPath);
|
||||
// console.log("BDSAddonInstaller - Extracting packs from " + addonPath);
|
||||
|
||||
// Extract file path and name info for saving the extracted packs.
|
||||
let addonName = path.basename(addonPath).replace(".mcaddon", "");
|
||||
@ -379,7 +381,7 @@ async function extractAddonPacks(addonPath) {
|
||||
|
||||
// Move addon packs from temporary location to BDS-Addon directory.
|
||||
for (let pack of packs) {
|
||||
console.log(`BDSAddonInstaller - Extracting ${pack} from ${addonName}.`);
|
||||
// console.log(`BDSAddonInstaller - Extracting ${pack} from ${addonName}.`);
|
||||
|
||||
// If the mcpack is already packaged, move the file.
|
||||
if (pack.endsWith(".mcpack")) {
|
||||
@ -388,7 +390,7 @@ async function extractAddonPacks(addonPath) {
|
||||
let packDestination = path.join(dirPath, packName);
|
||||
await fs.promises.rename(packFile, packDestination);
|
||||
results.push(packDestination);
|
||||
console.log("BDSAddonInstaller - Extracted " + packDestination);
|
||||
// console.log("BDSAddonInstaller - Extracted " + packDestination);
|
||||
}else {
|
||||
// The pack still needs to be zipped and then moved.
|
||||
let packName = addonName + "_" + pack + ".mcpack";
|
||||
@ -396,7 +398,7 @@ async function extractAddonPacks(addonPath) {
|
||||
let packDestination = path.join(dirPath, packName);
|
||||
await promiseZip(packFolder, packDestination);
|
||||
results.push(packDestination);
|
||||
console.log("BDSAddonInstaller - Extracted " + packDestination);
|
||||
// console.log("BDSAddonInstaller - Extracted " + packDestination);
|
||||
}
|
||||
}
|
||||
|
||||
@ -417,7 +419,7 @@ function extractPackManifest(packPath) {
|
||||
// Validate the provided pack (path exists and file is correct type)
|
||||
if (!fs.existsSync(packPath)) throw new Error("Unable to extract manifest file. Invalid file path provided: " + packPath);
|
||||
if (!packPath.endsWith(".mcpack")) throw new Error("Unable to extract manifest file. The provided file is not a pack. " + packPath);
|
||||
console.log("BDSAddonInstaller - Reading manifest data from " + packPath);
|
||||
// console.log("BDSAddonInstaller - Reading manifest data from " + packPath);
|
||||
|
||||
// Locate the manifest file in the zipped pack.
|
||||
let archive = new admZip(packPath);
|
||||
@ -436,7 +438,7 @@ function extractPackManifest(packPath) {
|
||||
*/
|
||||
function readWorldName() {
|
||||
let propertyFile = path.join(serverPath, "server.properties");
|
||||
console.log("BDSAddonInstaller - Reading world name from " + propertyFile);
|
||||
// console.log("BDSAddonInstaller - Reading world name from " + propertyFile);
|
||||
if (!fs.existsSync(propertyFile)) throw new Error("Unable to locate server properties @ " + propertyFile);
|
||||
let properties = fs.readFileSync(propertyFile);
|
||||
let levelName = properties.toString().match(/level-name=.*/);
|
||||
@ -467,14 +469,14 @@ function mapInstalledPacks(directory) {
|
||||
let subdirectories = fs.readdirSync(directory);
|
||||
subdirectories.forEach(subdirectory => {
|
||||
let location = path.join(directory, subdirectory);
|
||||
console.log("BDSAddonInstaller - Reading manifest data from " + location);
|
||||
// console.log("BDSAddonInstaller - Reading manifest data from " + location);
|
||||
|
||||
// Locate the directory containing the pack manifest.
|
||||
let manifestLocation = findFilesSync(["manifest.json", "pack_manifest.json"], location);
|
||||
if (!manifestLocation) {
|
||||
console.error(manifestLocation);
|
||||
console.warn("BDSAddonInstaller - Unable to locate manifest file of installed pack.");
|
||||
console.warn("BDSAddonInstaller - Installed location: " + location);
|
||||
// console.error(manifestLocation);
|
||||
// console.warn("BDSAddonInstaller - Unable to locate manifest file of installed pack.");
|
||||
// console.warn("BDSAddonInstaller - Installed location: " + location);
|
||||
return;
|
||||
}
|
||||
|
||||
|
13
src/api.ts
13
src/api.ts
@ -8,9 +8,7 @@ app.use(express.urlencoded({extended: true}));
|
||||
app.use(express.json());
|
||||
app.use((req, res, next) => {
|
||||
res.json = (body) => {
|
||||
if (!res.get("Content-Type")) {
|
||||
res.set("Content-Type", "application/json");
|
||||
}
|
||||
res.send(JSON.stringify(body, (key, value) => {
|
||||
if (typeof value === "bigint") value = value.toString();
|
||||
else if (isDate(value)) value = value.toString();
|
||||
@ -34,6 +32,17 @@ app.all("/", ({res}) => res.json((() => {
|
||||
return data;
|
||||
})()));
|
||||
|
||||
// Session info
|
||||
app.get("/:SessionID", (req, res) => {
|
||||
const SessionID: string = req.params.SessionID;
|
||||
const Sessions = ServerManeger.getSessions();
|
||||
if (!Sessions[SessionID]) return res.status(404).send({message: "Session not found"});
|
||||
const filter = Object.keys(Sessions[SessionID]).filter(a => !(a === "addonManeger" || a ==="commands"));
|
||||
const data = {};
|
||||
filter.forEach(key => data[key] = Sessions[SessionID][key]);
|
||||
return res.json(data);
|
||||
});
|
||||
|
||||
// Get Players
|
||||
app.get("/:SessionID/player", (req, res) => {
|
||||
const SessionID: string = req.params.SessionID;
|
||||
|
@ -21,8 +21,8 @@ const Yargs = yargs(process.argv.slice(2)).command("download", "Download and Ins
|
||||
console.log("Sucess to download server");
|
||||
console.info("Release date: %s", `${res.Date.getDate()}/${res.Date.getMonth()+1}/${res.Date.getFullYear()}`);
|
||||
});
|
||||
}).command("start", "Start Server", yargs => {
|
||||
const options = yargs.option("platform", {
|
||||
}).command("start", "Start Server", async yargs => {
|
||||
const options = await yargs.option("platform", {
|
||||
alias: "p",
|
||||
describe: "Bds Core Platform",
|
||||
choices: ["bedrock", "java", "pocketmine", "spigot", "dragonfly"],
|
||||
@ -32,10 +32,10 @@ const Yargs = yargs(process.argv.slice(2)).command("download", "Download and Ins
|
||||
describe: "Bds Core API port listen",
|
||||
default: "3000",
|
||||
type: "number"
|
||||
}).parseSync();
|
||||
}).parseAsync();
|
||||
const Platform = options.platform as bdsTypes.Platform;
|
||||
BdsCore.API.listen(options.api);
|
||||
const Server = BdsCore.Server.Start(Platform);
|
||||
const Server = await BdsCore.Server.Start(Platform);
|
||||
console.log("Session ID: %s", Server.id);
|
||||
Server.on("all", data => process.stdout.write(data));
|
||||
const Input = readline.createInterface({input: process.stdin,output: process.stdout})
|
||||
@ -48,4 +48,4 @@ const Yargs = yargs(process.argv.slice(2)).command("download", "Download and Ins
|
||||
Yargs.showHelp();
|
||||
}
|
||||
}).help().version(false);
|
||||
Yargs.parseSync();
|
||||
Yargs.parseAsync();
|
@ -3,16 +3,21 @@ import fs from "fs";
|
||||
import os from "os";
|
||||
import crypto from "crypto";
|
||||
import child_process from "child_process";
|
||||
import node_cron from "cron";
|
||||
import addon from "./addons/index";
|
||||
import * as bdsBackup from "./backup";
|
||||
import * as serverConfig from "./serverConfig";
|
||||
import * as bdsTypes from "./globalType";
|
||||
|
||||
type BdsSession = {
|
||||
id: string;
|
||||
startDate: Date;
|
||||
seed?: string;
|
||||
addonManeger: {
|
||||
installAddon: (packPath: string) => Promise<void>;
|
||||
installAllAddons: (removeOldPacks: boolean) => Promise<void>;
|
||||
};
|
||||
creteBackup: (crontime: string|Date) => void;
|
||||
on: (from: "all"|"stdout"|"stderr", callback: (data: string) => void) => void;
|
||||
exit: (callback: (code: number, signal: string) => void) => void;
|
||||
getPlayer: () => {[player: string]: {action: "connect"|"disconnect"|"unknown"; date: Date; history: Array<{action: "connect"|"disconnect"|"unknown"; date: Date}>}};
|
||||
@ -28,7 +33,7 @@ const Sessions: {[Session: string]: BdsSession} = {};
|
||||
export function getSessions() {return Sessions;}
|
||||
|
||||
// Start Server
|
||||
export function Start(Platform: bdsTypes.Platform): BdsSession {
|
||||
export async function Start(Platform: bdsTypes.Platform): Promise<BdsSession> {
|
||||
const ServerPath = path.resolve(process.env.SERVERPATH||path.join(os.homedir(), "bds_core/servers"), Platform);
|
||||
if (!(fs.existsSync(ServerPath))) fs.mkdirSync(ServerPath, {recursive: true});
|
||||
const Process: {command: string; args: Array<string>; env: {[env: string]: string}; cwd: string;} = {
|
||||
@ -141,13 +146,21 @@ export function Start(Platform: bdsTypes.Platform): BdsSession {
|
||||
}
|
||||
|
||||
// Return Session
|
||||
const Seesion = {
|
||||
const Seesion: BdsSession = {
|
||||
id: crypto.randomUUID(),
|
||||
startDate: StartDate,
|
||||
seed: undefined,
|
||||
addonManeger: {
|
||||
installAddon: async function (packPath: string) {console.log(packPath); return;},
|
||||
installAllAddons: async function (removeOldPacks: boolean) {console.log(removeOldPacks); return;}
|
||||
},
|
||||
creteBackup: (crontime: string|Date) => {
|
||||
const cronJob = new node_cron.CronJob(crontime, async () => {
|
||||
bdsBackup.CreateBackup(Platform);
|
||||
});
|
||||
cronJob.start();
|
||||
return;
|
||||
},
|
||||
on: onLog,
|
||||
exit: onExit,
|
||||
ports: () => ports,
|
||||
@ -157,7 +170,11 @@ export function Start(Platform: bdsTypes.Platform): BdsSession {
|
||||
tpPlayer: tpPlayer,
|
||||
}
|
||||
};
|
||||
if (Platform === "bedrock") Seesion.addonManeger = addon.bedrock.addonInstaller();
|
||||
if (Platform === "bedrock") {
|
||||
Seesion.addonManeger = addon.bedrock.addonInstaller();
|
||||
const bedrockConfig = await serverConfig.parseConfig(Platform);
|
||||
Seesion.seed = bedrockConfig.nbt.parsed.value.RandomSeed.value.toString();
|
||||
}
|
||||
const logFile = path.resolve(ServerPath, `../log/${Seesion.id}.log`);
|
||||
if(!(fs.existsSync(path.parse(logFile).dir))) fs.mkdirSync(path.parse(logFile).dir, {recursive: true});
|
||||
const logStream = fs.createWriteStream(logFile, {flags: "w+"});
|
||||
|
44
src/serverConfig.ts
Normal file
44
src/serverConfig.ts
Normal file
@ -0,0 +1,44 @@
|
||||
import path from "path";
|
||||
import os from "os";
|
||||
import fs from "fs";
|
||||
import * as prismarineNbt from "prismarine-nbt";
|
||||
import properties_to_json from "properties-to-json";
|
||||
import * as bdsType from "./globalType";
|
||||
|
||||
type BdsConfigGet = {
|
||||
world: string;
|
||||
description: string;
|
||||
gamemode: string;
|
||||
difficulty: "peaceful"|"easy"|"normal"|"hard";
|
||||
players: number;
|
||||
whitelist: true|false;
|
||||
portv4: number;
|
||||
portv6: number;
|
||||
nbt?: {
|
||||
parsed: prismarineNbt.NBT;
|
||||
type: prismarineNbt.NBTFormat;
|
||||
metadata: prismarineNbt.Metadata;
|
||||
}|undefined;
|
||||
}
|
||||
|
||||
export async function parseConfig(Platform: bdsType.Platform): Promise<BdsConfigGet> {
|
||||
const serverPath = path.resolve(process.env.SERVERPATH||path.join(os.homedir(), "bds_core/servers"), Platform);
|
||||
if (Platform === "bedrock") {
|
||||
const bedrockConfigPath = path.join(serverPath, "server.properties");
|
||||
if (!(fs.existsSync(bedrockConfigPath))) throw new Error("Bedrock server config not found");
|
||||
const bedrockConfig = properties_to_json(fs.readFileSync(bedrockConfigPath, "utf8"));
|
||||
const bedrockConfigNbtPath = path.join(serverPath, "worlds", bedrockConfig["level-name"], "level.dat");
|
||||
return {
|
||||
world: bedrockConfig["level-name"],
|
||||
description: bedrockConfig["server-name"],
|
||||
difficulty: bedrockConfig["difficulty"],
|
||||
gamemode: bedrockConfig["gamemode"],
|
||||
players: parseInt(bedrockConfig["max-players"]),
|
||||
whitelist: bedrockConfig["white-list"] === "true",
|
||||
portv4: parseInt(bedrockConfig["server-port"]),
|
||||
portv6: parseInt(bedrockConfig["server-portv6"]),
|
||||
nbt: (fs.existsSync(bedrockConfigNbtPath)) ? await prismarineNbt.parse(fs.readFileSync(bedrockConfigNbtPath)) : undefined
|
||||
};
|
||||
}
|
||||
throw new Error("Platform not supported");
|
||||
}
|
Reference in New Issue
Block a user