Dragonfly full support #199
@ -21,7 +21,8 @@
|
|||||||
],
|
],
|
||||||
"java": [],
|
"java": [],
|
||||||
"pocketmine": [],
|
"pocketmine": [],
|
||||||
"spigot": []
|
"spigot": [],
|
||||||
|
"dragonfly": []
|
||||||
},
|
},
|
||||||
"StartedServer": {
|
"StartedServer": {
|
||||||
"bedrock": {
|
"bedrock": {
|
||||||
@ -39,12 +40,22 @@
|
|||||||
"spigot": {
|
"spigot": {
|
||||||
"value": null,
|
"value": null,
|
||||||
"regex": false
|
"regex": false
|
||||||
|
},
|
||||||
|
"dragonfly": {
|
||||||
|
"value": null,
|
||||||
|
"regex": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Servers": {
|
"Servers": {
|
||||||
"bedrock": {
|
"bedrock": {
|
||||||
"stop": "stop",
|
"stop": {
|
||||||
"op": "op \"{{Player}}\"",
|
"value": "stop",
|
||||||
|
"type": "command"
|
||||||
|
},
|
||||||
|
"op": {
|
||||||
|
"value": "op \"{{}}\"",
|
||||||
|
"type": "command"
|
||||||
|
},
|
||||||
"deop": "op \"{{Player}}\"",
|
"deop": "op \"{{Player}}\"",
|
||||||
"ban": "tp \"{{Player}}\" ~ ~99999 ~",
|
"ban": "tp \"{{Player}}\" ~ ~99999 ~",
|
||||||
"kick": "kick \"{{Player}}\" \"{{Text}}\"",
|
"kick": "kick \"{{Player}}\" \"{{Text}}\"",
|
||||||
@ -61,13 +72,64 @@
|
|||||||
"say": "say {{Text}}"
|
"say": "say {{Text}}"
|
||||||
},
|
},
|
||||||
"pocketmine": {
|
"pocketmine": {
|
||||||
"stop": "stop",
|
"stop": {
|
||||||
"op": "op {{Player}}",
|
"value": "stop",
|
||||||
"deop": "op {{Player}}",
|
"type": "command"
|
||||||
"ban": "ban {{Player}}",
|
},
|
||||||
"kick": "kick {{Player}}",
|
"op": {
|
||||||
"tp": "tp \"{{Player}}\" {{X}} {{Y}} {{X}}",
|
"value": "op {{Player}}",
|
||||||
"say": "say {{Text}}"
|
"type": "command"
|
||||||
|
},
|
||||||
|
"deop": {
|
||||||
|
"value": "deop {{Player}}",
|
||||||
|
"type": "command"
|
||||||
|
},
|
||||||
|
"ban": {
|
||||||
|
"value": "ban {{Player}}",
|
||||||
|
"type": "command"
|
||||||
|
},
|
||||||
|
"kick": {
|
||||||
|
"value": "kick {{Player}}",
|
||||||
|
"type": "command"
|
||||||
|
},
|
||||||
|
"tp": {
|
||||||
|
"value": "tp {{Player}} {{X}} {{Y}} {{X}}",
|
||||||
|
"type": "command"
|
||||||
|
},
|
||||||
|
"say": {
|
||||||
|
"value": "say {{Text}}",
|
||||||
|
"type": "command"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"dragonfly": {
|
||||||
|
"stop": {
|
||||||
|
"value": "SIGNKILL",
|
||||||
|
"type": "process"
|
||||||
|
},
|
||||||
|
"op": {
|
||||||
|
"value": null,
|
||||||
|
"type": null
|
||||||
|
},
|
||||||
|
"deop": {
|
||||||
|
"value": null,
|
||||||
|
"type": null
|
||||||
|
},
|
||||||
|
"ban": {
|
||||||
|
"value": null,
|
||||||
|
"type": null
|
||||||
|
},
|
||||||
|
"kick": {
|
||||||
|
"value": null,
|
||||||
|
"type": null
|
||||||
|
},
|
||||||
|
"tp": {
|
||||||
|
"value": null,
|
||||||
|
"type": null
|
||||||
|
},
|
||||||
|
"say": {
|
||||||
|
"value": null,
|
||||||
|
"type": null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"contributors": [
|
"contributors": [
|
||||||
|
@ -83,4 +83,3 @@ async function Command() {
|
|||||||
|
|
||||||
module.exports.Command = Command;
|
module.exports.Command = Command;
|
||||||
module.exports.TpMenu = TpMenu;
|
module.exports.TpMenu = TpMenu;
|
||||||
TpMenu();
|
|
@ -14,7 +14,8 @@ const ProcessArgs = require("minimist")(process.argv.slice(2));
|
|||||||
const BdsCore = require("../index");
|
const BdsCore = require("../index");
|
||||||
const BdsReq = require("../lib/Requests");
|
const BdsReq = require("../lib/Requests");
|
||||||
const BdsExtraInfo = require("../BdsManegerInfo.json");
|
const BdsExtraInfo = require("../BdsManegerInfo.json");
|
||||||
const commandExits = require("../lib/commandExist")
|
const commandExits = require("../lib/commandExist");
|
||||||
|
const BdsMenus = require("./bds_maneger/menus");
|
||||||
|
|
||||||
// Async functiona
|
// Async functiona
|
||||||
async function Runner() {
|
async function Runner() {
|
||||||
@ -100,16 +101,16 @@ async function Runner() {
|
|||||||
serverline.setPrompt("Command > ");
|
serverline.setPrompt("Command > ");
|
||||||
serverline.on("line", async function(line) {
|
serverline.on("line", async function(line) {
|
||||||
if (/^@/.test(line)) {
|
if (/^@/.test(line)) {
|
||||||
console.log("🤪It's not working yet!");
|
serverline.close();
|
||||||
// const command = (await inquirer.prompt([
|
if (/^@stop/.test(line)) {
|
||||||
// {
|
BdsCoreStart.stop();
|
||||||
// type: "list",
|
return;
|
||||||
// name: "command",
|
} else if (/^@tp/.test(line)) {
|
||||||
// message: "Select the command to run",
|
await BdsMenus.TpMenu();
|
||||||
// choices: ["tp", "stop", "restart", "update", "info", "download"]
|
}
|
||||||
// }
|
return serverline.init();
|
||||||
// ])).command;
|
|
||||||
} else BdsCoreStart.command(line);
|
} else BdsCoreStart.command(line);
|
||||||
});
|
});
|
||||||
|
if (!(ProcessArgs["no-api"])) BdsCore.api()
|
||||||
}
|
}
|
||||||
Runner();
|
Runner();
|
||||||
|
@ -2,6 +2,7 @@ const { join, resolve, basename } = require("path");
|
|||||||
const { existsSync, writeFileSync, mkdirSync, readFileSync } = require("fs");
|
const { existsSync, writeFileSync, mkdirSync, readFileSync } = require("fs");
|
||||||
const { homedir } = require("os");
|
const { homedir } = require("os");
|
||||||
const yaml = require("js-yaml");
|
const yaml = require("js-yaml");
|
||||||
|
const deepmerge = require("deepmerge");
|
||||||
|
|
||||||
// PATHs
|
// PATHs
|
||||||
const home = homedir();
|
const home = homedir();
|
||||||
@ -37,6 +38,7 @@ var Config = {
|
|||||||
java: null,
|
java: null,
|
||||||
pocketmine: null,
|
pocketmine: null,
|
||||||
spigot: null,
|
spigot: null,
|
||||||
|
dragonfly: null
|
||||||
},
|
},
|
||||||
Settings: {
|
Settings: {
|
||||||
java: {
|
java: {
|
||||||
@ -105,7 +107,7 @@ const ConfigPath = join(resolve(homedir(), "bds_core"), "BdsConfig.yaml")
|
|||||||
const SaveConfig = () => writeFileSync(ConfigPath, yaml.dump(Config));
|
const SaveConfig = () => writeFileSync(ConfigPath, yaml.dump(Config));
|
||||||
process.on("exit", () => SaveConfig());
|
process.on("exit", () => SaveConfig());
|
||||||
|
|
||||||
if (existsSync(ConfigPath)) Config = yaml.load(readFileSync(ConfigPath, "utf8"));
|
if (existsSync(ConfigPath)) Config = deepmerge(Config, yaml.load(readFileSync(ConfigPath, "utf8")));
|
||||||
else writeFileSync(ConfigPath, yaml.dump(Config))
|
else writeFileSync(ConfigPath, yaml.dump(Config))
|
||||||
|
|
||||||
// Paths
|
// Paths
|
||||||
|
@ -3,6 +3,7 @@ const { readdirSync } = require("fs");
|
|||||||
const { execSync } = require("child_process");
|
const { execSync } = require("child_process");
|
||||||
const commadExist = require("./commandExist");
|
const commadExist = require("./commandExist");
|
||||||
const Request = require("./Requests");
|
const Request = require("./Requests");
|
||||||
|
const bds = require("../index");
|
||||||
|
|
||||||
async function CheckSystemAsync() {
|
async function CheckSystemAsync() {
|
||||||
const
|
const
|
||||||
@ -14,12 +15,15 @@ async function CheckSystemAsync() {
|
|||||||
bedrock: true,
|
bedrock: true,
|
||||||
pocketmine: true,
|
pocketmine: true,
|
||||||
java: commadExist("java"),
|
java: commadExist("java"),
|
||||||
dragonfly: commadExist("go"),
|
dragonfly: true
|
||||||
};
|
};
|
||||||
|
|
||||||
// check php bin
|
// check php bin
|
||||||
if ((PHPBin[process.platform] || {})[arch]) valid_platform["pocketmine"] = true;
|
if ((PHPBin[process.platform] || {})[arch]) valid_platform["pocketmine"] = true;
|
||||||
else valid_platform["pocketmine"] = false;
|
else valid_platform["pocketmine"] = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (!(Servers.dragonfly[Servers.latest.dragonfly][process.platform][bds.arch])) valid_platform["dragonfly"] = false;
|
||||||
|
|
||||||
// SoSystem X
|
// SoSystem X
|
||||||
if (process.platform == "win32") {
|
if (process.platform == "win32") {
|
||||||
|
25
package-lock.json
generated
25
package-lock.json
generated
@ -16,11 +16,13 @@
|
|||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@azure/storage-blob": "^12.6.0",
|
"@azure/storage-blob": "^12.6.0",
|
||||||
|
"@iarna/toml": "^2.2.5",
|
||||||
"adm-zip": "^0.5.1",
|
"adm-zip": "^0.5.1",
|
||||||
"body-parser": "^1.19.0",
|
"body-parser": "^1.19.0",
|
||||||
"cli-color": "^2.0.0",
|
"cli-color": "^2.0.0",
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
"cron": "^1.8.2",
|
"cron": "^1.8.2",
|
||||||
|
"deepmerge": "^4.2.2",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"express-fileupload": "^1.2.1",
|
"express-fileupload": "^1.2.1",
|
||||||
"express-prettify": "^0.1.1",
|
"express-prettify": "^0.1.1",
|
||||||
@ -395,6 +397,11 @@
|
|||||||
"integrity": "sha512-wdppn25U8z/2yiaT6YGquE6X8sSv7hNMWSXYSSU1jGv/yd6XqjXgTDJ8KP4NgjTXfJ3GbRjeeb8RTV7a/VpM+w==",
|
"integrity": "sha512-wdppn25U8z/2yiaT6YGquE6X8sSv7hNMWSXYSSU1jGv/yd6XqjXgTDJ8KP4NgjTXfJ3GbRjeeb8RTV7a/VpM+w==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"node_modules/@iarna/toml": {
|
||||||
|
"version": "2.2.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/@iarna/toml/-/toml-2.2.5.tgz",
|
||||||
|
"integrity": "sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg=="
|
||||||
|
},
|
||||||
"node_modules/@opentelemetry/api": {
|
"node_modules/@opentelemetry/api": {
|
||||||
"version": "1.0.3",
|
"version": "1.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-1.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-1.0.3.tgz",
|
||||||
@ -1350,6 +1357,14 @@
|
|||||||
"integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==",
|
"integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"node_modules/deepmerge": {
|
||||||
|
"version": "4.2.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.2.2.tgz",
|
||||||
|
"integrity": "sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg==",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.10.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/defaults": {
|
"node_modules/defaults": {
|
||||||
"version": "1.0.3",
|
"version": "1.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.3.tgz",
|
||||||
@ -5983,6 +5998,11 @@
|
|||||||
"integrity": "sha512-wdppn25U8z/2yiaT6YGquE6X8sSv7hNMWSXYSSU1jGv/yd6XqjXgTDJ8KP4NgjTXfJ3GbRjeeb8RTV7a/VpM+w==",
|
"integrity": "sha512-wdppn25U8z/2yiaT6YGquE6X8sSv7hNMWSXYSSU1jGv/yd6XqjXgTDJ8KP4NgjTXfJ3GbRjeeb8RTV7a/VpM+w==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"@iarna/toml": {
|
||||||
|
"version": "2.2.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/@iarna/toml/-/toml-2.2.5.tgz",
|
||||||
|
"integrity": "sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg=="
|
||||||
|
},
|
||||||
"@opentelemetry/api": {
|
"@opentelemetry/api": {
|
||||||
"version": "1.0.3",
|
"version": "1.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-1.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-1.0.3.tgz",
|
||||||
@ -6714,6 +6734,11 @@
|
|||||||
"integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==",
|
"integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"deepmerge": {
|
||||||
|
"version": "4.2.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.2.2.tgz",
|
||||||
|
"integrity": "sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg=="
|
||||||
|
},
|
||||||
"defaults": {
|
"defaults": {
|
||||||
"version": "1.0.3",
|
"version": "1.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.3.tgz",
|
||||||
|
@ -54,11 +54,13 @@
|
|||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@azure/storage-blob": "^12.6.0",
|
"@azure/storage-blob": "^12.6.0",
|
||||||
|
"@iarna/toml": "^2.2.5",
|
||||||
"adm-zip": "^0.5.1",
|
"adm-zip": "^0.5.1",
|
||||||
"body-parser": "^1.19.0",
|
"body-parser": "^1.19.0",
|
||||||
"cli-color": "^2.0.0",
|
"cli-color": "^2.0.0",
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
"cron": "^1.8.2",
|
"cron": "^1.8.2",
|
||||||
|
"deepmerge": "^4.2.2",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"express-fileupload": "^1.2.1",
|
"express-fileupload": "^1.2.1",
|
||||||
"express-prettify": "^0.1.1",
|
"express-prettify": "^0.1.1",
|
||||||
|
@ -12,6 +12,7 @@ function Backup() {
|
|||||||
java: GetServerPaths("java"),
|
java: GetServerPaths("java"),
|
||||||
pocketmine: GetServerPaths("pocketmine"),
|
pocketmine: GetServerPaths("pocketmine"),
|
||||||
spigot: GetServerPaths("spigot"),
|
spigot: GetServerPaths("spigot"),
|
||||||
|
dragonfly: GetServerPaths("dragonfly"),
|
||||||
}
|
}
|
||||||
const CurrentDate = new Date();
|
const CurrentDate = new Date();
|
||||||
const ZipName = `Bds_Maneger_Core_Backups_${CurrentDate.getDate()}-${CurrentDate.getMonth()}-${CurrentDate.getFullYear()}.zip`
|
const ZipName = `Bds_Maneger_Core_Backups_${CurrentDate.getDate()}-${CurrentDate.getMonth()}-${CurrentDate.getFullYear()}.zip`
|
||||||
@ -35,6 +36,20 @@ function Backup() {
|
|||||||
for (let index of ["pocketmine.yml", "server.properties", "white-list.txt", "ops.txt", "banned-players.txt", "banned-ips.txt"]) if (fs.existsSync(join(Paths.pocketmine, index))) zip.addLocalFile(join(Paths.pocketmine, index), "pocketmine");
|
for (let index of ["pocketmine.yml", "server.properties", "white-list.txt", "ops.txt", "banned-players.txt", "banned-ips.txt"]) if (fs.existsSync(join(Paths.pocketmine, index))) zip.addLocalFile(join(Paths.pocketmine, index), "pocketmine");
|
||||||
} else console.info("Skipping the pocketmine as it was not installed");
|
} else console.info("Skipping the pocketmine as it was not installed");
|
||||||
|
|
||||||
|
// Spigot
|
||||||
|
if (fs.existsSync(join(Paths.spigot, "spigot.jar"))) {
|
||||||
|
if (fs.existsSync(join(Paths.spigot, "worlds"))) zip.addLocalFolder(join(Paths.spigot, "worlds"), join("Servers", "spigot", "worlds"));
|
||||||
|
for (let index of ["spigot.yml", "server.properties", "white-list.txt", "ops.txt", "banned-players.txt", "banned-ips.txt"]) if (fs.existsSync(join(Paths.spigot, index))) zip.addLocalFile(join(Paths.spigot, index), "spigot");
|
||||||
|
} else console.info("Skipping the spigot as it was not installed");
|
||||||
|
|
||||||
|
// Dragonfly
|
||||||
|
if (fs.existsSync(join(Paths.dragonfly, "config.toml"))) {
|
||||||
|
for (let index of fs.readdirSync(Paths.dragonfly).map(value => join(Paths.dragonfly, value))) {
|
||||||
|
if (fs.lstatSync(index).isDirectory()) zip.addLocalFolder(index, join("Servers", "dragonfly"));
|
||||||
|
else if (fs.lstatSync(index).isFile()) zip.addLocalFile(index, join("Servers", "dragonfly"));
|
||||||
|
}
|
||||||
|
} else console.info("Skipping the dragonfly as it was not installed");
|
||||||
|
|
||||||
// The Bds Maneger Core Backup
|
// The Bds Maneger Core Backup
|
||||||
for (let index of ["BdsConfig.yaml", "bds_tokens.json"]) if (fs.existsSync(join(bds_dir, index))) zip.addLocalFile(join(bds_dir, index));
|
for (let index of ["BdsConfig.yaml", "bds_tokens.json"]) if (fs.existsSync(join(bds_dir, index))) zip.addLocalFile(join(bds_dir, index));
|
||||||
|
|
||||||
|
@ -9,15 +9,14 @@ const commandExists = require("../lib/commandExist");
|
|||||||
const BdsDetect = require("./CheckKill").Detect;
|
const BdsDetect = require("./CheckKill").Detect;
|
||||||
const bds = require("../index");
|
const bds = require("../index");
|
||||||
const { GetServerPaths, GetPaths, GetServerSettings, GetPlatform, GetCronBackup } = require("../lib/BdsSettings");
|
const { GetServerPaths, GetPaths, GetServerSettings, GetPlatform, GetCronBackup } = require("../lib/BdsSettings");
|
||||||
const BdsInfo = require("../BdsManegerInfo.json");
|
|
||||||
const { Backup } = require("./BdsBackup");
|
const { Backup } = require("./BdsBackup");
|
||||||
|
|
||||||
// Set bdsexec functions
|
// Set bdsexec functions
|
||||||
global.BdsExecs = {};
|
global.BdsExecs = {};
|
||||||
|
|
||||||
function start() {
|
function start() {
|
||||||
if (BdsDetect()){let ErrorReturn = "You already have a server running"; console.warn(ErrorReturn); throw new Error(ErrorReturn);}
|
if (BdsDetect()) throw new Error("You already have a server running");
|
||||||
|
const CurrentBdsPlatform = GetPlatform();
|
||||||
const SetupCommands = {
|
const SetupCommands = {
|
||||||
command: String,
|
command: String,
|
||||||
args: [],
|
args: [],
|
||||||
@ -28,7 +27,7 @@ function start() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Minecraft Bedrock Oficial
|
// Minecraft Bedrock Oficial
|
||||||
if (GetPlatform() === "bedrock"){
|
if (CurrentBdsPlatform === "bedrock"){
|
||||||
// Check Darwin Platform
|
// Check Darwin Platform
|
||||||
if (process.platform === "darwin") throw new Error("Use a imagem Docker");
|
if (process.platform === "darwin") throw new Error("Use a imagem Docker");
|
||||||
|
|
||||||
@ -57,7 +56,7 @@ function start() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Minecraft Java Oficial
|
// Minecraft Java Oficial
|
||||||
else if (GetPlatform() === "java") {
|
else if (CurrentBdsPlatform === "java") {
|
||||||
const JavaConfig = GetServerSettings("java")
|
const JavaConfig = GetServerSettings("java")
|
||||||
|
|
||||||
// Checking if java is installed on the device
|
// Checking if java is installed on the device
|
||||||
@ -68,8 +67,30 @@ function start() {
|
|||||||
} else {require("open")(bds.package_json.docs_base + "Java-Download#windows"); throw new Error(`Open: ${bds.package_json.docs_base + "Java-Download#windows"}`)}
|
} else {require("open")(bds.package_json.docs_base + "Java-Download#windows"); throw new Error(`Open: ${bds.package_json.docs_base + "Java-Download#windows"}`)}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Spigot
|
||||||
|
else if (CurrentBdsPlatform === "spigot") {
|
||||||
|
const JavaConfig = GetServerSettings("java")
|
||||||
|
// Checking if java is installed on the device
|
||||||
|
if (commandExists("java")) {
|
||||||
|
SetupCommands.cwd = GetServerPaths("spigot");
|
||||||
|
SetupCommands.command = "java";
|
||||||
|
SetupCommands.args.push("-jar", `-Xms${JavaConfig.ram_mb}M`, `-Xmx${JavaConfig.ram_mb}M`, "spigot.jar", "nogui");
|
||||||
|
} else {require("open")(bds.package_json.docs_base + "Java-Download#windows"); throw new Error(`Open: ${bds.package_json.docs_base + "Java-Download#windows"}`)}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dragonfly
|
||||||
|
else if (CurrentBdsPlatform === "dragonfly") {
|
||||||
|
SetupCommands.cwd = GetServerPaths("dragonfly");
|
||||||
|
if (process.platform === "win32") {
|
||||||
|
SetupCommands.command = "Dragonfly.exe";
|
||||||
|
} else {
|
||||||
|
SetupCommands.command = "./Dragonfly";
|
||||||
|
child_process.execFileSync("chmod", ["a+x", SetupCommands.command], {cwd: SetupCommands.cwd});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Minecraft Bedrock (Pocketmine-MP)
|
// Minecraft Bedrock (Pocketmine-MP)
|
||||||
else if (GetPlatform() === "pocketmine") {
|
else if (CurrentBdsPlatform === "pocketmine") {
|
||||||
// Start PocketMine-MP
|
// Start PocketMine-MP
|
||||||
SetupCommands.command = path.join(path.resolve(GetServerPaths("pocketmine"), "bin", "php7", "bin"), "php");
|
SetupCommands.command = path.join(path.resolve(GetServerPaths("pocketmine"), "bin", "php7", "bin"), "php");
|
||||||
if (process.platform === "win32") SetupCommands.command = path.join(path.resolve(GetServerPaths("pocketmine"), "bin/php"), "php.exe");
|
if (process.platform === "win32") SetupCommands.command = path.join(path.resolve(GetServerPaths("pocketmine"), "bin/php"), "php.exe");
|
||||||
@ -109,22 +130,7 @@ function start() {
|
|||||||
ServerExec.stdout.on("data", data => {if (global.bds_log_string) global.bds_log_string = data; else global.bds_log_string += data});
|
ServerExec.stdout.on("data", data => {if (global.bds_log_string) global.bds_log_string = data; else global.bds_log_string += data});
|
||||||
|
|
||||||
// sets bds core commands
|
// sets bds core commands
|
||||||
const command = async function (command = "list", callback = function (){}) {
|
const log = function (logCallback){
|
||||||
return new Promise((resolve) => {
|
|
||||||
ServerExec.stdin.write(`${command}\n`);
|
|
||||||
if (typeof callback === "function") {
|
|
||||||
const TempLog = []
|
|
||||||
const ControlTempHost = data => {TempLog.push(data); return data;}
|
|
||||||
ServerExec.stdout.on("data", data => ControlTempHost(data));
|
|
||||||
ServerExec.stderr.on("data", data => ControlTempHost(data));
|
|
||||||
setTimeout(() => {
|
|
||||||
callback(TempLog.join("\n"));
|
|
||||||
resolve(TempLog.join("\n"));
|
|
||||||
}, 2500);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
const log = function (logCallback = data => process.stdout.write(data)){
|
|
||||||
if (typeof logCallback !== "function") throw new Error("Log Callback is not a function");
|
if (typeof logCallback !== "function") throw new Error("Log Callback is not a function");
|
||||||
ServerExec.stdout.on("data", data => logCallback(data));
|
ServerExec.stdout.on("data", data => logCallback(data));
|
||||||
ServerExec.stderr.on("data", data => logCallback(data));
|
ServerExec.stderr.on("data", data => logCallback(data));
|
||||||
@ -142,39 +148,130 @@ function start() {
|
|||||||
ServerExec.stdout.on("data", data);
|
ServerExec.stdout.on("data", data);
|
||||||
ServerExec.stderr.on("data", data);
|
ServerExec.stderr.on("data", data);
|
||||||
};
|
};
|
||||||
|
const command = function (command = "list") {
|
||||||
|
ServerExec.stdin.write(`${command}\n`);
|
||||||
|
return command;
|
||||||
|
};
|
||||||
const stop = function (){
|
const stop = function (){
|
||||||
ServerExec.stdin.write(BdsInfo.Servers[GetPlatform()].stop+"\n");
|
if (CurrentBdsPlatform === "bedrock") {
|
||||||
return BdsInfo.Servers[GetPlatform()].stop;
|
ServerExec.stdin.write("stop\n");
|
||||||
|
return "stop";
|
||||||
|
} else if (CurrentBdsPlatform === "dragonfly") {
|
||||||
|
ServerExec.kill("SIGKILL");
|
||||||
|
return "process";
|
||||||
|
} else if (CurrentBdsPlatform === "java") {
|
||||||
|
ServerExec.stdin.write("stop\n");
|
||||||
|
return "stop";
|
||||||
|
} else if (CurrentBdsPlatform === "pocketmine") {
|
||||||
|
ServerExec.stdin.write("stop\n");
|
||||||
|
return "stop";
|
||||||
|
} else if (CurrentBdsPlatform === "spigot") {
|
||||||
|
ServerExec.stdin.write("stop\n");
|
||||||
|
return "stop";
|
||||||
|
} else throw new Error("Bds Core Bad Config Error");
|
||||||
};
|
};
|
||||||
const op = function (player = "Steve") {
|
const op = function (player = "Steve") {
|
||||||
let command = BdsInfo.Servers[GetPlatform()].op.replace("{{Player}}", player);
|
if (CurrentBdsPlatform === "bedrock") {
|
||||||
ServerExec.stdin.write(command+"\n");
|
ServerExec.stdin.write(`op "${player}"\n`);
|
||||||
return command;
|
return "op";
|
||||||
|
} else if (CurrentBdsPlatform === "dragonfly") {
|
||||||
|
throw new Error("Dragonfly does not support commands");
|
||||||
|
} else if (CurrentBdsPlatform === "java") {
|
||||||
|
ServerExec.stdin.write(`op ${player}\n`);
|
||||||
|
return "op";
|
||||||
|
} else if (CurrentBdsPlatform === "pocketmine") {
|
||||||
|
ServerExec.stdin.write(`op ${player}\n`);
|
||||||
|
return "op";
|
||||||
|
} else if (CurrentBdsPlatform === "spigot") {
|
||||||
|
ServerExec.stdin.write(`op ${player}\n`);
|
||||||
|
return "op";
|
||||||
|
} else throw new Error("Bds Core Bad Config Error");
|
||||||
};
|
};
|
||||||
const deop = function (player = "Steve") {
|
const deop = function (player = "Steve") {
|
||||||
let command = BdsInfo.Servers[GetPlatform()].deop.replace("{{Player}}", player);
|
if (CurrentBdsPlatform === "bedrock") {
|
||||||
ServerExec.stdin.write(command+"\n");
|
ServerExec.stdin.write(`deop "${player}"\n`);
|
||||||
return command;
|
return "deop";
|
||||||
|
} else if (CurrentBdsPlatform === "dragonfly") {
|
||||||
|
throw new Error("Dragonfly does not support commands");
|
||||||
|
} else if (CurrentBdsPlatform === "java") {
|
||||||
|
ServerExec.stdin.write(`deop ${player}\n`);
|
||||||
|
return "deop";
|
||||||
|
} else if (CurrentBdsPlatform === "pocketmine") {
|
||||||
|
ServerExec.stdin.write(`deop ${player}\n`);
|
||||||
|
return "deop";
|
||||||
|
} else if (CurrentBdsPlatform === "spigot") {
|
||||||
|
ServerExec.stdin.write(`deop ${player}\n`);
|
||||||
|
return "deop";
|
||||||
|
} else throw new Error("Bds Core Bad Config Error");
|
||||||
};
|
};
|
||||||
const ban = function (player = "Steve") {
|
const ban = function (player = "Steve") {
|
||||||
let command = BdsInfo.Servers[GetPlatform()].ban.replace("{{Player}}", player);
|
if (CurrentBdsPlatform === "bedrock") {
|
||||||
ServerExec.stdin.write(command+"\n");
|
ServerExec.stdin.write(`kick "${player}"\n`);
|
||||||
return command;
|
return "kick";
|
||||||
|
} else if (CurrentBdsPlatform === "dragonfly") {
|
||||||
|
throw new Error("Dragonfly does not support commands");
|
||||||
|
} else if (CurrentBdsPlatform === "java") {
|
||||||
|
ServerExec.stdin.write(`ban ${player}\n`);
|
||||||
|
return "ban";
|
||||||
|
} else if (CurrentBdsPlatform === "pocketmine") {
|
||||||
|
ServerExec.stdin.write(`ban ${player}\n`);
|
||||||
|
return "ban";
|
||||||
|
} else if (CurrentBdsPlatform === "spigot") {
|
||||||
|
ServerExec.stdin.write(`ban ${player}\n`);
|
||||||
|
return "ban";
|
||||||
|
} else throw new Error("Bds Core Bad Config Error");
|
||||||
};
|
};
|
||||||
const kick = function (player = "Steve", text = "you got kicked") {
|
const kick = function (player = "Steve", text = "you got kicked") {
|
||||||
let command = BdsInfo.Servers[GetPlatform()].kick.replace("{{Player}}", player).replace("{{Text}}", text);
|
if (CurrentBdsPlatform === "bedrock") {
|
||||||
ServerExec.stdin.write(command+"\n");
|
ServerExec.stdin.write(`kick "${player}" ${text}\n`);
|
||||||
return command;
|
return "kick";
|
||||||
|
} else if (CurrentBdsPlatform === "dragonfly") {
|
||||||
|
throw new Error("Dragonfly does not support commands");
|
||||||
|
} else if (CurrentBdsPlatform === "java") {
|
||||||
|
ServerExec.stdin.write(`kick ${player} ${text}\n`);
|
||||||
|
return "kick";
|
||||||
|
} else if (CurrentBdsPlatform === "pocketmine") {
|
||||||
|
ServerExec.stdin.write(`kick ${player} ${text}\n`);
|
||||||
|
return "kick";
|
||||||
|
} else if (CurrentBdsPlatform === "spigot") {
|
||||||
|
ServerExec.stdin.write(`kick ${player} ${text}\n`);
|
||||||
|
return "kick";
|
||||||
|
} else throw new Error("Bds Core Bad Config Error");
|
||||||
};
|
};
|
||||||
const tp = function (player = "Steve", cord = {x: 0, y: 128, z: 0}) {
|
const tp = function (player = "Steve", cord = {x: 0, y: 128, z: 0}) {
|
||||||
let command = BdsInfo.Servers[GetPlatform()].tp.replace("{{Player}}", player);
|
if (CurrentBdsPlatform === "bedrock") {
|
||||||
if (cord.x) command = command.replace("{{X}}", cord.x); else command = command.replace("{{X}}", 0);
|
ServerExec.stdin.write(`tp ${player} ${cord.x} ${cord.y} ${cord.z}\n`);
|
||||||
if (cord.y) command = command.replace("{{Y}}", cord.y); else command = command.replace("{{Y}}", 128);
|
return "tp";
|
||||||
if (cord.y) command = command.replace("{{Z}}", cord.y); else command = command.replace("{{Z}}", 0);
|
} else if (CurrentBdsPlatform === "dragonfly") {
|
||||||
ServerExec.stdin.write(command+"\n");
|
throw new Error("Dragonfly does not support commands");
|
||||||
return command;
|
} else if (CurrentBdsPlatform === "java") {
|
||||||
|
ServerExec.stdin.write(`tp ${player} ${cord.x} ${cord.y} ${cord.z}\n`);
|
||||||
|
return "tp";
|
||||||
|
} else if (CurrentBdsPlatform === "pocketmine") {
|
||||||
|
ServerExec.stdin.write(`tp ${player} ${cord.x} ${cord.y} ${cord.z}\n`);
|
||||||
|
return "tp";
|
||||||
|
} else if (CurrentBdsPlatform === "spigot") {
|
||||||
|
ServerExec.stdin.write(`tp ${player} ${cord.x} ${cord.y} ${cord.z}\n`);
|
||||||
|
return "tp";
|
||||||
|
} else throw new Error("Bds Core Bad Config Error");
|
||||||
};
|
};
|
||||||
const say = (text = "") => ServerExec.stdin.write(BdsInfo.Servers.bedrock.say.replace("{{Text}}", text));
|
function say(text = ""){
|
||||||
|
if (CurrentBdsPlatform === "bedrock") {
|
||||||
|
ServerExec.stdin.write(`say ${text}\n`);
|
||||||
|
return "say";
|
||||||
|
} else if (CurrentBdsPlatform === "dragonfly") {
|
||||||
|
throw new Error("Dragonfly does not support commands");
|
||||||
|
} else if (CurrentBdsPlatform === "java") {
|
||||||
|
ServerExec.stdin.write(`say ${text}\n`);
|
||||||
|
return "say";
|
||||||
|
} else if (CurrentBdsPlatform === "pocketmine") {
|
||||||
|
ServerExec.stdin.write(`say ${text}\n`);
|
||||||
|
return "say";
|
||||||
|
} else if (CurrentBdsPlatform === "spigot") {
|
||||||
|
ServerExec.stdin.write(`say ${text}\n`);
|
||||||
|
return "say";
|
||||||
|
} else throw new Error("Bds Core Bad Config Error");
|
||||||
|
}
|
||||||
|
|
||||||
// Mount commands to Return
|
// Mount commands to Return
|
||||||
const returnFuntion = {
|
const returnFuntion = {
|
||||||
|
@ -4,215 +4,52 @@ const { writeFileSync, existsSync, readFileSync, readdirSync, rmSync } = fs;
|
|||||||
const { join, resolve } = path;
|
const { join, resolve } = path;
|
||||||
var AdmZip = require("adm-zip");
|
var AdmZip = require("adm-zip");
|
||||||
const BdsInfo = require("../lib/BdsSystemInfo");
|
const BdsInfo = require("../lib/BdsSystemInfo");
|
||||||
const { GetServerPaths, GetServerVersion, UpdateServerVersion, GetPlatform } = require("../lib/BdsSettings");
|
const { GetServerPaths, GetPlatform } = require("../lib/BdsSettings");
|
||||||
const Extra = require("../BdsManegerInfo.json");
|
const Extra = require("../BdsManegerInfo.json");
|
||||||
const bds = require("../index");
|
const bds = require("../index");
|
||||||
const { execSync } = require("child_process");
|
|
||||||
const Request = require("../lib/Requests");
|
const Request = require("../lib/Requests");
|
||||||
|
|
||||||
module.exports = function (version = true, force_install = false, callback = (err) => {if (err) console.log("Download Error")}) {
|
// Php download and install
|
||||||
return new Promise(async (promise_resolve, promise_reject) => {
|
async function php_download() {
|
||||||
BdsInfo().then(info => info.valid_platform).then(valid_platform => {
|
const bds_dir_pocketmine = GetServerPaths("pocketmine");
|
||||||
Request.JSON(Extra.Fetchs.servers).then(Servers => {
|
const PHPBin = (await (await fetch(Extra.Fetchs.php)).json());
|
||||||
try {
|
const phpFolder = resolve(bds_dir_pocketmine, "bin");
|
||||||
// Server Paths
|
const phpExtensiosnsDir = resolve(bds_dir_pocketmine, "bin/php7/lib/php/extensions");
|
||||||
const bds_dir_bedrock = GetServerPaths("bedrock"),
|
|
||||||
bds_dir_java = GetServerPaths("java"),
|
|
||||||
bds_dir_pocketmine = GetServerPaths("pocketmine"),
|
|
||||||
bds_dir_spigot = GetServerPaths("spigot"),
|
|
||||||
bds_dir_dragonfly = GetServerPaths("dragonfly");
|
|
||||||
|
|
||||||
// JSON Configs and others
|
// Check Php Binary
|
||||||
const ServerVersion = GetServerVersion();
|
let urlPHPBin = PHPBin[process.platform]
|
||||||
const CurrentPlatform = GetPlatform();
|
if (!(urlPHPBin)) throw new Error("unsupported system")
|
||||||
if (typeof version === "boolean" || /true|latest/gi.test(`${version}`.toLocaleLowerCase())) version = Servers.latest[CurrentPlatform];
|
urlPHPBin = urlPHPBin[bds.arch];
|
||||||
|
if (!(urlPHPBin)) throw new Error("unsupported arch")
|
||||||
|
|
||||||
// Donwload
|
// Remove Old php Binary if it exists
|
||||||
console.log(`Installing version ${version}`);
|
if (existsSync(phpFolder)) {
|
||||||
// Bedrock Installer Script
|
rmSync(phpFolder, { recursive: true });
|
||||||
if (CurrentPlatform === "bedrock") {
|
}
|
||||||
if (valid_platform.bedrock === true){
|
const ZipBuffer = Buffer.from((await (await fetch(urlPHPBin)).arrayBuffer()));
|
||||||
|
const zipExtractBin = new AdmZip(ZipBuffer);
|
||||||
|
zipExtractBin.extractAllTo(bds_dir_pocketmine, false)
|
||||||
|
|
||||||
if (!(force_install === true) && ServerVersion.bedrock === version) {
|
if (process.platform === "win32") return resolve();
|
||||||
console.warn("Jumping, installed version")
|
|
||||||
if (typeof callback === "function") callback(undefined, true);
|
|
||||||
promise_resolve(true);
|
|
||||||
} else {
|
|
||||||
// Get Server Version
|
|
||||||
const BedrockUrlDownload = (Servers.bedrock[version][bds.arch] || Servers.bedrock[version]["x64"])[process.platform];
|
|
||||||
if (!(BedrockUrlDownload)) return promise_reject(new Error("Error in find url version"));
|
|
||||||
if (Servers.bedrock[version].data) console.log(`Server data publish: ${Servers.bedrock[version].data}`);
|
|
||||||
|
|
||||||
// Copy Config files
|
let phpConfigInit = readFileSync(join(phpFolder, "php7", "bin", "php.ini"), "utf8");
|
||||||
var server_configs, permissions, whitelist;
|
if (!(existsSync(phpExtensiosnsDir))) return true;
|
||||||
if (existsSync(join(bds_dir_bedrock, "server.properties"))) server_configs = readFileSync(join(bds_dir_bedrock, "server.properties"), "utf8");
|
|
||||||
if (existsSync(join(bds_dir_bedrock, "permissions.json"))) permissions = readFileSync(join(bds_dir_bedrock, "permissions.json"), "utf8");
|
|
||||||
if (existsSync(join(bds_dir_bedrock, "whitelist.json"))) whitelist = readFileSync(join(bds_dir_bedrock, "whitelist.json"), "utf8");
|
|
||||||
|
|
||||||
// Download and Add to Adm_Zip
|
const phpExtensiosns = readdirSync(phpExtensiosnsDir).map(FileFolder => {
|
||||||
Request.BUFFER(BedrockUrlDownload).then(ResBuffer => {
|
if (!(FileFolder.includes("debug-zts"))) return false;
|
||||||
// Extract Zip
|
return resolve(phpExtensiosnsDir, FileFolder);
|
||||||
const zip = new AdmZip(ResBuffer);
|
}).filter(a=>a);
|
||||||
console.log("Download Sucess")
|
|
||||||
zip.extractAllTo(bds_dir_bedrock, true)
|
|
||||||
console.log("Extract Sucess")
|
|
||||||
|
|
||||||
// Reeplace Server Configs
|
if (phpConfigInit.includes("extension_dir")) console.log("Skipping php.ini configuration");
|
||||||
if (server_configs) writeFileSync(join(bds_dir_bedrock, "server.properties"), server_configs);
|
else {
|
||||||
if (permissions) writeFileSync(join(bds_dir_bedrock, "permissions.json"), permissions);
|
phpConfigInit = (`extension_dir="${phpExtensiosns.join()}"\n${phpConfigInit}`);
|
||||||
if (whitelist) writeFileSync(join(bds_dir_bedrock, "whitelist.json"), whitelist);
|
writeFileSync(join(phpFolder, "php7", "bin", "php.ini"), phpConfigInit);
|
||||||
|
}
|
||||||
// Update Server Version
|
return true;
|
||||||
UpdateServerVersion(version);
|
|
||||||
|
|
||||||
// Resolve
|
|
||||||
promise_resolve();
|
|
||||||
if (typeof callback === "function") callback(undefined);
|
|
||||||
}).catch(error => {promise_reject(error); if (typeof callback === "function") callback(error);});
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
const BedrcokError = Error("Bedrock Not suported");
|
|
||||||
promise_reject(BedrcokError);
|
|
||||||
if (typeof callback === "function") callback(BedrcokError);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Java
|
|
||||||
else if (CurrentPlatform === "java") {
|
|
||||||
if (valid_platform.java === true){
|
|
||||||
if (version === "latest") version = Servers.latest.java
|
|
||||||
if (!(force_install === true) && version === ServerVersion.java) {
|
|
||||||
console.warn("Jumping, installed version")
|
|
||||||
promise_resolve(true);
|
|
||||||
if (typeof callback === "function") callback(undefined, true);
|
|
||||||
} else {
|
|
||||||
const JavaDownloadUrl = Servers.java[version].url
|
|
||||||
console.log(`Server data publish: ${Servers.java[version].data}`)
|
|
||||||
Request.BUFFER(JavaDownloadUrl).then(ResBuffer => {
|
|
||||||
// Save Jar file
|
|
||||||
writeFileSync(join(bds_dir_java, "MinecraftServerJava.jar"), ResBuffer, "binary")
|
|
||||||
console.log("Success when downloading and saving Minecraft Server java");
|
|
||||||
|
|
||||||
// Update Server Version
|
|
||||||
UpdateServerVersion(version);
|
|
||||||
|
|
||||||
// Resolve
|
|
||||||
promise_resolve();
|
|
||||||
if (typeof callback === "function") callback(undefined);
|
|
||||||
}).catch(error => {
|
|
||||||
promise_reject(error);
|
|
||||||
if (typeof callback === "function") callback(error);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
const JavaError = Error("Java is not supported or required software is not installed");
|
|
||||||
promise_reject(JavaError);
|
|
||||||
if (typeof callback === "function") callback(JavaError);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Pocketmine-MP
|
|
||||||
else if (CurrentPlatform === "pocketmine") {
|
|
||||||
if (valid_platform.pocketmine === true) {
|
|
||||||
if (version === "latest") version = Servers.latest.pocketmine
|
|
||||||
if (!(force_install === true) && version === ServerVersion.pocketmine) {
|
|
||||||
console.warn("Jumping, installed version")
|
|
||||||
promise_resolve();
|
|
||||||
if (typeof callback === "function") callback(undefined);
|
|
||||||
} else {
|
|
||||||
const PocketMineJson = Servers.pocketmine[version]
|
|
||||||
console.log(`Server data publish: ${PocketMineJson.data}`);
|
|
||||||
|
|
||||||
Request.BUFFER(PocketMineJson.url).then(ResBuffer => {
|
|
||||||
writeFileSync(join(bds_dir_pocketmine, "PocketMine-MP.phar"), ResBuffer, "binary")
|
|
||||||
console.log("Success downloading and saving PocketMine-MP php");
|
|
||||||
php_download().then(() => {
|
|
||||||
// Update server Version
|
|
||||||
UpdateServerVersion(version)
|
|
||||||
// Callback
|
|
||||||
promise_resolve(true);
|
|
||||||
if (typeof callback === "function") callback(undefined, true);
|
|
||||||
}).catch(error => {
|
|
||||||
promise_reject(error);
|
|
||||||
if (typeof callback === "function") callback(error);
|
|
||||||
});
|
|
||||||
}).catch(error => {
|
|
||||||
promise_reject(error);
|
|
||||||
if (typeof callback === "function") callback(error);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
const PocketMineError = Error("Pocketmine not suported");
|
|
||||||
promise_reject(PocketMineError);
|
|
||||||
if (typeof callback === "function") callback(PocketMineError);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Spigot
|
|
||||||
else if (CurrentPlatform === "spigot") {
|
|
||||||
if (valid_platform.java) {
|
|
||||||
if (version === "latest") version = Servers.latest.spigot;
|
|
||||||
if (!(force_install === true) && version === ServerVersion.spigot) {
|
|
||||||
console.warn("Jumping, installed version")
|
|
||||||
if (typeof callback === "function") callback(undefined, true);
|
|
||||||
promise_resolve(true)
|
|
||||||
} else {
|
|
||||||
const SpigotArray = Servers.spigot[version];
|
|
||||||
if (SpigotArray.data) console.log(`Server data publish: ${SpigotArray.data}`);
|
|
||||||
Request.BUFFER(SpigotArray.url).then(ResBuffer => {
|
|
||||||
writeFileSync(join(bds_dir_spigot, "spigot.jar"), ResBuffer, "binary");
|
|
||||||
console.log("Success when downloading and saving Spigot");
|
|
||||||
UpdateServerVersion(version);
|
|
||||||
promise_resolve();
|
|
||||||
if (typeof callback === "function") callback(undefined);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
const JavaError = Error("Java is not supported or required software is not installed");
|
|
||||||
promise_reject(JavaError);
|
|
||||||
if (typeof callback === "function") callback(JavaError);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// dragonfly
|
|
||||||
else if (CurrentPlatform === "dragonfly") {
|
|
||||||
if (valid_platform.dragonfly) {
|
|
||||||
console.info("Dragonfly does not support versions");
|
|
||||||
execSync("git clone https://github.com/df-mc/dragonfly ./", {
|
|
||||||
cwd: bds_dir_dragonfly
|
|
||||||
});
|
|
||||||
promise_resolve(true);
|
|
||||||
if (typeof callback === "function") callback(undefined);
|
|
||||||
} else {
|
|
||||||
const DragonFlyError = Error("Dragonfly not suported");
|
|
||||||
promise_reject(DragonFlyError);
|
|
||||||
if (typeof callback === "function") callback(DragonFlyError);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Unidentified platform
|
|
||||||
else {
|
|
||||||
const Err = Error("Bds maneger Config file error");
|
|
||||||
promise_reject(Err);
|
|
||||||
if (typeof callback === "function") callback(Err);
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
promise_reject(err);
|
|
||||||
if (typeof callback === "function") callback(err);
|
|
||||||
}
|
|
||||||
}).catch(err => {
|
|
||||||
promise_reject(err);
|
|
||||||
if (typeof callback === "function") callback(err);
|
|
||||||
});
|
|
||||||
}).catch(err => {
|
|
||||||
promise_reject(err);
|
|
||||||
if (typeof callback === "function") callback(err);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// New Download Method
|
// New Download Method
|
||||||
module.exports.v2 = async (version = true) => {
|
async function BdsDownloadV2(version = "latest") {
|
||||||
const CurrentPlatform = GetPlatform();
|
const CurrentPlatform = GetPlatform();
|
||||||
const valid_platform = (await BdsInfo()).valid_platform;
|
const valid_platform = (await BdsInfo()).valid_platform;
|
||||||
const LocalServersVersions = bds.BdsSettigs.GetServerVersion();
|
const LocalServersVersions = bds.BdsSettigs.GetServerVersion();
|
||||||
@ -222,11 +59,11 @@ module.exports.v2 = async (version = true) => {
|
|||||||
const ServerDownloadJSON = await Request.json(Extra.Fetchs.servers);
|
const ServerDownloadJSON = await Request.json(Extra.Fetchs.servers);
|
||||||
|
|
||||||
// Check is latest version options or boolean
|
// Check is latest version options or boolean
|
||||||
if (typeof version === "boolean" || /true|false|latest/.test(`${version}`.toLocaleLowerCase())) version = ServerDownloadJSON.latest[CurrentPlatform];
|
if (typeof version === "boolean" || /true|false|null|undefined|latest/.test(`${version}`.toLocaleLowerCase())) version = ServerDownloadJSON.latest[CurrentPlatform];
|
||||||
if (!version) throw Error("No version found");
|
if (!version) throw Error("No version found");
|
||||||
|
|
||||||
const ReturnObject = {
|
const ReturnObject = {
|
||||||
version: version,
|
version,
|
||||||
platform: CurrentPlatform,
|
platform: CurrentPlatform,
|
||||||
url: "",
|
url: "",
|
||||||
data: "",
|
data: "",
|
||||||
@ -304,7 +141,7 @@ module.exports.v2 = async (version = true) => {
|
|||||||
if (valid_platform.spigot) {
|
if (valid_platform.spigot) {
|
||||||
if (LocalServersVersions.spigot !== version) {
|
if (LocalServersVersions.spigot !== version) {
|
||||||
// Add info to ReturnObject
|
// Add info to ReturnObject
|
||||||
const FindedSpigot = ServerDownloadJSON.spigot.findOne(spigot => spigot.version === version);
|
const FindedSpigot = ServerDownloadJSON.spigot.find(spigot => spigot.version === version);
|
||||||
ReturnObject.url = FindedSpigot.url;
|
ReturnObject.url = FindedSpigot.url;
|
||||||
ReturnObject.data = FindedSpigot.data;
|
ReturnObject.data = FindedSpigot.data;
|
||||||
|
|
||||||
@ -376,41 +213,6 @@ module.exports.v2 = async (version = true) => {
|
|||||||
return ReturnObject;
|
return ReturnObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Php download and install
|
// Export
|
||||||
async function php_download() {
|
module.exports = BdsDownloadV2;
|
||||||
const bds_dir_pocketmine = GetServerPaths("pocketmine");
|
module.exports.v2 = BdsDownloadV2;
|
||||||
const PHPBin = (await (await fetch(Extra.Fetchs.php)).json());
|
|
||||||
const phpFolder = resolve(bds_dir_pocketmine, "bin");
|
|
||||||
const phpExtensiosnsDir = resolve(bds_dir_pocketmine, "bin/php7/lib/php/extensions");
|
|
||||||
|
|
||||||
// Check Php Binary
|
|
||||||
let urlPHPBin = PHPBin[process.platform]
|
|
||||||
if (!(urlPHPBin)) throw new Error("unsupported system")
|
|
||||||
urlPHPBin = urlPHPBin[bds.arch];
|
|
||||||
if (!(urlPHPBin)) throw new Error("unsupported arch")
|
|
||||||
|
|
||||||
// Remove Old php Binary if it exists
|
|
||||||
if (existsSync(phpFolder)) {
|
|
||||||
rmSync(phpFolder, { recursive: true });
|
|
||||||
}
|
|
||||||
const ZipBuffer = Buffer.from((await (await fetch(urlPHPBin)).arrayBuffer()));
|
|
||||||
const zipExtractBin = new AdmZip(ZipBuffer);
|
|
||||||
zipExtractBin.extractAllTo(bds_dir_pocketmine, false)
|
|
||||||
|
|
||||||
if (process.platform === "win32") return resolve();
|
|
||||||
|
|
||||||
let phpConfigInit = readFileSync(join(phpFolder, "php7", "bin", "php.ini"), "utf8");
|
|
||||||
if (!(existsSync(phpExtensiosnsDir))) return true;
|
|
||||||
|
|
||||||
const phpExtensiosns = readdirSync(phpExtensiosnsDir).map(FileFolder => {
|
|
||||||
if (!(FileFolder.includes("debug-zts"))) return false;
|
|
||||||
return resolve(phpExtensiosnsDir, FileFolder);
|
|
||||||
}).filter(a=>a);
|
|
||||||
|
|
||||||
if (phpConfigInit.includes("extension_dir")) console.log("Skipping php.ini configuration");
|
|
||||||
else {
|
|
||||||
phpConfigInit = (`extension_dir="${phpExtensiosns.join()}"\n${phpConfigInit}`);
|
|
||||||
writeFileSync(join(phpFolder, "php7", "bin", "php.ini"), phpConfigInit);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
@ -54,8 +54,10 @@ function Detect(){
|
|||||||
const CurrentProcess = getProcess();
|
const CurrentProcess = getProcess();
|
||||||
for (let check of CurrentProcess) {
|
for (let check of CurrentProcess) {
|
||||||
if (/MinecraftServerJava.jar/.test(check.command)) return true;
|
if (/MinecraftServerJava.jar/.test(check.command)) return true;
|
||||||
|
if (/spigot.jar/.test(check.command)) return true;
|
||||||
if (/bedrock_server/.test(check.command)) return true;
|
if (/bedrock_server/.test(check.command)) return true;
|
||||||
if (/PocketMine-MP.phar/.test(check.command)) return true;
|
if (/PocketMine-MP.phar/.test(check.command)) return true;
|
||||||
|
if (/Dragonfly/.test(check.command)) return true;
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -68,6 +70,10 @@ function Kill(){
|
|||||||
console.log("Killing Minecraft Server Java");
|
console.log("Killing Minecraft Server Java");
|
||||||
killWithPid(check.pid);
|
killWithPid(check.pid);
|
||||||
}
|
}
|
||||||
|
if (/spigot.jar/.test(check.command)) {
|
||||||
|
console.log("Killing Spigot");
|
||||||
|
killWithPid(check.pid);
|
||||||
|
}
|
||||||
if (/bedrock_server/.test(check.command)) {
|
if (/bedrock_server/.test(check.command)) {
|
||||||
console.log("Killing Minecraft Bedrock Server");
|
console.log("Killing Minecraft Bedrock Server");
|
||||||
killWithPid(check.pid);
|
killWithPid(check.pid);
|
||||||
@ -76,6 +82,10 @@ function Kill(){
|
|||||||
console.log("Killing Pocketmine-MP");
|
console.log("Killing Pocketmine-MP");
|
||||||
killWithPid(check.pid);
|
killWithPid(check.pid);
|
||||||
}
|
}
|
||||||
|
if (/Dragonfly/.test(check.command)) {
|
||||||
|
console.log("Killing Dragonfly");
|
||||||
|
killWithPid(check.pid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -3,15 +3,18 @@ const path = require("path");
|
|||||||
const propertiesToJSON = require("properties-to-json");
|
const propertiesToJSON = require("properties-to-json");
|
||||||
const BdsInfo = require("../lib/BdsSystemInfo");
|
const BdsInfo = require("../lib/BdsSystemInfo");
|
||||||
const { GetServerPaths, GetPlatform } = require("../lib/BdsSettings");
|
const { GetServerPaths, GetPlatform } = require("../lib/BdsSettings");
|
||||||
|
const TOML = require("@iarna/toml");
|
||||||
|
|
||||||
const ConfigFilePath = {
|
const ConfigFilePath = {
|
||||||
bedrock: path.join(GetServerPaths("bedrock"), "server.properties"),
|
bedrock: path.join(GetServerPaths("bedrock"), "server.properties"),
|
||||||
java: path.join(GetServerPaths("java"), "server.properties"),
|
java: path.join(GetServerPaths("java"), "server.properties"),
|
||||||
pocketmine: path.join(GetServerPaths("pocketmine"), "server.properties")
|
pocketmine: path.join(GetServerPaths("pocketmine"), "server.properties"),
|
||||||
|
dragonfly: path.join(GetServerPaths("dragonfly"), "config.toml"),
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set Config
|
// Set Config
|
||||||
function bds_config(NewConfig = {world: "Bds Maneger", description: "The Bds Maneger", gamemode: "creative", difficulty: "normal", players: 10, commands: true, account: true, whitelist: true, port: 19132, portv6: 19133, seed: ""}){
|
function bds_config(NewConfig = {world: "Bds Maneger", description: "The Bds Maneger", gamemode: "creative", difficulty: "normal", players: 10, commands: true, account: true, whitelist: true, port: 19132, portv6: 19133, seed: ""}){
|
||||||
|
const BdsPlatform = GetPlatform();
|
||||||
const JsonConfig = {
|
const JsonConfig = {
|
||||||
world: "Bds Maneger",
|
world: "Bds Maneger",
|
||||||
description: "The Bds Maneger",
|
description: "The Bds Maneger",
|
||||||
@ -44,7 +47,7 @@ function bds_config(NewConfig = {world: "Bds Maneger", description: "The Bds Man
|
|||||||
if (typeof NewConfig.portv6 === "number" && NewConfig.portv6) JsonConfig.portv6 = NewConfig.portv6
|
if (typeof NewConfig.portv6 === "number" && NewConfig.portv6) JsonConfig.portv6 = NewConfig.portv6
|
||||||
|
|
||||||
const Config = [];
|
const Config = [];
|
||||||
if (GetPlatform() === "bedrock") {
|
if (BdsPlatform === "bedrock") {
|
||||||
const bedrockCPUThread = BdsInfo.GetCpuCoreCount();
|
const bedrockCPUThread = BdsInfo.GetCpuCoreCount();
|
||||||
var tickDistance; if (!(bedrockCPUThread % 2)) tickDistance = bedrockCPUThread; else tickDistance = 1;
|
var tickDistance; if (!(bedrockCPUThread % 2)) tickDistance = bedrockCPUThread; else tickDistance = 1;
|
||||||
Config.push(
|
Config.push(
|
||||||
@ -77,7 +80,7 @@ function bds_config(NewConfig = {world: "Bds Maneger", description: "The Bds Man
|
|||||||
"correct-player-movement=false",
|
"correct-player-movement=false",
|
||||||
"server-authoritative-block-breaking=false",
|
"server-authoritative-block-breaking=false",
|
||||||
);
|
);
|
||||||
} else if (GetPlatform() === "java") {
|
} else if (BdsPlatform === "java") {
|
||||||
Config.push(
|
Config.push(
|
||||||
"# By The Bds Maneger project",
|
"# By The Bds Maneger project",
|
||||||
`# Date: ${Date.now()}`,
|
`# Date: ${Date.now()}`,
|
||||||
@ -133,7 +136,35 @@ function bds_config(NewConfig = {world: "Bds Maneger", description: "The Bds Man
|
|||||||
"spawn-protection=16",
|
"spawn-protection=16",
|
||||||
"max-world-size=29999984",
|
"max-world-size=29999984",
|
||||||
);
|
);
|
||||||
} else if (GetPlatform() === "pocketmine") {
|
} else if (BdsPlatform === "dragonfly") {
|
||||||
|
Config.push(
|
||||||
|
"",
|
||||||
|
"[Network]",
|
||||||
|
` Address = ":${JsonConfig.port}"`,
|
||||||
|
"",
|
||||||
|
"[Players]",
|
||||||
|
" Folder = \"players\"",
|
||||||
|
" MaxCount = 0",
|
||||||
|
" MaximumChunkRadius = 32",
|
||||||
|
" SaveData = true",
|
||||||
|
"",
|
||||||
|
"[Resources]",
|
||||||
|
" Folder = \"resources\"",
|
||||||
|
"",
|
||||||
|
"[Server]",
|
||||||
|
" AuthEnabled = true",
|
||||||
|
" JoinMessage = \"%v has joined the game\"",
|
||||||
|
` Name = "${JsonConfig.description}"`,
|
||||||
|
" QuitMessage = \"%v has left the game\"",
|
||||||
|
" ShutdownMessage = \"Server closed.\"",
|
||||||
|
"",
|
||||||
|
"[World]",
|
||||||
|
" Folder = \"world\"",
|
||||||
|
` Name = "${JsonConfig.world}"`,
|
||||||
|
" SimulationDistance = 8",
|
||||||
|
""
|
||||||
|
);
|
||||||
|
} else if (BdsPlatform === "pocketmine") {
|
||||||
// Whitelist
|
// Whitelist
|
||||||
if (JsonConfig.whitelist === true) JsonConfig.whitelist = "on";
|
if (JsonConfig.whitelist === true) JsonConfig.whitelist = "on";
|
||||||
else JsonConfig.whitelist = "off";
|
else JsonConfig.whitelist = "off";
|
||||||
@ -178,12 +209,13 @@ function bds_config(NewConfig = {world: "Bds Maneger", description: "The Bds Man
|
|||||||
"auto-save=on",
|
"auto-save=on",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
fs.writeFileSync(ConfigFilePath[GetPlatform()], Config.join("\n"))
|
fs.writeFileSync(ConfigFilePath[BdsPlatform], Config.join("\n"))
|
||||||
return Config.join("\n");
|
return Config.join("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get Config
|
// Get Config
|
||||||
function bds_get_config(){
|
function bds_get_config(){
|
||||||
|
const BdsPlatform = GetPlatform();
|
||||||
var config;
|
var config;
|
||||||
const JsonConfig = {
|
const JsonConfig = {
|
||||||
world: "",
|
world: "",
|
||||||
@ -196,8 +228,8 @@ function bds_get_config(){
|
|||||||
portv6: 0,
|
portv6: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (GetPlatform() === "bedrock") {
|
if (BdsPlatform === "bedrock") {
|
||||||
if (fs.existsSync(ConfigFilePath[GetPlatform()])) {
|
if (fs.existsSync(ConfigFilePath[BdsPlatform])) {
|
||||||
config = propertiesToJSON(fs.readFileSync(ConfigFilePath["bedrock"], "utf8"));
|
config = propertiesToJSON(fs.readFileSync(ConfigFilePath["bedrock"], "utf8"));
|
||||||
|
|
||||||
// Players
|
// Players
|
||||||
@ -217,8 +249,8 @@ function bds_get_config(){
|
|||||||
// JsonConfig.worldtype = "default";
|
// JsonConfig.worldtype = "default";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (GetPlatform() === "java") {
|
else if (BdsPlatform === "java") {
|
||||||
if (fs.existsSync(ConfigFilePath[GetPlatform()])) {
|
if (fs.existsSync(ConfigFilePath[BdsPlatform])) {
|
||||||
config = propertiesToJSON(fs.readFileSync(path.join(ConfigFilePath["java"], "server.properties"), "utf8"));
|
config = propertiesToJSON(fs.readFileSync(path.join(ConfigFilePath["java"], "server.properties"), "utf8"));
|
||||||
|
|
||||||
// Players
|
// Players
|
||||||
@ -238,8 +270,8 @@ function bds_get_config(){
|
|||||||
// JsonConfig.worldtype = config["level-type"];
|
// JsonConfig.worldtype = config["level-type"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (GetPlatform() === "pocketmine") {
|
else if (BdsPlatform === "pocketmine") {
|
||||||
if (fs.existsSync(ConfigFilePath[GetPlatform()])) {
|
if (fs.existsSync(ConfigFilePath[BdsPlatform])) {
|
||||||
config = propertiesToJSON(fs.readFileSync(path.join(ConfigFilePath["pocketmine"], "server.properties"), "utf8"));
|
config = propertiesToJSON(fs.readFileSync(path.join(ConfigFilePath["pocketmine"], "server.properties"), "utf8"));
|
||||||
|
|
||||||
// Players
|
// Players
|
||||||
@ -258,6 +290,21 @@ function bds_get_config(){
|
|||||||
JsonConfig.commands = false;
|
JsonConfig.commands = false;
|
||||||
// JsonConfig.worldtype = config["level-type"];
|
// JsonConfig.worldtype = config["level-type"];
|
||||||
}
|
}
|
||||||
|
} else if (BdsPlatform === "dragonfly") {
|
||||||
|
if (fs.existsSync(ConfigFilePath[BdsPlatform])) {
|
||||||
|
const ConfigFile = TOML.parse(fs.readFileSync(ConfigFilePath[BdsPlatform], "utf8"));
|
||||||
|
JsonConfig.world = ConfigFile.World.Name;
|
||||||
|
JsonConfig.description = ConfigFile.Server.Name;
|
||||||
|
JsonConfig.gamemode = "creative";
|
||||||
|
JsonConfig.difficulty = null;
|
||||||
|
JsonConfig.players = parseInt(ConfigFile.Players.MaxCount || 0);
|
||||||
|
JsonConfig.account = false;
|
||||||
|
JsonConfig.whitelist = null;
|
||||||
|
JsonConfig.portv4 = parseInt(ConfigFile.Network.Address.replace(":", ""));
|
||||||
|
JsonConfig.portv6 = parseInt(ConfigFile.Network.Address.replace(":", ""));
|
||||||
|
JsonConfig.seed = null;
|
||||||
|
JsonConfig.commands = false;
|
||||||
|
}
|
||||||
} else throw new Error("Platform no exists, check config file");
|
} else throw new Error("Platform no exists, check config file");
|
||||||
return JsonConfig;
|
return JsonConfig;
|
||||||
}
|
}
|
||||||
@ -265,7 +312,7 @@ function bds_get_config(){
|
|||||||
// Get Withelist
|
// Get Withelist
|
||||||
function bds_get_whitelist(){
|
function bds_get_whitelist(){
|
||||||
const BdsPlatform = GetPlatform();
|
const BdsPlatform = GetPlatform();
|
||||||
const ToReturn = [];
|
const ToReturn = [];
|
||||||
|
|
||||||
// Bedrock
|
// Bedrock
|
||||||
if (BdsPlatform === "bedrock") {
|
if (BdsPlatform === "bedrock") {
|
||||||
|
Reference in New Issue
Block a user