Pocketmine init #79
@ -54,7 +54,7 @@ if (!(existsSync(server_exec))) {
|
||||
if (bds_version){
|
||||
try {
|
||||
process.env.BDS_DOCKER_IMAGE = true
|
||||
bds.download(bds_version)
|
||||
bds.download(bds_version, true)
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
process.exit(165)
|
||||
|
10
index.js
10
index.js
@ -221,9 +221,9 @@ module.exports.PHPurlNames = PHPurlNames
|
||||
// Configs
|
||||
var bds_config, bds_config_file = path.join(bds_dir, "bds_config.json");
|
||||
const current_version_bds_core = bds_maneger_version
|
||||
var default_porcess;
|
||||
if (process.platform.includes("win32", "linux")) default_porcess = "bedrock"
|
||||
else default_porcess = "java"
|
||||
var default_platformConfig;
|
||||
if (process.platform.includes("win32", "linux")) default_platformConfig = "bedrock"
|
||||
else default_platformConfig = "java"
|
||||
if (fs.existsSync(bds_config_file)){
|
||||
bds_config = JSON.parse(fs.readFileSync(bds_config_file, "utf8"))
|
||||
if (bds_config.version !== current_version_bds_core){
|
||||
@ -234,7 +234,7 @@ if (fs.existsSync(bds_config_file)){
|
||||
bds_config = {
|
||||
"version": current_version_bds_core,
|
||||
"bds_pages": (bds_config.bds_pages||"default"),
|
||||
"bds_platform": (bds_config.bds_platform||default_porcess),
|
||||
"bds_platform": (bds_config.bds_platform||default_platformConfig),
|
||||
"platform_version": {
|
||||
"bedrock": (bds_config.platform_version.bedrock||"latest"),
|
||||
"java": (bds_config.platform_version.java||"latest")
|
||||
@ -260,7 +260,7 @@ if (fs.existsSync(bds_config_file)){
|
||||
bds_config = {
|
||||
"version": current_version_bds_core,
|
||||
"bds_pages": "default",
|
||||
"bds_platform": default_porcess,
|
||||
"bds_platform": default_platformConfig,
|
||||
"platform_version": {
|
||||
"bedrock": "latest",
|
||||
"java": "latest"
|
||||
|
@ -5,6 +5,7 @@ const fs = require("fs")
|
||||
const path = require("path")
|
||||
const {CheckBan} = require("./check");
|
||||
const { resolve } = require("path");
|
||||
const commandExists = require("command-exists").sync
|
||||
|
||||
module.exports.start = () => {
|
||||
function KickPlayer(player){
|
||||
@ -57,8 +58,21 @@ module.exports.start = () => {
|
||||
}
|
||||
}
|
||||
} else if (plat === "pocketmine") {
|
||||
start_server = exec(`${resolve(bds.bds_dir_pocketmine, "bin/php7/bin/php")} ${resolve(bds.bds_dir_pocketmine, "PocketMine-MP.phar")}`, {env: {
|
||||
...process.env,
|
||||
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)
|
||||
|
@ -6,7 +6,9 @@ function bds_config(json_config){
|
||||
|
||||
var Server_Config;
|
||||
if (bds.platform === "java") Server_Config = path.join(bds.bds_dir_java, "server.properties");
|
||||
else Server_Config = path.join(bds.bds_dir_bedrock, "server.properties");
|
||||
else if (bds.platform === "bedrock") Server_Config = path.join(bds.bds_dir_bedrock, "server.properties");
|
||||
else if (bds.platform === "pocketmine") Server_Config = path.join(bds.bds_dir_pocketmine, "server.properties");
|
||||
else throw Error("Bds Maneger Config, Platforms not valid: "+bds.platform)
|
||||
|
||||
var CPU
|
||||
if (2 < cpuCount - 2) CPU = cpuCount - 2;
|
||||
@ -18,8 +20,8 @@ function bds_config(json_config){
|
||||
|
||||
//
|
||||
var
|
||||
description_name = "Dedicated Server",
|
||||
level_name = "Bedrock level",
|
||||
description_name = "A minecraft server",
|
||||
level_name = "Minecraft World",
|
||||
gamemode = "survival",
|
||||
difficulty = "easy",
|
||||
allow_cheats = false,
|
||||
@ -29,7 +31,8 @@ function bds_config(json_config){
|
||||
server_port = 19132,
|
||||
server_portv6 = 19133,
|
||||
player_permission = "member",
|
||||
tick = 0
|
||||
tick = 0,
|
||||
hardcore;
|
||||
|
||||
if (config.description !== undefined) description_name = config.description;
|
||||
|
||||
@ -91,7 +94,11 @@ server-authoritative-block-breaking=false
|
||||
|
||||
# Created on Bds-Manager by Sirherobrine23`
|
||||
|
||||
} else {
|
||||
} else if (bds.platform === "java") {
|
||||
hardcore = "false"
|
||||
if (gamemode === "survival") null
|
||||
else if (gamemode === "creative") null
|
||||
else {gamemode = 0;hardcore = "true"}
|
||||
config_file_content = `enable-jmx-monitoring=false
|
||||
rcon.port=25575
|
||||
level-seed=
|
||||
@ -101,7 +108,7 @@ enable-query=true
|
||||
generator-settings=
|
||||
level-name=${level_name}
|
||||
motd=${description_name}
|
||||
query.port=${server_port}
|
||||
query.port=${server_port+1}
|
||||
pvp=true
|
||||
generate-structures=true
|
||||
difficulty=${difficulty}
|
||||
@ -128,7 +135,7 @@ rcon.password=25as65d3
|
||||
player-idle-timeout=0
|
||||
force-gamemode=false
|
||||
rate-limit=0
|
||||
hardcore=false
|
||||
hardcore=${hardcore}
|
||||
white-list=${white_list}
|
||||
broadcast-console-to-ops=true
|
||||
spawn-npcs=true
|
||||
@ -144,10 +151,39 @@ spawn-protection=16
|
||||
max-world-size=29999984
|
||||
#
|
||||
# Created on Bds-Manager by Sirherobrine23`
|
||||
}
|
||||
// console.log(config_file_content);
|
||||
fs.writeFileSync(Server_Config, config_file_content);
|
||||
return true
|
||||
} else if (bds.platform === "pocketmine") {
|
||||
hardcore = "off"
|
||||
if (gamemode === "survival") gamemode = 0
|
||||
else if (gamemode === "creative") gamemode = 1
|
||||
else {gamemode = 0;hardcore = "on"}
|
||||
config_file_content = `language=eng
|
||||
motd=${description_name}
|
||||
server-port=${server_port}
|
||||
white-list=off
|
||||
announce-player-achievements=on
|
||||
spawn-protection=16
|
||||
max-players=${max_players}
|
||||
gamemode=${gamemode}
|
||||
force-gamemode=off
|
||||
hardcore=${hardcore}
|
||||
pvp=on
|
||||
difficulty=2
|
||||
generator-settings=
|
||||
level-name=${level_name}
|
||||
level-seed=
|
||||
level-type=DEFAULT
|
||||
enable-query=on
|
||||
enable-rcon=off
|
||||
rcon.password=F/deZ5kefY
|
||||
auto-save=on
|
||||
view-distance=${tick}
|
||||
xbox-auth=on
|
||||
#
|
||||
# Created on Bds-Manager by Sirherobrine23`
|
||||
} else throw Error("Plaforms not valid: "+bds.platform)
|
||||
// Write file
|
||||
fs.writeFileSync(Server_Config, config_file_content);
|
||||
return true
|
||||
}
|
||||
function bds_get_config(){
|
||||
var fs = require("fs");
|
||||
|
@ -1,10 +1,11 @@
|
||||
var AdmZip = require("adm-zip");
|
||||
const { warn } = require("console");
|
||||
const {writeFileSync, existsSync, readFileSync} = require("fs");
|
||||
const { join } = require("path");
|
||||
const {writeFileSync, existsSync, readFileSync, readdirSync} = require("fs");
|
||||
const { join, resolve } = require("path");
|
||||
const {bds_config, bds_dir_bedrock, bds_dir_java, platform_version_update, valid_platform, PHPurlNames, bds_dir_pocketmine, PHPbinsUrls} = require("../index")
|
||||
const bdsSystem = require("../index").system
|
||||
const response = require("../index").SERVER_URLs
|
||||
const commandExists = require("command-exists").sync
|
||||
module.exports = function (version, force_install) {
|
||||
try {
|
||||
if (version === "") version="latest"
|
||||
@ -74,7 +75,11 @@ module.exports = function (version, force_install) {
|
||||
console.log("PocketMine-MP.phar saved");
|
||||
platform_version_update(version)
|
||||
const binFolder = join(bds_dir_pocketmine, "bin")
|
||||
if (!(existsSync(binFolder))) {
|
||||
var CheckBinPHPFolder;
|
||||
if (existsSync(binFolder)) CheckBinPHPFolder = false
|
||||
else if (commandExists("php")) CheckBinPHPFolder = false
|
||||
else CheckBinPHPFolder = true
|
||||
if (CheckBinPHPFolder||force_install) {
|
||||
var urlPHPBin;
|
||||
for (let index in PHPurlNames){
|
||||
const nameFile = PHPurlNames[index]
|
||||
@ -102,6 +107,27 @@ module.exports = function (version, force_install) {
|
||||
var zipExtractBin = new AdmZip(response);
|
||||
zipExtractBin.extractAllTo(bds_dir_pocketmine, true)
|
||||
console.log("Extract Sucess")
|
||||
const phpBinFolder = resolve(bds_dir_pocketmine, "bin")
|
||||
const phpIni = readFileSync(join(phpBinFolder, "php7", "bin", "php.ini"), "utf-8")
|
||||
const phpIniSplit = phpIni.split("\n")
|
||||
var check_extension_dir = false
|
||||
for (let index in phpIniSplit){
|
||||
let test = phpIniSplit[index]
|
||||
if (test.includes("extension_dir")) check_extension_dir = true;
|
||||
console.log(test);
|
||||
}
|
||||
if (check_extension_dir) console.log("Pulando configuração do php.ini");
|
||||
else {
|
||||
const phpExtensiosnsDir = resolve(bds_dir_pocketmine, "bin/php7/lib/php/extensions")
|
||||
const phpExtensiosns = readdirSync(phpExtensiosnsDir)
|
||||
var exetensionZen;
|
||||
for (let index2 in phpExtensiosns){
|
||||
|
||||
if (phpExtensiosns[index2].includes("debug-zts")) exetensionZen = phpExtensiosns[index2]
|
||||
}
|
||||
phpIniSplit.push(`extension_dir="${resolve(phpExtensiosnsDir, exetensionZen)}"`)
|
||||
writeFileSync(join(phpBinFolder, "php7", "bin", "php.ini"), phpIniSplit.join("\n"))
|
||||
}
|
||||
if (process.env.BDS_DOCKER_IMAGE === "true") process.exit(0);
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user