Add new Bds Maneger Core CLI #194
@ -5,6 +5,7 @@ process.env.IS_BDS_CLI = process.env.IS_BIN_BDS = true;
|
||||
// External Modules
|
||||
const cli_color = require("cli-color");
|
||||
const inquirer = require("inquirer");
|
||||
const serverline = require("serverline");
|
||||
|
||||
// Bin Args
|
||||
const ProcessArgs = require("minimist")(process.argv.slice(2));
|
||||
@ -52,26 +53,11 @@ async function Runner() {
|
||||
console.log(cli_color.redBright(`Bds Core Exit with code ${code}, Uptimed: ${BdsCoreStart.uptime}`));
|
||||
process.exit(code);
|
||||
});
|
||||
const BdsCliMenus = require("./bds_maneger/menus");
|
||||
const InfinitCommands = async () => {
|
||||
const CommandtoRun = (await inquirer.prompt([
|
||||
{
|
||||
type: "list",
|
||||
name: "commands",
|
||||
message: "Select a command",
|
||||
choices: [
|
||||
"tp"
|
||||
]
|
||||
}
|
||||
])).commands;
|
||||
if (CommandtoRun === "tp") {
|
||||
BdsCliMenus.tp();
|
||||
return await InfinitCommands();
|
||||
} else {
|
||||
BdsCliMenus.Command();
|
||||
return await InfinitCommands();
|
||||
}
|
||||
}
|
||||
InfinitCommands();
|
||||
serverline.init();
|
||||
serverline.setCompletion(["tp"]);
|
||||
serverline.setPrompt("Command > ");
|
||||
serverline.on('line', function(line) {
|
||||
BdsCoreStart.command(line);
|
||||
});
|
||||
}
|
||||
Runner();
|
14
package-lock.json
generated
14
package-lock.json
generated
@ -30,6 +30,7 @@
|
||||
"ora": "^6.0.1",
|
||||
"properties-to-json": "^0.2.1",
|
||||
"request-ip": "^2.1.3",
|
||||
"serverline": "^1.5.0",
|
||||
"telegraf": "^4.0.0",
|
||||
"uuid": "^8.3.2"
|
||||
},
|
||||
@ -4995,6 +4996,14 @@
|
||||
"node": ">= 0.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/serverline": {
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmjs.org/serverline/-/serverline-1.5.0.tgz",
|
||||
"integrity": "sha512-QzNBH8omGchv+L5n/irZEeU2IGK3r8EMRh3EKRIlbfTklf9PtNRiRbWcYr8kqdNeWdc5M5jS13VtspDKgFXFFg==",
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/setprototypeof": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz",
|
||||
@ -9773,6 +9782,11 @@
|
||||
"send": "0.17.1"
|
||||
}
|
||||
},
|
||||
"serverline": {
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmjs.org/serverline/-/serverline-1.5.0.tgz",
|
||||
"integrity": "sha512-QzNBH8omGchv+L5n/irZEeU2IGK3r8EMRh3EKRIlbfTklf9PtNRiRbWcYr8kqdNeWdc5M5jS13VtspDKgFXFFg=="
|
||||
},
|
||||
"setprototypeof": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz",
|
||||
|
@ -69,6 +69,7 @@
|
||||
"ora": "^6.0.1",
|
||||
"properties-to-json": "^0.2.1",
|
||||
"request-ip": "^2.1.3",
|
||||
"serverline": "^1.5.0",
|
||||
"telegraf": "^4.0.0",
|
||||
"uuid": "^8.3.2"
|
||||
},
|
||||
|
@ -85,22 +85,6 @@ function start() {
|
||||
env: SetupCommands.env
|
||||
});
|
||||
|
||||
// Post Start
|
||||
if (GetPlatform() === "java") {
|
||||
const eula_file_path = path.join(GetServerPaths("java"), "eula.txt");
|
||||
if (fs.existsSync(eula_file_path)) {
|
||||
const eula_file = fs.readFileSync(eula_file_path, "utf8");
|
||||
console.log(eula_file);
|
||||
if (eula_file.includes("eula=false")) {
|
||||
fs.writeFileSync(eula_file_path, eula_file.replace(/eula=false/gi, "eula=true"));
|
||||
throw new Error("Restart application/CLI")
|
||||
}
|
||||
} else {
|
||||
console.log("EULA file not found");
|
||||
throw new Error("EULA file not found")
|
||||
}
|
||||
}
|
||||
|
||||
// Log file
|
||||
const LogFile = path.join(GetPaths("log"), `${GetPlatform()}_${new Date().toString().replace(/:|\(|\)/g, "_")}_Bds_log.log`);
|
||||
const LatestLog_Path = path.join(GetPaths("log"), "latest.log");
|
||||
|
@ -238,7 +238,7 @@ module.exports.v2 = async (version = true, force = true) => {
|
||||
// Bedrock
|
||||
if (CurrentPlatform === "bedrock") {
|
||||
if (valid_platform.bedrock) {
|
||||
if (!(force === true && typeof force === "boolean") && LocalServersVersions !== version) {
|
||||
if (!(force === true && typeof force === "boolean") && LocalServersVersions.bedrock !== version) {
|
||||
// Add info to ReturnObject
|
||||
ReturnObject.url = ServerDownloadJSON.bedrock[version][bds.arch][process.platform];
|
||||
ReturnObject.data = ServerDownloadJSON.bedrock[version].data;
|
||||
@ -279,13 +279,14 @@ module.exports.v2 = async (version = true, force = true) => {
|
||||
// Java
|
||||
else if (CurrentPlatform === "java") {
|
||||
if (valid_platform.java) {
|
||||
if (!(force === true && typeof force === "boolean") && LocalServersVersions !== version) {
|
||||
if (!(force === true && typeof force === "boolean") && LocalServersVersions.java !== version) {
|
||||
// Add info to ReturnObject
|
||||
ReturnObject.url = ServerDownloadJSON.java[version].url;
|
||||
ReturnObject.data = ServerDownloadJSON.java[version].data;
|
||||
|
||||
// Download and write java file
|
||||
fs.writeFileSync(path.join(ServersPaths.java, "MinecraftServerJava.jar"), await Request.buffer(ReturnObject.url), "binary");
|
||||
const JavaBufferJar = await Request.buffer(ReturnObject.url);
|
||||
fs.writeFileSync(path.join(ServersPaths.java, "MinecraftServerJava.jar"), JavaBufferJar, "binary");
|
||||
|
||||
// Write EULA
|
||||
fs.writeFileSync(path.join(ServersPaths.java, "eula.txt"), "eula=true");
|
||||
@ -303,7 +304,7 @@ module.exports.v2 = async (version = true, force = true) => {
|
||||
// Spigot
|
||||
else if (CurrentPlatform === "spigot") {
|
||||
if (valid_platform.spigot) {
|
||||
if (!(force === true && typeof force === "boolean") && LocalServersVersions !== version) {
|
||||
if (!(force === true && typeof force === "boolean") && LocalServersVersions.spigot !== version) {
|
||||
// Add info to ReturnObject
|
||||
const FindedSpigot = ServerDownloadJSON.spigot.findOne(spigot => spigot.version === version);
|
||||
ReturnObject.url = FindedSpigot.url;
|
||||
@ -325,7 +326,7 @@ module.exports.v2 = async (version = true, force = true) => {
|
||||
// Dragonfly
|
||||
else if (CurrentPlatform === "dragonfly") {
|
||||
if (valid_platform.dragonfly) {
|
||||
if (!(force === true && typeof force === "boolean") && LocalServersVersions !== version) {
|
||||
if (!(force === true && typeof force === "boolean") && LocalServersVersions.dragonfly !== version) {
|
||||
// Add info to ReturnObject
|
||||
ReturnObject.url = "https://github.com/df-mc/dragonfly/tree/master";
|
||||
ReturnObject.data = "";
|
||||
@ -353,6 +354,9 @@ module.exports.v2 = async (version = true, force = true) => {
|
||||
}
|
||||
}
|
||||
|
||||
// Pocketmine-MP
|
||||
else if (CurrentPlatform === "pocketmine") {throw new Error("We are still creating for Pocketmine-MP");}
|
||||
|
||||
// if the platform does not exist
|
||||
else throw Error("No Valid Platform");
|
||||
|
||||
|
Reference in New Issue
Block a user