Pocketmine init #79
@ -2,7 +2,7 @@ const { existsSync, mkdirSync, writeFileSync, chmodSync } = require("fs")
|
|||||||
const { resolve, join } = require("path")
|
const { resolve, join } = require("path")
|
||||||
const binFolder = resolve((process.env.USERPROFILE||process.env.HOME), "bds_core", "bin")
|
const binFolder = resolve((process.env.USERPROFILE||process.env.HOME), "bds_core", "bin")
|
||||||
|
|
||||||
if (typeof fetch === "undefined") {var fetch = require("node-fetch")}
|
if (typeof fetch === "undefined") {global.fetch = require("node-fetch")}
|
||||||
(function (){
|
(function (){
|
||||||
if (require("command-exists").sync("curl")) {console.log("Curl is already installed.");process.exit(0)}
|
if (require("command-exists").sync("curl")) {console.log("Curl is already installed.");process.exit(0)}
|
||||||
else {
|
else {
|
||||||
|
@ -4,7 +4,7 @@ const {exec, execSync} = require("child_process");
|
|||||||
const fs = require("fs")
|
const fs = require("fs")
|
||||||
const path = require("path")
|
const path = require("path")
|
||||||
const {CheckBan} = require("./check");
|
const {CheckBan} = require("./check");
|
||||||
const { resolve } = require("path");
|
const { resolve, join } = require("path");
|
||||||
const commandExists = require("command-exists").sync
|
const commandExists = require("command-exists").sync
|
||||||
|
|
||||||
module.exports.start = () => {
|
module.exports.start = () => {
|
||||||
@ -41,60 +41,6 @@ module.exports.start = () => {
|
|||||||
...process.env,
|
...process.env,
|
||||||
LD_LIBRARY_PATH: bds.bds_dir_bedrock
|
LD_LIBRARY_PATH: bds.bds_dir_bedrock
|
||||||
}, cwd: 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){
|
start_server.stdout.on("data", function(data){
|
||||||
data = data.split("\n")
|
data = data.split("\n")
|
||||||
var username;
|
var username;
|
||||||
@ -157,9 +103,57 @@ module.exports.start = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else if (bds.bds_config.bds_platform === "java"){
|
} else if (process.platform === "darwin") throw Error("We don't have MacOS support yet")
|
||||||
console.log("Java is not yet supported the user list");
|
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 = ""}
|
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})
|
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);
|
Storage.setItem("bds_status", true);
|
||||||
|
@ -96,9 +96,7 @@ server-authoritative-block-breaking=false
|
|||||||
|
|
||||||
} else if (bds.platform === "java") {
|
} else if (bds.platform === "java") {
|
||||||
hardcore = "false"
|
hardcore = "false"
|
||||||
if (gamemode === "survival") null
|
if (gamemode === "hardcore") {gamemode = 0;hardcore = "true"}
|
||||||
else if (gamemode === "creative") null
|
|
||||||
else {gamemode = 0;hardcore = "true"}
|
|
||||||
config_file_content = `enable-jmx-monitoring=false
|
config_file_content = `enable-jmx-monitoring=false
|
||||||
rcon.port=25575
|
rcon.port=25575
|
||||||
level-seed=
|
level-seed=
|
||||||
|
@ -116,7 +116,7 @@ module.exports = function (version, force_install) {
|
|||||||
if (test.includes("extension_dir")) check_extension_dir = true;
|
if (test.includes("extension_dir")) check_extension_dir = true;
|
||||||
console.log(test);
|
console.log(test);
|
||||||
}
|
}
|
||||||
if (check_extension_dir) console.log("Pulando configuração do php.ini");
|
if (check_extension_dir) console.log("Skipping php.ini configuration");
|
||||||
else {
|
else {
|
||||||
const phpExtensiosnsDir = resolve(bds_dir_pocketmine, "bin/php7/lib/php/extensions")
|
const phpExtensiosnsDir = resolve(bds_dir_pocketmine, "bin/php7/lib/php/extensions")
|
||||||
const phpExtensiosns = readdirSync(phpExtensiosnsDir)
|
const phpExtensiosns = readdirSync(phpExtensiosnsDir)
|
||||||
|
Reference in New Issue
Block a user