This repository has been archived on 2024-01-16. You can view files and clone it, but cannot push or open issues or pull requests.
Files
Maneger/index.js

479 lines
18 KiB
JavaScript
Raw Normal View History

/* eslint-disable no-irregular-whitespace */
2021-04-23 21:40:08 -03:00
const { resolve } = require("path");
2021-04-18 23:36:41 -03:00
const { error } = console;
const { execSync } = require("child_process");
const { CronJob } = require("cron");
const path = require("path")
const fs = require("fs");
2021-04-23 21:40:08 -03:00
const { getConfigHome } = require("./GetPlatformFolder")
2021-05-02 23:11:17 -03:00
const commandExistsSync = require("./commandExist");
2021-03-24 14:51:12 +00:00
const bds_core_package = resolve(__dirname, "package.json")
const bds_maneger_version = require(bds_core_package).version
2021-05-02 23:11:17 -03:00
module.exports = require("./bdsgetPaths");
2021-04-22 19:50:21 -03:00
if (process.env.SHOW_BDS_VERSION !== undefined) console.log(`Running the Bds Maneger API in version ${bds_maneger_version}`)
function date(format) {
const today = new Date(),
yaer = today.getFullYear(),
day = String(today.getDate()).padStart(2, "0"),
month = String(today.getMonth() + 1).padStart(2, "0"),
hour = today.getHours(),
minute = today.getMinutes();
// ---------------------------------------------------------
if (format === "year") return yaer
else if (format === "day") return day
else if (format === "month") return month
else if (format === "hour") return hour
else if (format === "minute") return minute
else if (format === "hour_minu") return `${hour}-${minute}`
else return `${day}-${month}-${yaer}_${hour}-${minute}`
2020-12-04 11:33:24 -03:00
}
2021-04-23 21:40:08 -03:00
module.exports.package_path = bds_core_package
const { bds_dir, log_dir } = require("./bdsgetPaths");
2021-05-02 23:11:17 -03:00
2021-04-23 21:40:08 -03:00
// System Architect (x64, aarch64 and others)
var arch;
if (process.arch === "arm64") arch = "aarch64"; else arch = process.arch
2021-03-24 14:51:12 +00:00
module.exports.arch = arch
2021-04-23 21:40:08 -03:00
// -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
var system,
valid_platform = {
bedrock: true,
pocketmine: true,
java: true,
jsprismarine: true
}
2021-01-15 15:41:16 -03:00
if (process.platform == "win32") {
2021-04-07 23:00:30 -03:00
system = "Windows";
2021-04-29 00:35:47 -03:00
// ia32
if (process.arch !== "x64") {
valid_platform["bedrock"] = false
valid_platform["pocketmine"] = false
}
2021-01-15 15:41:16 -03:00
} else if (process.platform == "linux") {
2021-04-07 23:00:30 -03:00
system = "Linux";
2021-05-02 23:11:17 -03:00
if (commandExistsSync("qemu-x86_64-static")) {
valid_platform["bedrock"] = true
valid_platform["pocketmine"] = true
} else if (process.arch !== "x64") {
valid_platform["bedrock"] = false
valid_platform["pocketmine"] = false
}
2021-01-15 15:41:16 -03:00
} else if (process.platform == "darwin") {
if (arch === "arm64") require("open")("https://github.com/The-Bds-Maneger/core/wiki/system_support#information-for-users-of-macbooks-and-imacs-with-m1-processor")
else require("open")("https://github.com/The-Bds-Maneger/core/wiki/system_support#macos-with-intel-processors");
2021-04-07 23:00:30 -03:00
system = "MacOS";
valid_platform["bedrock"] = false
2021-04-29 01:33:44 -03:00
} else if (process.platform === "android") {
system = "Android";
valid_platform["bedrock"] = false
valid_platform["java"] = false
2020-12-12 00:37:02 -03:00
} else {
2021-04-13 12:46:08 -03:00
console.log(`The Bds Maneger Core does not support ${process.platform} systems, as no tests have been done.`);
system = "Other";
valid_platform["bedrock"] = false
valid_platform["pocketmine"] = false
2021-03-24 14:51:12 +00:00
process.exit(254)
}
2021-03-24 14:51:12 +00:00
/* ------------------------------------------------------------ Take the variables of different systems ------------------------------------------------------------ */
/**
* Platforms valid from deferents systems
*/
module.exports.valid_platform = valid_platform
2021-04-01 23:01:53 -03:00
/**
2021-03-24 14:51:12 +00:00
* Identifying a system in the script can be simple with this variable
*/
module.exports.system = system
const log_date = date();
2021-04-23 21:40:08 -03:00
module.exports.log_date = log_date;
module.exports.latest_log = path.join(bds_dir, "log", "latest.log");
2021-03-24 14:51:12 +00:00
module.exports.package_json = JSON.parse(fs.readFileSync(bds_core_package))
2021-03-24 14:51:12 +00:00
if (typeof fetch === "undefined") global.fetch = require("node-fetch");
2021-04-13 12:46:08 -03:00
if (typeof localStorage === "undefined") {
2021-04-18 23:36:41 -03:00
let Bdsname = JSON.parse(fs.readFileSync(resolve(__dirname, "package.json"))).name;
let LocalStorageFolder = path.join(getConfigHome(), Bdsname)
2021-04-13 12:46:08 -03:00
// Create localStorage folder
2021-05-04 14:46:10 -03:00
if (!(fs.existsSync(LocalStorageFolder))) fs.mkdirSync(LocalStorageFolder, {recursive: true})
2021-04-18 23:36:41 -03:00
let Local = require("node-localstorage")
global.localStorage = new Local.LocalStorage(path.join(LocalStorageFolder, "Local_Storage"));}
2021-03-24 14:51:12 +00:00
2021-04-07 23:00:30 -03:00
/* Minecraft Servers URLs and depedencies */
// urls
2021-04-23 21:40:08 -03:00
var CurlWgetCommand;
if (commandExistsSync("wget")) CurlWgetCommand = "wget -qO-";
else if (commandExistsSync("curl")) CurlWgetCommand = "curl -sS";
else throw new Error("Curl or Wget command not found")
const SERVER_URLs = JSON.parse(execSync(`${CurlWgetCommand} "https://raw.githubusercontent.com/Bds-Maneger/Raw_files/main/Server.json"`).toString())
2021-04-07 23:00:30 -03:00
module.exports.SERVER_URLs = SERVER_URLs
// PHP Bins
2021-04-23 21:40:08 -03:00
const PHPbinsUrl = JSON.parse(execSync(`${CurlWgetCommand} "https://raw.githubusercontent.com/The-Bds-Maneger/Raw_files/main/php_bin.json"`).toString())
2021-04-07 23:00:30 -03:00
module.exports.PHPbinsUrls = PHPbinsUrl
2021-04-09 13:09:07 -03:00
// PHP bins System availble in Json File
2021-04-07 23:00:30 -03:00
const PHPurlNames = Object.getOwnPropertyNames(PHPbinsUrl)
module.exports.PHPurlNames = PHPurlNames
2021-04-23 21:40:08 -03:00
// Google Drive Credentials
const GoogleDriveCredentials = JSON.parse(execSync("curl -sS \"https://raw.githubusercontent.com/Bds-Maneger/Raw_files/main/credentials.json\"").toString())
module.exports.GoogleDriveCredentials = GoogleDriveCredentials
2021-03-24 14:51:12 +00:00
/* ---------------------------------------------------------------------------- Variables ---------------------------------------------------------------------------- */
// Configs
var bds_config, bds_config_file = path.join(bds_dir, "bds_config.json");
const current_version_bds_core = bds_maneger_version
2021-04-29 00:35:47 -03:00
// Set default platform for bds maneger
var default_platformConfig;
2021-04-29 13:59:01 -03:00
if (valid_platform["bedrock"]) default_platformConfig = "bedrock";else if (valid_platform["java"]) default_platformConfig = "java"; else if (valid_platform["pocketmine"]) default_platformConfig = "pocketmine"; else default_platformConfig = "jsprismarine"
2021-04-29 00:35:47 -03:00
2021-05-04 14:46:10 -03:00
module.exports.internal_ip = require("./scripts/external_ip").internal_ip
module.exports.external_ip = require("./scripts/external_ip").external_ip
2021-04-29 00:35:47 -03:00
// Config File
if (fs.existsSync(bds_config_file)) bds_config = JSON.parse(fs.readFileSync(bds_config_file, "utf8"));else bds_config = {platform_version: {}, telegram_admin: ["all_users"]}
bds_config = {
"version": current_version_bds_core,
"bds_pages": (bds_config.bds_pages || "default"),
"bds_platform": (bds_config.bds_platform || default_platformConfig),
2021-05-02 23:11:17 -03:00
"LoadTelemetry": (() => {if (bds_config.LoadTelemetry === undefined) return true ;else return bds_config.LoadTelemetry})(),
2021-05-04 14:46:10 -03:00
"TelemetryID": (bds_config.TelemetryID || execSync(`curl -sS https://telemetry.the-bds-maneger.org/getid?external_ip=${require("./scripts/external_ip").external_ip}`).toString()),
2021-04-29 00:35:47 -03:00
"platform_version": {
2021-05-03 23:49:40 -03:00
"bedrock": (bds_config.platform_version.bedrock || null),
"java": (bds_config.platform_version.java || null),
"pocketmine": (bds_config.platform_version.pocketmine || null),
2021-04-29 00:35:47 -03:00
"jsprismarine": "latest"
},
"bds_ban": (bds_config.bds_ban || ["Steve", "Alex", "steve", "alex"]),
"telegram_token": (bds_config.telegram_token || "not User defined"),
"Google_Drive_root_backup_id": (bds_config.Google_Drive_root_backup_id || undefined),
"BackupCron": (bds_config.BackupCron||[]),
"telegram_admin": bds_config.telegram_admin
}
2021-04-29 00:35:47 -03:00
fs.writeFileSync(bds_config_file, JSON.stringify(bds_config, null, 4))
bds_config_export()
2021-04-23 21:40:08 -03:00
require("./logger")
2021-05-02 23:11:17 -03:00
2021-04-23 21:40:08 -03:00
/**
* Update bds config version installed
*
* @param bedrock
* @param java
* @param pocketmine
*/
module.exports.platform_version_update = function (version){
let bds_config = JSON.parse(fs.readFileSync(bds_config_file, "utf8"))
if (bds_config.bds_platform === "bedrock") bds_config.platform_version.bedrock = version
2021-04-10 21:58:18 -03:00
else if (bds_config.bds_platform === "java") bds_config.platform_version.java = version
2021-04-29 00:35:47 -03:00
else if (bds_config.bds_platform === "pocketmine") bds_config.platform_version.pocketmine = version
else if (bds_config.bds_platform === "jsprismarine") bds_config.platform_version.jsprismarine = version
fs.writeFileSync(bds_config_file, JSON.stringify(bds_config, null, 4))
bds_config_export()
2021-04-23 21:40:08 -03:00
};
2021-04-10 00:17:40 -03:00
/**
* Save ID Google Drive folder to Backups
*/
module.exports.save_google_id = function (id){
let bds_config = JSON.parse(fs.readFileSync(bds_config_file, "utf8"))
bds_config.Google_Drive_root_backup_id = id
fs.writeFileSync(bds_config_file, JSON.stringify(bds_config, null, 4))
bds_config_export()
return true
}
2021-04-23 21:40:08 -03:00
module.exports.platform = bds_config.bds_platform
2021-04-18 23:36:41 -03:00
module.exports.bds_platform = bds_config.bds_platform
2021-03-24 14:51:12 +00:00
/**
2021-04-10 00:17:40 -03:00
* Bds Maneger Latest log file.
*/
2021-04-10 00:17:40 -03:00
const log_file = path.join(log_dir, `${date()}_${bds_config.bds_platform}_Bds_log.log`);
module.exports.log_file = log_file
function bds_config_export (){
2021-04-19 23:26:14 -03:00
const Config = JSON.parse(fs.readFileSync(path.join(bds_dir, "bds_config.json"), "utf8"))
/**
* Get current bds core config
*
2021-04-29 00:35:47 -03:00
* @example bds_config.bds_platform // return bedrock, java, pocketmine or jsprismarine
*
*/
2021-04-19 23:26:14 -03:00
module.exports.bds_config = Config
module.exports.platform = Config.bds_platform
}
bds_config_export()
2021-03-24 14:51:12 +00:00
2021-04-18 23:36:41 -03:00
function getBdsConfig (){
const Config = fs.readFileSync(path.join(bds_dir, "bds_config.json"), "utf8")
return JSON.parse(Config)
}
module.exports.getBdsConfig = getBdsConfig
/**
* with this command we can change the platform with this script
*
* bedrock change_platform("bedrock")
*
* java change_platform("java")
2021-04-29 00:35:47 -03:00
*
* pocketmine change_platform("pocketmine")
*
* jsprismarine change_platform("jsprismarine")
*
* @example change_platform("bedrock")
2021-04-23 21:40:08 -03:00
*
* @param "bedrock"
* @param "java"
* @param "pocketmine"
2021-04-29 00:35:47 -03:00
* @param "jsprismarine"
*/
function platform_update(plate){
2021-04-01 23:01:53 -03:00
// Server platform detect
2021-04-29 00:35:47 -03:00
if (!(plate === "java" || plate === "bedrock" || plate === "pocketmine" || plate === "jsprismarine")) throw new Error(`platform not identified or does not exist, ${plate} informed platform`);
2021-04-01 23:01:53 -03:00
// Platforma Update
2021-04-18 23:36:41 -03:00
const bds_config = path.join(bds_dir, "bds_config.json");
try {
const config_load = JSON.parse(fs.readFileSync(bds_config))
config_load.bds_platform = plate
2021-03-14 01:55:34 +00:00
fs.writeFileSync(bds_config, JSON.stringify(config_load, null, 4))
2021-02-17 17:23:17 +00:00
console.log(`upgrading the platform ${plate}`)
bds_config_export()
return true
} catch (error) {
2021-04-23 21:40:08 -03:00
throw new Error(`Something happened error: ${error}`)
}
}
2021-04-23 21:40:08 -03:00
2021-04-18 23:36:41 -03:00
module.exports.change_platform = platform_update
module.exports.platform_update = platform_update
2021-04-23 21:40:08 -03:00
2021-03-14 01:55:34 +00:00
if (process.env.SERVER !== undefined){
2021-04-18 23:36:41 -03:00
let PlaformSelectServer = (process.env.SERVER || "bedrock")
if (PlaformSelectServer.includes("java", "JAVA")) platform_update("java");
else if (PlaformSelectServer.includes("bedrock", "BEDROCK")) platform_update("bedrock");
else if (PlaformSelectServer.includes("pocketmine", "POCKETMINE", "pocketmine-mp", "POCKETMINE-MP")) platform_update("pocketmine");
2021-04-29 00:35:47 -03:00
else if (PlaformSelectServer.includes("JSPrismarine", "JSPRISMARINE", "jsprismarine")) platform_update("jsprismarine");
2021-04-18 23:36:41 -03:00
else throw new Error("Server Plaform Error: "+process.env.SERVER)
}
2021-01-12 21:46:22 -03:00
const telegram_token_save = function (token) {
try {
const bds_config = path.join(bds_dir, "bds_config.json")
const config_load = JSON.parse(fs.readFileSync(bds_config))
config_load.telegram_token = token
2021-03-14 01:55:34 +00:00
fs.writeFileSync(bds_config, JSON.stringify(config_load, null, 4))
bds_config_export()
return true
} catch {
return false
}
}
module.exports.telegram_token_save = telegram_token_save
if (require("fs").existsSync(path.join(bds_dir, "telegram_token.txt"))){
2021-04-01 23:01:53 -03:00
console.log(`We identified the old telegram token file (${path.join (bds_dir, "telegram_token.txt")}), starting the migration process`)
try {
const token = fs.readFileSync(path.join(bds_dir, "telegram_token.txt"), "utf8").split("\n").join("")
2021-04-01 23:01:53 -03:00
telegram_token_save(token)
fs.rmSync(path.join(bds_dir, "telegram_token.txt"))
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")
}
Merge (#20) * push * Push * Bump systeminformation from 4.34.7 to 4.34.9 Bumps [systeminformation](https://github.com/sebhildebrandt/systeminformation) from 4.34.7 to 4.34.9. - [Release notes](https://github.com/sebhildebrandt/systeminformation/releases) - [Changelog](https://github.com/sebhildebrandt/systeminformation/blob/master/CHANGELOG.md) - [Commits](https://github.com/sebhildebrandt/systeminformation/compare/v4.34.7...v4.34.9) Signed-off-by: dependabot[bot] <support@github.com> * Bump systeminformation from 4.34.9 to 5.0.2 Bumps [systeminformation](https://github.com/sebhildebrandt/systeminformation) from 4.34.9 to 5.0.2. - [Release notes](https://github.com/sebhildebrandt/systeminformation/releases) - [Changelog](https://github.com/sebhildebrandt/systeminformation/blob/master/CHANGELOG.md) - [Commits](https://github.com/sebhildebrandt/systeminformation/commits) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Bump adm-zip from 0.5.1 to 0.5.2 Bumps [adm-zip](https://github.com/cthackers/adm-zip) from 0.5.1 to 0.5.2. - [Release notes](https://github.com/cthackers/adm-zip/releases) - [Changelog](https://github.com/cthackers/adm-zip/blob/master/history.md) - [Commits](https://github.com/cthackers/adm-zip/compare/v0.5.1...v0.5.2) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Bump systeminformation from 5.0.2 to 5.0.5 Bumps [systeminformation](https://github.com/sebhildebrandt/systeminformation) from 5.0.2 to 5.0.5. - [Release notes](https://github.com/sebhildebrandt/systeminformation/releases) - [Changelog](https://github.com/sebhildebrandt/systeminformation/blob/master/CHANGELOG.md) - [Commits](https://github.com/sebhildebrandt/systeminformation/commits) Signed-off-by: dependabot[bot] <support@github.com> * Bump telegraf from 4.0.1 to 4.0.2 Bumps [telegraf](https://github.com/telegraf/telegraf) from 4.0.1 to 4.0.2. - [Release notes](https://github.com/telegraf/telegraf/releases) - [Commits](https://github.com/telegraf/telegraf/compare/v4.0.1...v4.0.2) Signed-off-by: dependabot[bot] <support@github.com> * Bump systeminformation from 5.0.5 to 5.0.6 Bumps [systeminformation](https://github.com/sebhildebrandt/systeminformation) from 5.0.5 to 5.0.6. - [Release notes](https://github.com/sebhildebrandt/systeminformation/releases) - [Changelog](https://github.com/sebhildebrandt/systeminformation/blob/master/CHANGELOG.md) - [Commits](https://github.com/sebhildebrandt/systeminformation/compare/v5.0.5...v5.0.6) Signed-off-by: dependabot[bot] <support@github.com> * push * push * bedrock fix to Docker Image * bedrock fix to Docker Image * bedrock fix to Docker Image * fix start * fix start * new scripts alteraçoes foram feitas para unificar arquivos separados alguns erros podem aparecer a imagem do Docker vai passar por manuteçao os proximos scripts podem aplicar alteraçoes para o docker algumas coisas foram reparadas no script do Google Driver * null * docker teste * docker teste Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2021-01-30 23:44:48 -03:00
}
2021-01-16 20:08:27 -03:00
2021-04-01 23:01:53 -03:00
// Get server version
2021-04-22 19:50:21 -03:00
module.exports.bedrock_all_versions = Object.getOwnPropertyNames(SERVER_URLs.bedrock);
module.exports.java_all_versions = Object.getOwnPropertyNames(SERVER_URLs.java);
module.exports.bds_latest = (SERVER_URLs.bedrock_lateste||SERVER_URLs.bedrock_latest);
module.exports.bedrock_latest = SERVER_URLs.bedrock_latest;
module.exports.java_latest = SERVER_URLs.java_latest;
/**
* Activate an API via expresss.js, to receive requests via http such as the log, send and receive commands
*
* to activate use:
* * bds.api() // to activate requests via http
* * bds.log()
*/
module.exports.api = require("./rest/api");
module.exports.rest = require("./rest/api");
2021-04-01 23:01:53 -03:00
// ------------
2021-04-20 22:09:34 -03:00
const user_file_connected = path.join(bds_dir, "bds_usersV2.json")
/**
* get the location of the file where the player history connected to the server is saved
*/
module.exports.players_files = user_file_connected
2021-04-20 22:09:34 -03:00
if (!(fs.existsSync(user_file_connected))) fs.writeFileSync(user_file_connected, "{}")
const file_user_check = fs.readFileSync(user_file_connected, "utf8");
2021-04-20 22:09:34 -03:00
if (file_user_check.charAt(0) !== "{") console.warn("ok, we have an error in the file of the connected players, please check the file, it should start on the first line with --> [ ,and end with -->]")
else if (file_user_check.slice(-1) !== "}") console.warn("ok, we have an error in the file of the connected players, please check the file, it should start on the first line with --> [ ,and end with -->]")
2021-04-23 21:40:08 -03:00
module.exports.telegram_token = bds_config.telegram_token
module.exports.telegram = require("./scripts/telegram_bot")
2021-04-12 00:36:47 -03:00
const token_register = function (username, passworld) {
2021-02-17 19:17:00 +00:00
const bds_token_path = path.join(bds_dir, "bds_tokens.json")
if (!(fs.existsSync(bds_token_path))) fs.writeFileSync(bds_token_path, "[]")
2021-04-12 00:36:47 -03:00
function getRandomNumber (){
const number = Math.trunc(15 * (10 * Math.random()))
if (number < 10) return getRandomNumber()
else if (number > 15) return getRandomNumber()
else return number
}
let number = getRandomNumber()
require("crypto").randomBytes(number, function(err, buffer) {
2021-02-17 19:17:00 +00:00
if (err) console.warn(err);
const new_token = buffer.toString("hex");
var tokens = JSON.parse(fs.readFileSync(bds_token_path, "utf8"));
2021-04-12 00:36:47 -03:00
tokens.push({
"token": (passworld||new_token),
"user": (username||"all")
});
2021-03-14 01:55:34 +00:00
fs.writeFileSync(bds_token_path, JSON.stringify(tokens, null, 4), "utf8");
2021-02-17 19:17:00 +00:00
2021-04-12 00:36:47 -03:00
console.log(`Bds Maneger API REST token: "${new_token}"`);
if (process.stdout.isTTY === false) {
2021-04-01 23:01:53 -03:00
require("qrcode").toString(new_token, {type: "terminal"}, function (err, url) {
if (err) throw Error(err)
console.log(url)
})
}
2021-02-17 19:17:00 +00:00
})
}
2021-04-12 00:36:47 -03:00
2021-04-18 23:36:41 -03:00
// Requires
const { World_BAckup } = require("./scripts/backups");
const { stop, BdsCommand } = require("./scripts/basic_server");
2021-05-04 14:46:10 -03:00
const bdsStart = require("./scripts/basic_server").start;
2021-04-18 23:36:41 -03:00
const { config, get_config, config_example } = require("./scripts/bds_settings");
const { mcpe, drive_backup } = require("./scripts/GoogleDrive");
2021-04-23 21:40:08 -03:00
const download = require("./scripts/download");
2021-04-18 23:36:41 -03:00
const Jobs = {};
for (let index of bds_config.BackupCron) {
Jobs[index] = new CronJob(index, function() {
World_BAckup()
});
}
module.exports.CronBackups = Jobs
2021-04-12 00:36:47 -03:00
/**
* Register tokens to use in Bds Maneger REST and other supported applications
*
* @example token_register()
*/
module.exports.token_register = token_register
/**
* Take the current date
*/
module.exports.date = date
/**
* sending commands more simply to the server
*
* @example bds.command("say hello from Bds Maneger")
*/
2021-04-18 23:36:41 -03:00
module.exports.command = BdsCommand
// New management method
/**
* to start the server here in the sera script with child_process, then you will have to use the return function for your log custumization or anything else
*
* @example const server = bds.start();
* server.on.stdout("date", function (log){console.log(log)})
*/
2021-05-04 14:46:10 -03:00
module.exports.start = bdsStart
/**
* use this command for the server, that's all
*/
2021-04-18 23:36:41 -03:00
module.exports.stop = stop
/**
* backup your map locally
*/
2021-04-18 23:36:41 -03:00
module.exports.backup = World_BAckup
/**
* identify if there are any servers running in the background
*
* @example bds.detect()
* // true: if the server is running
* // false: if not already
*/
module.exports.detect = require("./scripts/detect")
module.exports.bds_detect = require("./scripts/detect")
/**
* download some version of the java and Bedrock servers in the highest possible form
*
2021-03-24 14:51:12 +00:00
* use download( version, boolean ) // the boolean is for if you want to force the installation of the server
*
* @example
* bedrock: bds.download("1.16.201.02")
*
* java: bds.download("1.16.5")
*
* any platform: bds.download("latest") // It will download the latest version available for download
*/
2021-04-18 23:36:41 -03:00
module.exports.download = download
/**
* this function will be used to kill the server in the background
*/
module.exports.kill = require("./scripts/kill_server")
2021-04-18 23:36:41 -03:00
module.exports.config_example = config_example
2021-04-12 00:36:47 -03:00
/**
* use this command to modify server settings
*
2021-04-12 00:36:47 -03:00
* @example bds.set_config({
name: "Bedrock our Java",
description: "BDS Maneger",
gamemode: "survival",
difficulty: "normal",
player_permission: "member",
xbox: true,
white_list: false,
cheats: false,
players: 100,
port: 19132,
port6: 19133
})
*/
2021-04-18 23:36:41 -03:00
module.exports.set_config = config
/**
* takes the server settings in JSON format
*/
2021-04-18 23:36:41 -03:00
module.exports.get_config = get_config
2021-04-01 23:01:53 -03:00
/**
* download the latest version of minecraft bedrock for android available, remember to use if you want
*
* you are taking responsibility for that
*/
2021-04-18 23:36:41 -03:00
module.exports.mcpe_file = mcpe
2021-04-12 00:36:47 -03:00
2021-04-01 23:01:53 -03:00
/**
* perform a backup of the map, some resources are still under construction in the code more works
*
* on the bedrock platform, all maps will be backed up into the "worlds" folder
*
* on the java platform the map selected in the server configuration will be backed up, any other map will have to change in the server settings to perform the backup
*/
2021-04-29 00:35:47 -03:00
module.exports.drive_backup = drive_backup