Merge #31

Merged
Sirherobrine23 merged 14 commits from main into stable 2021-02-09 17:53:17 +00:00
20 changed files with 3832 additions and 166 deletions
Showing only changes of commit 20751eb40a - Show all commits

21
.eslintrc.json Normal file
View File

@ -0,0 +1,21 @@
{
"env": {
"browser": true,
"commonjs": true,
"es2021": true,
"node": true,
"shelljs": true
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 12,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"rules": {
"quotes": ["error", "double"],
"eqeqeq": 0
}
}

5
.github/workflows/get_version.sh vendored Normal file
View File

@ -0,0 +1,5 @@
#!/bin/bash
v=`cat package.json | jq '.version' | sed "s|\"||g"`
d=`cat package.json | jq '.dependencies'|tr "\n" " "|sed "s|\^||g"|sed "s| ||g"`
echo "bds_api_version=${v}" >> $GITHUB_ENV
echo "bds_api_depe=${d} >> $GITHUB_ENV

View File

@ -67,10 +67,7 @@ jobs:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Get Infos
run: |
sudo apt install -y jq
echo "bds_api_version=$(cat package.json | jq '.version'|sed "s|\"||g")" >> $GITHUB_ENV
echo "bds_api_depe=$(cat package.json | jq '.dependencies'|tr "\n" " "|sed "s|\^||g"|sed "s| ||g") >> $GITHUB_ENV
run: bash .github/workflows/get_version.sh
- name: Tag
uses: softprops/action-gh-release@v1
@ -78,7 +75,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: Bds Maneger API v${{ env.bds_api_version }}
tag_name: ${{ env.bds_api_version }}
tag_name: ${{ github.run_id }}
prerelease: true
body: |
Install: npm install bds_maneger_api@dev

View File

@ -58,9 +58,7 @@ jobs:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Get Infos
run: |
echo "bds_api_version=$(cat package.json | jq '.version'|sed "s|\"||g")" >> $GITHUB_ENV
echo "bds_api_depe=\"$(cat package.json | jq '.dependencies'|tr "\n" " "|sed "s|\^||g"|sed "s| ||g")\"" >> $GITHUB_ENV
run: bash .github/workflows/get_version.sh
- name: Tag
uses: softprops/action-gh-release@v1

View File

@ -4,7 +4,7 @@ module.exports = () => {
const bds = require("../index");
const fs = require("fs");
const app = express();
var cors = require('cors');
var cors = require("cors");
app.use(cors());
const rateLimit = require("express-rate-limit");
const limiter = rateLimit({
@ -17,16 +17,16 @@ module.exports = () => {
max: 5000 // limit each IP to 5000 requests per windowMs
});
app.use(limiter);
const requestIp = require('request-ip');
const requestIp = require("request-ip");
app.use(requestIp.mw())
app.get("/", (req, res) => {
if (typeof bds_log_string === 'undefined'){
if (typeof bds_log_string === "undefined"){
if (fs.existsSync(localStorage.getItem("old_log_file"))){
var text = `${fs.readFileSync(localStorage.getItem("old_log_file"), "utf8")}`
var log_file = localStorage.getItem("old_log_file")
var sucess = true
} else {
var text = `The server is stopped`
var text = "The server is stopped"
var sucess = false
}
} else {

View File

@ -42,7 +42,7 @@ function getAccessToken(oAuth2Client, callback) {
callback(oAuth2Client);
});
});
};
}
module.exports.drive_backup = () => {
const file_json = require("../scripts/backups").Drive_backup()
@ -51,7 +51,7 @@ module.exports.drive_backup = () => {
const path_file = file_json.file_path
const name_d = file_json.file_name;
const gd_secret = '';
const gd_secret = "";
console.log(gd_secret)
function upload_backup(auth) {
const drive = google.drive({version: "v3", auth});
@ -65,7 +65,7 @@ module.exports.drive_backup = () => {
name: name_d,
parents: [parent_id]
}
};
}
var media = {
mimeType: "application/octet-stream",
body: fs.createReadStream(path_file)
@ -101,6 +101,6 @@ module.exports.mcpe = () => {
progress += d.length / 1024 / 1024;
if (process.stdout.isTTY) {process.stdout.clearLine();process.stdout.cursorTo(0);process.stdout.write(`Downloaded ${Math.trunc(progress)} Mbytes`);}
}).pipe(dest)});
};
}
return authorize(gd_secret, download_mcpe);
}

