|
|
|
@ -4,7 +4,7 @@ const {exec, execSync} = require("child_process");
|
|
|
|
|
const fs = require("fs")
|
|
|
|
|
const path = require("path")
|
|
|
|
|
const {CheckBan} = require("./check");
|
|
|
|
|
const { resolve } = require("path");
|
|
|
|
|
const { resolve, join } = require("path");
|
|
|
|
|
const commandExists = require("command-exists").sync
|
|
|
|
|
|
|
|
|
|
module.exports.start = () => {
|
|
|
|
@ -41,60 +41,6 @@ module.exports.start = () => {
|
|
|
|
|
...process.env,
|
|
|
|
|
LD_LIBRARY_PATH: bds.bds_dir_bedrock
|
|
|
|
|
}, cwd: bds.bds_dir_bedrock});
|
|
|
|
|
} else if (process.platform === "darwin") throw Error("We don't have MacOS support yet")
|
|
|
|
|
else process.exit(210)
|
|
|
|
|
} else if (plat === "java") {
|
|
|
|
|
if (require("command-exists").sync("java")) start_server = exec(`java -Xmx${bds.bds_config.java_config.max}M -Xms${bds.bds_config.java_config.max}M -jar server.jar nogui`, {cwd: bds.bds_dir_java});
|
|
|
|
|
else {
|
|
|
|
|
if (bds.system == "windows"){
|
|
|
|
|
require("open")("http://docs.sirherobrine23.com/bds_maneger_api_java#Windows");
|
|
|
|
|
console.log("http://docs.sirherobrine23.com/bds_maneger_api_java#Windows")
|
|
|
|
|
} else if (bds.system === "linux"){
|
|
|
|
|
require("open")("http://docs.sirherobrine23.com/bds_maneger_api_java#Linux");
|
|
|
|
|
console.log("http://docs.sirherobrine23.com/bds_maneger_api_java#Linux")
|
|
|
|
|
} else {
|
|
|
|
|
require("open")("http://docs.sirherobrine23.com/bds_maneger_api_java");
|
|
|
|
|
console.log("http://docs.sirherobrine23.com/scripts/_java")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else if (plat === "pocketmine") {
|
|
|
|
|
let childPorcessEnv = process.env
|
|
|
|
|
const phpinCore = resolve(bds.bds_dir_pocketmine, "bin", "php7", "bin")
|
|
|
|
|
if (commandExists("php")) throw Error("php command installed in system, please remove php from your system as it may conflict with pocketmine");
|
|
|
|
|
else if (fs.existsSync(phpinCore)) {
|
|
|
|
|
console.log(phpinCore);
|
|
|
|
|
if (process.env.PATH.includes(phpinCore))console.log("PHP bin folder includes in PATH");
|
|
|
|
|
else {
|
|
|
|
|
if (process.platform === "win32") childPorcessEnv.PATH += `;${phpinCore}`
|
|
|
|
|
else childPorcessEnv.PATH += `:${phpinCore}`
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else throw Error("Reinstall Pocketmine-MP, PHP binaries not found")
|
|
|
|
|
console.log(childPorcessEnv.PATH);
|
|
|
|
|
start_server = exec(`php ${resolve(bds.bds_dir_pocketmine, "PocketMine-MP.phar")}`, {env: {
|
|
|
|
|
...childPorcessEnv
|
|
|
|
|
}, cwd: bds.bds_dir_pocketmine});
|
|
|
|
|
} else throw Error("")
|
|
|
|
|
Storage.setItem("old_log_file", bds.log_file)
|
|
|
|
|
start_server.stdout.on("data", function(data){
|
|
|
|
|
if (data.includes("agree", "EULA")){
|
|
|
|
|
const path = require("path");
|
|
|
|
|
require("open")("https://account.mojang.com/documents/minecraft_eula");
|
|
|
|
|
const eula_file = path.join(bds.bds_dir_java, "eula.txt")
|
|
|
|
|
fs.writeFileSync(eula_file, fs.readFileSync(eula_file, "utf8").replace("eula=false", "eula=true"))
|
|
|
|
|
if (process.argv[0].includes("node")){
|
|
|
|
|
console.warn("Ending the process")
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
process.exit(0)
|
|
|
|
|
}, 1000);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
var logConsoleStream = require("fs").createWriteStream(bds.log_file, {flags: "a"});
|
|
|
|
|
var latestLog = require("fs").createWriteStream(path.join(bds.bds_dir, "log", "latest.log"), {flags: "w"});
|
|
|
|
|
start_server.stdout.pipe(logConsoleStream);
|
|
|
|
|
start_server.stdout.pipe(latestLog);
|
|
|
|
|
if (bds.bds_config.bds_platform === "bedrock"){
|
|
|
|
|
start_server.stdout.on("data", function(data){
|
|
|
|
|
data = data.split("\n")
|
|
|
|
|
var username;
|
|
|
|
@ -157,9 +103,57 @@ module.exports.start = () => {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
} else if (bds.bds_config.bds_platform === "java"){
|
|
|
|
|
console.log("Java is not yet supported the user list");
|
|
|
|
|
} else if (process.platform === "darwin") throw Error("We don't have MacOS support yet")
|
|
|
|
|
else process.exit(210)
|
|
|
|
|
} else if (plat === "java") {
|
|
|
|
|
if (require("command-exists").sync("java")) start_server = exec(`java -Xmx${bds.bds_config.java_config.max}M -Xms${bds.bds_config.java_config.max}M -jar server.jar nogui`, {cwd: bds.bds_dir_java});
|
|
|
|
|
else {
|
|
|
|
|
if (bds.system == "windows"){
|
|
|
|
|
require("open")("http://docs.sirherobrine23.com/bds_maneger_api_java#Windows");
|
|
|
|
|
console.log("http://docs.sirherobrine23.com/bds_maneger_api_java#Windows")
|
|
|
|
|
} else if (bds.system === "linux"){
|
|
|
|
|
require("open")("http://docs.sirherobrine23.com/bds_maneger_api_java#Linux");
|
|
|
|
|
console.log("http://docs.sirherobrine23.com/bds_maneger_api_java#Linux")
|
|
|
|
|
} else {
|
|
|
|
|
require("open")("http://docs.sirherobrine23.com/bds_maneger_api_java");
|
|
|
|
|
console.log("http://docs.sirherobrine23.com/scripts/_java")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else if (plat === "pocketmine") {
|
|
|
|
|
let childPorcessEnv = process.env
|
|
|
|
|
const phpinCore = resolve(bds.bds_dir_pocketmine, "bin", "php7", "bin")
|
|
|
|
|
if (commandExists("php")) throw Error("php command installed in system, please remove php from your system as it may conflict with pocketmine");
|
|
|
|
|
else if (fs.existsSync(phpinCore)) {
|
|
|
|
|
console.log(phpinCore);
|
|
|
|
|
if (process.env.PATH.includes(phpinCore))console.log("PHP bin folder includes in PATH");
|
|
|
|
|
else {
|
|
|
|
|
if (process.platform === "win32") childPorcessEnv.PATH += `;${phpinCore}`
|
|
|
|
|
else childPorcessEnv.PATH += `:${phpinCore}`
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else throw Error("Reinstall Pocketmine-MP, PHP binaries not found")
|
|
|
|
|
console.log(childPorcessEnv.PATH);
|
|
|
|
|
start_server = exec(`php ${join(bds.bds_dir_pocketmine, "PocketMine-MP.phar")}`, {env: {
|
|
|
|
|
...childPorcessEnv
|
|
|
|
|
}, cwd: bds.bds_dir_pocketmine});
|
|
|
|
|
} else throw Error("")
|
|
|
|
|
Storage.setItem("old_log_file", bds.log_file)
|
|
|
|
|
start_server.stdout.on("data", function(data){
|
|
|
|
|
if (data.includes("agree", "EULA")){
|
|
|
|
|
const path = require("path");
|
|
|
|
|
require("open")("https://account.mojang.com/documents/minecraft_eula");
|
|
|
|
|
const eula_file = path.join(bds.bds_dir_java, "eula.txt")
|
|
|
|
|
fs.writeFileSync(eula_file, fs.readFileSync(eula_file, "utf8").replace("eula=false", "eula=true"))
|
|
|
|
|
if (process.argv[0].includes("node")){
|
|
|
|
|
console.warn("Ending the process")
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
process.exit(0)
|
|
|
|
|
}, 1000);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
start_server.stdout.pipe(fs.createWriteStream(bds.log_file, {flags: "a"}));
|
|
|
|
|
start_server.stdout.pipe(fs.createWriteStream(path.join(bds.bds_dir, "log", "latest.log"), {flags: "w"}));
|
|
|
|
|
if (typeof bds_log_string !== "undefined"){bds_log_string = ""}
|
|
|
|
|
start_server.stdout.on("data", function(data){if (global.bds_log_string === undefined) global.bds_log_string = data;else global.bds_log_string += data})
|
|
|
|
|
Storage.setItem("bds_status", true);
|
|
|
|
|