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

474 lines
17 KiB
JavaScript
Raw Normal View History

/* eslint-disable no-irregular-whitespace */
2021-06-11 17:13:40 -03:00
const { resolve } = require("path");
2021-04-18 23:36:41 -03:00
const { CronJob } = require("cron");
const path = require("path")
const fs = require("fs");
2021-06-15 19:45:13 -03:00
const { getConfigHome } = require("./lib/GetPlatformFolder");
2021-06-11 17:13:40 -03:00
const commandExistsSync = require("./lib/commandExist");
const FetchSync = require("./lib/fetchSync");
2021-05-20 21:06:00 -03:00
const { randomBytes } = require("crypto")
2021-06-14 20:58:57 -03:00
module.exports = require("./lib/bdsgetPaths");
2021-05-02 23:11:17 -03:00
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-06-11 17:13:40 -03:00
const bds_core_package = resolve(__dirname, "package.json")
2021-04-23 21:40:08 -03:00
module.exports.package_path = bds_core_package
2021-06-11 17:13:40 -03:00
const package_json = JSON.parse(fs.readFileSync(bds_core_package))
module.exports.package_json = package_json
2021-04-23 21:40:08 -03:00
2021-06-14 20:58:57 -03:00
const { bds_dir, log_dir } = require("./lib/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
2021-05-16 23:14:17 -03:00
const SERVER_URLs = FetchSync("https://raw.githubusercontent.com/Bds-Maneger/Raw_files/main/Server.json").json()
const PHPbinsUrl = FetchSync("https://raw.githubusercontent.com/The-Bds-Maneger/Raw_files/main/php_bin.json").json()
const GoogleDriveCredentials = FetchSync("https://raw.githubusercontent.com/Bds-Maneger/Raw_files/main/credentials.json").json()
2021-04-23 21:40:08 -03:00
// -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
var system,
2021-05-16 23:14:17 -03:00
require_qemu = false,
valid_platform = {
bedrock: true,
pocketmine: true,
2021-06-11 17:13:40 -03:00
java: commandExistsSync("java"),
2021-05-17 23:22:32 -03:00
jsprismarine: commandExistsSync("node")
2021-05-16 23:14:17 -03:00
}
// check php bin
if (PHPbinsUrl[process.platform]) {
if (PHPbinsUrl[process.platform][arch]) valid_platform["pocketmine"] = true; else valid_platform["pocketmine"] = false
} else valid_platform["pocketmine"] = false
// SoSystem X
2021-01-15 15:41:16 -03:00
if (process.platform == "win32") {
2021-04-07 23:00:30 -03:00
system = "Windows";
2021-05-16 23:14:17 -03:00
// arm64 and X64
if (!(arch === "x64" || arch === "aarch64")) valid_platform["bedrock"] = 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-16 23:14:17 -03:00
if (SERVER_URLs.bedrock[SERVER_URLs.bedrock_latest][arch]) {
if (SERVER_URLs.bedrock[SERVER_URLs.bedrock_latest][arch][process.platform]) valid_platform["bedrock"] = true; else valid_platform["bedrock"] = false;
} else valid_platform["bedrock"] = false
if (valid_platform["bedrock"] === false) {
if (commandExistsSync("qemu-x86_64-static")) {
console.warn("The Minecraft Bedrock Server is only being validated because you can use 'qemu-x86_64-static'");
valid_platform["bedrock"] = true
require_qemu = true
}
}
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-05-16 23:14:17 -03:00
module.exports.require_qemu = require_qemu
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-05-17 23:22:32 -03:00
module.exports.extra_json = JSON.parse(fs.readFileSync(resolve(__dirname, "extra.json")))
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
2021-04-07 23:00:30 -03:00
module.exports.SERVER_URLs = SERVER_URLs
2021-05-06 22:58:17 -03:00
module.exports.ServerJson = SERVER_URLs
// Get server version
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;
2021-04-07 23:00:30 -03:00
// PHP Bins
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
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");
2021-04-29 00:35:47 -03:00
// Set default platform for bds maneger
var default_platformConfig;
2021-06-11 17:13:40 -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-06-11 17:13:40 -03:00
// User IP
2021-05-17 23:22:32 -03:00
const maneger_ips = require("./scripts/external_ip")
module.exports.internal_ip = maneger_ips.internal_ip
module.exports.external_ip = maneger_ips.external_ip
2021-05-04 14:46:10 -03:00
2021-04-29 00:35:47 -03:00
// Config File
2021-05-17 23:22:32 -03:00
var Oldbds_config
if (fs.existsSync(bds_config_file)) Oldbds_config = JSON.parse(fs.readFileSync(bds_config_file, "utf8"));else Oldbds_config = {platform_version: {}, telegram_admin: ["all_users"]}
2021-04-29 00:35:47 -03:00
bds_config = {
2021-06-11 17:13:40 -03:00
"version": package_json.version,
"bds_pages": (Oldbds_config.bds_pages || "default"),
"bds_platform": (Oldbds_config.bds_platform || default_platformConfig),
"LoadTelemetry": (() => {if (Oldbds_config.LoadTelemetry === undefined) return true ;else return Oldbds_config.LoadTelemetry})(),
"TelemetryID": (Oldbds_config.TelemetryID || FetchSync(`https://telemetry.the-bds-maneger.org/getid?external_ip=${maneger_ips.external_ip}`).toString()),
"platform_version": {
"bedrock": (Oldbds_config.platform_version.bedrock || null),
"java": (Oldbds_config.platform_version.java || null),
"pocketmine": (Oldbds_config.platform_version.pocketmine || null),
"jsprismarine": "latest"
2021-04-29 00:35:47 -03:00
},
2021-06-11 17:13:40 -03:00
"bds_ban": (Oldbds_config.bds_ban || ["Steve", "Alex", "steve", "alex"]),
"telegram_token": (Oldbds_config.telegram_token || "not User defined"),
"Google_Drive_root_backup_id": (Oldbds_config.Google_Drive_root_backup_id || undefined),
"BackupCron": (Oldbds_config.BackupCron||[]),
"telegram_admin": Oldbds_config.telegram_admin
}
2021-04-29 00:35:47 -03:00
fs.writeFileSync(bds_config_file, JSON.stringify(bds_config, null, 4))
2021-05-20 21:06:00 -03:00
function bds_config_export (){
const Config = JSON.parse(fs.readFileSync(path.join(bds_dir, "bds_config.json"), "utf8"))
/**
* Get current bds core config
*
* @example bds_config.bds_platform // return bedrock, java, pocketmine or jsprismarine
*
*/
module.exports.bds_config = Config
module.exports.telegram_token = Config.telegram_toke
module.exports.platform = Config.bds_platform
}
2021-04-29 00:35:47 -03:00
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
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 {
2021-05-06 22:58:17 -03:00
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
/**
* 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-05-05 23:48:25 -03:00
const user_file_connected = path.join(bds_dir, "bds_usersV3.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
2021-05-05 23:48:25 -03:00
if (!(fs.existsSync(user_file_connected))) {
let config = {};
config["bedrock"] = {};
config["java"] = {};
config["pocketmine"] = {};
config["jsprismarine"] = {};
let NewJson = JSON.stringify(config, null, 4);
fs.writeFileSync(user_file_connected, NewJson);
}
const file_user_check = fs.readFileSync(user_file_connected, "utf8");
2021-05-06 22:58:17 -03:00
try {
JSON.parse(file_user_check)
} catch (error) {
fs.renameSync(user_file_connected, `${user_file_connected}_old_${Math.random()}_${new Date().getDate()}_${new Date().getMonth()}_${new Date().getFullYear()}.json`)
}
2021-04-23 21:40:08 -03:00
module.exports.telegram_token = bds_config.telegram_token
2021-05-20 21:06:00 -03:00
function token_register() {
const bds_token_path = path.join(bds_dir, "bds_tokens.json");
if (!(fs.existsSync(bds_token_path))) fs.writeFileSync(bds_token_path, "[]");
randomBytes((Math.trunc(15 * (10 * Math.random()))), function(err, buffer) {
if (err) return console.warn(err);
2021-02-17 19:17:00 +00:00
const new_token = buffer.toString("hex");
var tokens = JSON.parse(fs.readFileSync(bds_token_path, "utf8"));
2021-05-20 21:06:00 -03:00
tokens.push({token: new_token});
2021-03-14 01:55:34 +00:00
fs.writeFileSync(bds_token_path, JSON.stringify(tokens, null, 4), "utf8");
2021-04-12 00:36:47 -03:00
console.log(`Bds Maneger API REST token: "${new_token}"`);
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 { config, get_config, config_example } = require("./scripts/bds_settings");
2021-04-23 21:40:08 -03:00
const download = require("./scripts/download");
2021-05-20 21:06:00 -03:00
const { start, stop, BdsCommand } = require("./scripts/basic_server")
2021-04-18 23:36:41 -03:00
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();
2021-05-20 21:06:00 -03:00
* server.log(function (log){console.log(log)})
*/
2021-05-20 21:06:00 -03:00
module.exports.start = start
/**
* 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-06-11 17:13:40 -03:00
// Core Applications
2021-05-20 21:06:00 -03:00
/**
* This is telegram bot
*/
2021-06-11 17:13:40 -03:00
module.exports.telegram = require("./scripts/telegram_bot")
// Backups
const Jobs = {};
for (let index of bds_config.BackupCron) {
Jobs[index] = new CronJob(index, function() {
World_BAckup()
});
}
module.exports.CronBackups = Jobs