View File

@ -3,7 +3,7 @@ module.exports.checkUser = (USERNAME) => {
if (fs.existsSync(`${require("../index").bds_dir}/telegram_admin.json`)) {
var admins = fs.readFileSync(`${require("../index").bds_dir}/telegram_admin.json`, "utf-8");
} else {
var admins = `{"sh23_bot_not_config": {"allow": true}}`;
var admins = "{\"sh23_bot_not_config\": {\"allow\": true}}";
console.warn("All allowed")
console.log(`Create file in with name: ${require("../index").bds_dir}/telegram_admin.json`)
}
@ -14,8 +14,8 @@ module.exports.checkUser = (USERNAME) => {
} else if (check_ == "sh23_bot_not_config"){
console.warn("Allow all")
return true
}; check_++;
};
} check_++;
}
return false
}

View File

@ -27,27 +27,27 @@ bot.command("server_start", (ctx) => {
document.getElementById("startButtom").click()
} else {
require("../index").start()
};
ctx.reply(`The server has started`)
}
ctx.reply("The server has started")
} else
ctx.reply(`${ctx.message.from.username} already started`)
} else {
console.log("Erro");
ctx.reply(`Please contact the Server Administrator, You are not on the list, I count to add your username \(${ctx.message.from.username}\) on the whitelist`)
};
}
});
bot.command("server_stop", (ctx) => {
if (require("./check").checkUser(ctx.message.from.username)){
const bds_status = require("../index").detect()
if (bds_status){
require("../index").stop()
ctx.reply(`O servidor esta parando`)
ctx.reply("O servidor esta parando")
} else
ctx.reply(`${ctx.message.from.username} o servidor está parado`)
} else {
console.log("Erro");
ctx.reply(`Please contact the Server Administrator, You are not on the list, I count to add your username \(${ctx.message.from.username}\) on the whitelist`)
};
}
});
bot.command("command", (ctx) =>{
const bds_command = require("../index").command

View File

@ -34,7 +34,7 @@ const arch = process.arch
if (arch == "x64"){
var archi = "amd64"
} else if (arch == "arm64"){
console.warn(`It is not recommended to use platforms that are not amd64 (x64), please inform you that you will need to manually configure some things. \!\!`)
console.warn("It is not recommended to use platforms that are not amd64 (x64), please inform you that you will need to manually configure some things. \!\!")
var archi = "arm"
} else {
console.warn(`Unsupported processor, ${arch} will not be supported by The Bds Maneger`)
@ -52,11 +52,11 @@ if (process.platform == "win32") {
} else if (package_root_builder){
var cache_dir = path.join(home, "AppData", "Roaming", require(package_root_builder).name)
} else {
console.warn(`Temporary Storages, some functions will be lost after restarting the system`);
var cache_dir = path.join(process.env.TMP, `bds_tmp_configs`);
console.warn("Temporary Storages, some functions will be lost after restarting the system");
var cache_dir = path.join(process.env.TMP, "bds_tmp_configs");
}
var tmp = process.env.TMP
var system = `windows`;
var system = "windows";
} else if (process.platform == "linux") {
var home = process.env.HOME;
if (fs.existsSync(package_root)){
@ -64,14 +64,14 @@ if (process.platform == "win32") {
} else if (fs.existsSync(package_root_builder)) {
var cache_dir = path.join(home, ".config", require(package_root_builder).name);
} else {
console.warn(`Temporary Storages, some functions will be lost after restarting the system`);
var cache_dir = `/tmp/bds_tmp_configs`;
console.warn("Temporary Storages, some functions will be lost after restarting the system");
var cache_dir = "/tmp/bds_tmp_configs";
}
var file = path.join(home, ".config", "user-dirs.dirs");var data = {};
if (fs.existsSync(file)){let content = fs.readFileSync(file,"utf8");let lines = content.split(/\r?\n/g).filter((a)=> !a.startsWith("#"));for(let line of lines){let i = line.indexOf("=");if(i >= 0){try{data[line.substring(0,i)] = JSON.parse(line.substring(i + 1))}catch(e){}}}};if(data["XDG_DESKTOP_DIR"]){var desktop = data["XDG_DESKTOP_DIR"];desktop = desktop.replace(/\$([A-Za-z\-\_]+)|\$\{([^\{^\}]+)\}/g, (_, a, b) => (process.env[a || b] || ""))}else{var desktop = "/tmp"}
if (fs.existsSync(file)){let content = fs.readFileSync(file,"utf8");let lines = content.split(/\r?\n/g).filter((a)=> !a.startsWith("#"));for(let line of lines){let i = line.indexOf("=");if(i >= 0){try{data[line.substring(0,i)] = JSON.parse(line.substring(i + 1))}catch(e){}}}}if(data["XDG_DESKTOP_DIR"]){var desktop = data["XDG_DESKTOP_DIR"];desktop = desktop.replace(/\$([A-Za-z\-\_]+)|\$\{([^\{^\}]+)\}/g, (_, a, b) => (process.env[a || b] || ""))}else{var desktop = "/tmp"}
var tmp = `/tmp`;
var system = `linux`;
var tmp = "/tmp";
var system = "linux";
} else if (process.platform == "darwin") {
require("open")("https://github.com/Bds-Maneger/Bds_Maneger/wiki/systems-support#a-message-for-mac-os-users")
console.error("Please use Windows or Linux MacOS Not yet supported")
@ -79,7 +79,7 @@ if (process.platform == "win32") {
} else {
console.log(`Please use an operating system (OS) compatible with Minecraft Bedrock Server ${process.platform} is not supported`);
process.exit(2021)
};
}
// ---------
// ---------
if (typeof fetch === "undefined"){
@ -87,12 +87,12 @@ if (typeof fetch === "undefined"){
}
if (typeof localStorage === "undefined"){
var localStorageS = require("node-localstorage").LocalStorage;
global.localStorage = new localStorageS(path.join(cache_dir, `Local_Storage`));
global.localStorage = new localStorageS(path.join(cache_dir, "Local_Storage"));
}
var bds_dir = path.join(home, "bds_Server");
var bds_dir_bedrock = path.join(bds_dir, 'bedrock');
var bds_dir_java = path.join(bds_dir, 'java');
var bds_dir_backup = path.join(bds_dir, 'backups');
var bds_dir_bedrock = path.join(bds_dir, "bedrock");
var bds_dir_java = path.join(bds_dir, "java");
var bds_dir_backup = path.join(bds_dir, "backups");
module.exports.backup_folder = bds_dir_backup
if (!(fs.existsSync(bds_dir))){
@ -147,8 +147,8 @@ if (!(fs.existsSync(log_dir))){
console.log(`Creating the bds log dir (${log_dir})`)
fs.mkdirSync(log_dir)
if (!(fs.existsSync(log_dir))) shell.mkdir("-p", log_dir)
};
};
}
}
// e
@ -198,9 +198,9 @@ if (require("fs").existsSync(path.join(bds_dir, "telegram_token.txt"))){
const token = fs.readFileSync(path.join(bds_dir, "telegram_token.txt"), "utf-8").split("\n").join("")
require("./index").telegram_token_save(token)
fs.rmSync(path.join(bds_dir, "telegram_token.txt"))
console.log(`We finished migrating the old telegram token file`)
console.log("We finished migrating the old telegram token file")
} catch {
throw new error(`It was not possible to move the old telegram token file to the new bds maneger api file`)
throw new error("It was not possible to move the old telegram token file to the new bds maneger api file")
}
}
@ -235,7 +235,7 @@ fetch("https://raw.githubusercontent.com/Bds-Maneger/Raw_files/main/Server.json"
var html = `${versions[v]}`;
module.exports.version_select += `<option value=\"${html}\">${html}</option>\n`;
v++;
};
}
module.exports.bedrock_all_versions = Object.getOwnPropertyNames(rawOUT.bedrock);
module.exports.java_all_versions = Object.getOwnPropertyNames(rawOUT.java);
module.exports.bds_latest = rawOUT.bedrock_lateste;
@ -248,7 +248,7 @@ fetch("https://raw.githubusercontent.com/Bds-Maneger/Raw_files/main/Server.json"
require("./API/log")();
}
} else {
console.warn(`The API via http is disabled, for more information, visit https://docs.srherobrine23.com/enable_bds_requests.html`)
console.warn("The API via http is disabled, for more information, visit https://docs.srherobrine23.com/enable_bds_requests.html")
}
module.exports.get_version = (type) => {
if (type == "raw")
@ -312,7 +312,7 @@ module.exports.telegram = require("./global/telegram_bot")
module.exports.change_platform = platform_update
module.exports.token_register = () => {
if (!(fs.existsSync(path.join(bds_dir, "bds_tokens.json")))){
fs.writeFileSync(path.join(bds_dir, "bds_tokens.json"), "[]")};
fs.writeFileSync(path.join(bds_dir, "bds_tokens.json"), "[]")}
require("crypto").randomBytes(10, function(err, buffer) {
var token = buffer.toString("hex");
console.log(token);

3418
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -5,7 +5,8 @@
"private": false,
"main": "index.js",
"scripts": {
"test": "exit 0",
"test": "eslint .",
"test:fix": "eslint --fix .",
"server": "node index.js"
},
"repository": {
@ -41,12 +42,15 @@
"properties-to-json": "^0.1.7",
"qr-image": "^3.2.0",
"qrcode": "^1.4.4",
"request-ip": "^2.1.3",
"shelljs": "^0.8.4",
"systeminformation": "^5.0.10",
"request-ip": "^2.1.3",
"telegraf": "^4.0.0"
},
"engines": {
"node": ">=14"
},
"devDependencies": {
"eslint": "^7.19.0"
}
}

View File

@ -1,5 +1,5 @@
module.exports.World_BAckup = () => {
const bds = require('../index')
const bds = require("../index")
const path = require("path")
const java_pro = require("properties-to-json")
const fs = require("fs")
@ -33,7 +33,7 @@ module.exports.World_BAckup = () => {
};
module.exports.Drive_backup = () => {
const bds = require('../index')
const bds = require("../index")
const path = require("path")
const java_pro = require("properties-to-json")
const fs = require("fs")

View File

@ -2,32 +2,32 @@ module.exports.start = () => {
const bds = require("../index")
const Storage = localStorage;
const {exec, execSync} = require("child_process");
const fs = require('fs')
const fs = require("fs")
if (!(bds.detect())){
const plat = bds.platform
if (plat === "bedrock"){
if (process.platform == "win32"){
var start_server = exec(`bedrock_server.exe`, {cwd: bds.bds_dir_bedrock});
var start_server = exec("bedrock_server.exe", {cwd: bds.bds_dir_bedrock});
} else if (process.platform == "linux"){
console.log(execSync(`chmod 777 bedrock_server`, {cwd: bds.bds_dir_bedrock}).toString())
var start_server = exec(`./bedrock_server`, {env: {PATH: process.env.PATH, LD_LIBRARY_PATH: bds.bds_dir_bedrock}, cwd: bds.bds_dir_bedrock});
console.log(execSync("chmod 777 bedrock_server", {cwd: bds.bds_dir_bedrock}).toString())
var start_server = exec("./bedrock_server", {env: {PATH: process.env.PATH, LD_LIBRARY_PATH: bds.bds_dir_bedrock}, cwd: bds.bds_dir_bedrock});
} else {
process.exit(210)
}
} else {
if (require('command-exists').sync('java')){
var start_server = exec(`java -Xmx1024M -Xms1024M -jar server.jar nogui`, {cwd: bds.bds_dir_java});
if (require("command-exists").sync("java")){
var start_server = exec("java -Xmx1024M -Xms1024M -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");
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");
} 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");
require("open")("http://docs.sirherobrine23.com/bds_maneger_api_java");
console.log("http://docs.sirherobrine23.com/bds_maneger_api_java")
}
}
@ -39,14 +39,14 @@ module.exports.start = () => {
start_server.stdout.pipe(logConsoleStream);
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 path = require("path");
require("open")("https://account.mojang.com/documents/minecraft_eula");
const eula_file = path.join(bds.bds_dir_java, "eula.txt")
const eula_make_true = fs.readFileSync(eula_file, "utf-8").replace("eula=false", "eula=true")
fs.writeFileSync(eula_file, eula_make_true)
const node_detect = process.argv[0]
if (node_detect.includes('node')){
console.warn(`Ending the process`)
if (node_detect.includes("node")){
console.warn("Ending the process")
setTimeout(() => {
process.exit(0)
}, 1000);
@ -59,22 +59,22 @@ module.exports.start = () => {
global.bds_server_string = start_server;
return start_server;
} else {
console.warn(`You already have a server running`);
return `You already have a server running`;
console.warn("You already have a server running");
return "You already have a server running";
}
}
module.exports.stop = () => {
if (typeof bds_server_string == "undefined"){
const detect = process.argv[0];
if (detect.includes('electron')) alert("The server is stopped!");
if (detect.includes("electron")) alert("The server is stopped!");
else console.log("The server is stopped!");
} else {
bds_server_string.stdin.write("stop\n");
bds_server_string.stdout.on("data", function (data){
if (data.includes("Quit correctly")){
localStorage.setItem("bds_status", false)
};
}
});
};
}
return
}

View File

@ -1,12 +1,12 @@
module.exports = (Vdown) => {
console.warn("Do not exit BDS Manager")
const bds = require('../index')
const bds = require("../index")
fetch("https://raw.githubusercontent.com/Bds-Maneger/Raw_files/main/Server.json").then(response => response.json()).then(versions => {
if (bds.platform === "bedrock"){
const system = bds.system
var mine_name = `bedrock.zip`
if (system === 'linux'){
var mine_name = "bedrock.zip"
if (system === "linux"){
var versions_get = versions.bedrock[Vdown].url_linux;
} else {
var versions_get = versions.bedrock[Vdown].url_windows;
@ -21,7 +21,7 @@ module.exports = (Vdown) => {
downloadBDSchild.stdout.on("data", function(data){console.log(data)})
downloadBDSchild.on("exit", function (code) {
if (code === 0) {
console.log(`Download zip file success`);
console.log("Download zip file success");
var server_DIR = bds.bds_dir_bedrock;
var ZIP_FILE_PATH = require("path").join(bds.tmp_dir, mine_name);
var AdmZip = require("adm-zip");
@ -29,7 +29,7 @@ module.exports = (Vdown) => {
if (fs.existsSync(`${server_DIR}/server.properties`)){var _old = true;var old1 = fs.readFileSync(`${server_DIR}/server.properties`, "utf-8");}
if (fs.existsSync(`${server_DIR}/permissions.json`)){var _old2 = true;var old2 = fs.readFileSync(`${server_DIR}/permissions.json`, "utf-8");}
if (fs.existsSync(`${server_DIR}/whitelist.json`)) {var _old3 = true;var old3 = fs.readFileSync(`${server_DIR}/whitelist.json`, "utf-8");}
if (fs.existsSync(`${server_DIR}/valid_known_packs.json`)){var _old4 = true;var old4 = fs.readFileSync(`${server_DIR}/valid_known_packs.json`, "utf-8");};
if (fs.existsSync(`${server_DIR}/valid_known_packs.json`)){var _old4 = true;var old4 = fs.readFileSync(`${server_DIR}/valid_known_packs.json`, "utf-8");}
// Unzip
var zip = new AdmZip(ZIP_FILE_PATH);
zip.extractAllTo(server_DIR, true);
@ -38,21 +38,21 @@ module.exports = (Vdown) => {
if (_old){fs.writeFileSync(`${server_DIR}/server.properties`, old1);}
if (_old2){fs.writeFileSync(`${server_DIR}/permissions.json`, old2);}
if (_old3){fs.writeFileSync(`${server_DIR}/whitelist.json`, old3);}
if (_old4){fs.writeFileSync(`${server_DIR}/valid_known_packs.json`, old4);};
if (_old4){fs.writeFileSync(`${server_DIR}/valid_known_packs.json`, old4);}
const docker_exit = process.env.BDS_DOCKER_IMAGE
console.log(docker_exit)
if (docker_exit == "true"){
console.log(`going out`)
console.log("going out")
process.exit(0)
}
} else {
localStorage.setItem("Download_sucess", "no")
throw new error(`Could not download`);
throw new error("Could not download");
}
})
} else {
var versions_get = versions.java[Vdown].url
var mine_name = `server.jar`
var mine_name = "server.jar"
console.log("Starting download")
const exec = require("child_process").exec
@ -65,11 +65,11 @@ module.exports = (Vdown) => {
})
downloadBDSchild.on("exit", function (code) {
if (code === 0) {
console.log(`Download zip file success`);
console.log("Download zip file success");
localStorage.setItem("Downlaod_sucess", "yes")
} else {
localStorage.setItem("Download_sucess", "no")
throw new error(`Could not download`);
throw new error("Could not download");
}
})
}

View File

@ -3,7 +3,7 @@ function bds_config(json_config){
const path = require("path")
var fs = require("fs")
if (bds.platform === 'java') var Server_Config = path.join(bds.bds_dir_java, "server.properties");
if (bds.platform === "java") var Server_Config = path.join(bds.bds_dir_java, "server.properties");
else var Server_Config = path.join(bds.bds_dir_bedrock, "server.properties");
const cpuCount = require("os").cpus().length;
@ -15,19 +15,19 @@ function bds_config(json_config){
var config = JSON.parse(fs.readFileSync(json_config, "utf8"))
} else var config = JSON.parse(json_config)
if (config.description == undefined) var description_name = `Dedicated Server`;
if (config.description == undefined) var description_name = "Dedicated Server";
else var description_name = config.description;
// Level Name
if (config.name == undefined) var level_name = `Bedrock level`;
if (config.name == undefined) var level_name = "Bedrock level";
else var level_name = config.name;
// gamemode
if (config.gamemode == undefined) var gamemode = `survival`;
if (config.gamemode == undefined) var gamemode = "survival";
else var gamemode = config.gamemode;
// Difficulty
if (config.difficulty == undefined) var difficulty = `easy`;
if (config.difficulty == undefined) var difficulty = "easy";
else var difficulty = config.difficulty;
// cheats
@ -43,16 +43,16 @@ function bds_config(json_config){
else var online_mode = config.xbox;
// Whitelist
if (config.white_list == undefined){var white_list = false;} else {var white_list = config.white_list;};
if (config.white_list == undefined){var white_list = false;} else {var white_list = config.white_list;}
// Server Port IPv4
if (config.port == undefined){var server_port = 19132;} else {var server_port = config.port;};
if (config.port == undefined){var server_port = 19132;} else {var server_port = config.port;}
// Server Port IPv6
if (config.port6 == undefined){var server_portv6 = 19133;} else {var server_portv6 = config.port6;};
if (config.port6 == undefined){var server_portv6 = 19133;} else {var server_portv6 = config.port6;}
// Default player permission
if (config.player_permission == undefined) var player_permission = `member`;
if (config.player_permission == undefined) var player_permission = "member";
else var player_permission = config.player_permission;
if (2 >= cpuCount) var tick = 2 ;
@ -63,7 +63,7 @@ function bds_config(json_config){
else var tick = 12
/*Save Files*/
if (bds.platform === 'bedrock'){
if (bds.platform === "bedrock"){
var config_file_content = `server-name=${description_name}
gamemode=${gamemode}
difficulty=${difficulty}
@ -147,8 +147,8 @@ max-world-size=29999984
}
// console.log(config_file_content);
fs.writeFileSync(Server_Config, config_file_content);
return `success`
};
return "success"
}
function bds_get_config(){
var fs = require("fs");
const path = require("path")

View File

@ -4,18 +4,18 @@ module.exports = () => {
if (bds.platform === "bedrock"){
if (process.platform == "win32") {
var killbds = spawn(`tasklist /fi "imagename eq bedrock_server.exe" | find /i "bedrock_server.exe" > nul & if not errorlevel 1 (echo 0) else (echo 1)`);
var killbds = spawn("tasklist /fi \"imagename eq bedrock_server.exe\" | find /i \"bedrock_server.exe\" > nul & if not errorlevel 1 (echo 0) else (echo 1)");
} else if (process.platform == "linux") {
var killbds = spawn(`ps aux|grep -v "grep"|grep "bedrock_server"|grep -q "bedrock_server";echo $?`, {shell: true});
var killbds = spawn("ps aux|grep -v \"grep\"|grep \"bedrock_server\"|grep -q \"bedrock_server\";echo $?", {shell: true});
}
} else {
if (process.platform == "win32") {
var killbds = spawn(`tasklist /fi "imagename eq server.jar" | find /i "server.jar" > nul & if not errorlevel 1 (echo 0) else (echo 1)`);
var killbds = spawn("tasklist /fi \"imagename eq server.jar\" | find /i \"server.jar\" > nul & if not errorlevel 1 (echo 0) else (echo 1)");
} else if (process.platform == "linux") {
var killbds = spawn(`ps aux|grep "jar server.jar"|grep -v 'grep'|grep -q "jar server.jar";echo $?`, {shell: true});
var killbds = spawn("ps aux|grep \"jar server.jar\"|grep -v 'grep'|grep -q \"jar server.jar\";echo $?", {shell: true});
}
}
//
console.log(`Detect code ${killbds}`)
if (killbds == 0){return true} else {return false};
if (killbds == 0){return true} else {return false}
};

View File

@ -4,13 +4,13 @@ module.exports = () => {
const Storage = localStorage
if (bds.bds_detect()){
if (bds.platform === "bedrock"){
if (process.platform == "win32") var killbds = spawn(`tasklist /fi "imagename eq bedrock_server.exe" | find /i "bedrock_server.exe" > nul & if not errorlevel 1 (taskkill /f /im "bedrock_server.exe" > nul && exit 0) else (exit 1)`);
else if (process.platform == "linux") var killbds = spawn(`kill $(ps aux|grep -v "grep"|grep "bedrock_server"|awk '{print $2}')`, {shell: true});
if (process.platform == "win32") var killbds = spawn("tasklist /fi \"imagename eq bedrock_server.exe\" | find /i \"bedrock_server.exe\" > nul & if not errorlevel 1 (taskkill /f /im \"bedrock_server.exe\" > nul && exit 0) else (exit 1)");
else if (process.platform == "linux") var killbds = spawn("kill $(ps aux|grep -v \"grep\"|grep \"bedrock_server\"|awk '{print $2}')", {shell: true});
} else {
if (process.platform == "win32") {
var killbds = spawn(`tasklist /fi "imagename eq server.jar" | find /i "server.jar" > nul & if not errorlevel 1 (taskkill /f /im "server.jar" > nul && exit 0) else (exit 1)`);
var killbds = spawn("tasklist /fi \"imagename eq server.jar\" | find /i \"server.jar\" > nul & if not errorlevel 1 (taskkill /f /im \"server.jar\" > nul && exit 0) else (exit 1)");
} else if (process.platform == "linux") {
var killbds = spawn(`kill $(ps aux|grep -v "grep"|grep "server.jar"|awk '{print $2}')`, {shell: true});
var killbds = spawn("kill $(ps aux|grep -v \"grep\"|grep \"server.jar\"|awk '{print $2}')", {shell: true});
}
}
killbds.on("exit", function () {
@ -21,5 +21,5 @@ module.exports = () => {
} else {
Storage.setItem("bds_status", false);
return false
};
}
};