CLI Color and Modifications actions relelases #163

Merged
Sirherobrine23 merged 6 commits from main into main 2021-08-20 02:56:15 +00:00
3 changed files with 957 additions and 957 deletions
Showing only changes of commit 868ef26136 - Show all commits

1
.gitignore vendored
View File

@ -12,6 +12,7 @@ node_modules/
Bds_Maneger Bds_Maneger
.dccache .dccache
docs/ docs/
the-bds-maneger-core-*.tgz
# Bds Maneger Core Binaries # Bds Maneger Core Binaries
bds_maneger bds_maneger

View File

@ -1,6 +1,14 @@
# Log # Log
*.log *.log
# Develop files
.devcontainer/
.vscode/
.Build/
# Linters
.eslint*
# test files # test files
*.test *.test
*test*.js* *test*.js*
@ -12,5 +20,8 @@ git*
.git* .git*
# Docker # Docker
.dockerignore .docker*
Docker* Docker*
# Npm
the-bds-maneger-core*.tgz

View File

@ -8,10 +8,39 @@
"temp_host": { "temp_host": {
"url": "http://hosts.bdsmaneger.com:3020" "url": "http://hosts.bdsmaneger.com:3020"
}, },
"download": { "Fetchs": {
"php": "https://raw.githubusercontent.com/The-Bds-Maneger/Php_Static_Binary/main/binarys.json", "php": "https://raw.githubusercontent.com/The-Bds-Maneger/Php_Static_Binary/main/binarys.json",
"servers": "https://raw.githubusercontent.com/The-Bds-Maneger/external_files/main/Server.json" "servers": "https://raw.githubusercontent.com/The-Bds-Maneger/external_files/main/Server.json"
}, },
"IgnoreLog": {
"bedrock": [
{
"value": "Running AutoCompaction",
"regex": true
}
],
"java": [],
"pocketmine": [],
"spigot": []
},
"StartedServer": {
"bedrock": {
"value": "Server started",
"regex": true
},
"java": {
"value": null,
"regex": false
},
"pocketmine": {
"value": null,
"regex": false
},
"spigot": {
"value": null,
"regex": false
}
},
"Servers": { "Servers": {
"bedrock": { "bedrock": {
"stop": "stop", "stop": "stop",

View File

@ -4,7 +4,7 @@ tag: bdsmaneger/core:dev
target: bdscore target: bdscore
buildx: buildx:
enable: false enable: false
platform: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 platform: linux/amd64,linux/arm/v7,linux/arm64
# Docker Run envs # Docker Run envs
env: env:
@ -47,5 +47,6 @@ ports:
# More options # More options
options: options:
build: [] build: []
run: [] run:
- "-v $(pwd)/Test:/root/bds_core"
runArgv: [] runArgv: []

View File

@ -15,17 +15,6 @@ FROM bdsbase AS bdscore
# Create Volume to Storage Server And Config # Create Volume to Storage Server And Config
VOLUME [ "/root/bds_core" ] VOLUME [ "/root/bds_core" ]
# Copy Bds Maneger Core
WORKDIR /opt/backend_core_scripts/
# Install Core dependencies
COPY package*.json ./
RUN npm install
# Copy BdsManger Core
COPY ./ ./
RUN chmod a+x -v bin/*
# Set default ENVs to Bds Core # Set default ENVs to Bds Core
ENV PLAYERS="5" \ ENV PLAYERS="5" \
WORLD_NAME="The Ultimate Server" \ WORLD_NAME="The Ultimate Server" \
@ -40,5 +29,16 @@ ENV PLAYERS="5" \
# Bds Maneger Core required ports # Bds Maneger Core required ports
EXPOSE 19132/udp 19133/udp 1932/tcp EXPOSE 19132/udp 19133/udp 1932/tcp
# Copy Bds Maneger Core
WORKDIR /opt/backend_core_scripts/
# Install Core dependencies
COPY package*.json ./
RUN npm install
# Copy BdsManger Core
COPY ./ ./
RUN chmod a+x -v bin/*
# Set Entrypint # Set Entrypint
ENTRYPOINT [ "node", "./bin/Docker.js" ] ENTRYPOINT [ "node", "./bin/Docker.js" ]

View File

@ -1,16 +1,23 @@
# Bds Maneger Core # Bds Maneger Core
Create manage a server for Minecraft Bedrock, java and derivatives with an integration in NodeJs in which we deliver a versatile REST API for integration with large projects up to independent projects. Bds Maneger Core is a javascript core in Nodejs that manages several types of server seftware for Minecraft Bedrock and Java. Bds Maneger Core has integrated with a REST API with full integration with Bds Maneger Core in addition to CLI and One bot versions for the telegram.
Any contribution is welcome, but before a look at [CONTRIBUTING.md](CONTRIBUTING.md), [Bds Manager Core code of conduct](CODE_OF_CONDUCT.md) Any contribution is welcome, but before a look at [CONTRIBUTING.md](CONTRIBUTING.md), [Bds Manager Core code of conduct](CODE_OF_CONDUCT.md)
## More important information for users before 1.10.0+ ## Requirements for Bds Maneger Core
In Version 1.11.0 there was a big change in the way to get the new settings and that left a good part of the program broken, so for those who are going to upgrade to the latest versions of Bds maneger Core will have to change the settings manually. ### All
* [Nodejs 14+](https://nodejs.org/en/download/)
* [OpenJDK 16+](https://www.oracle.com/java/technologies/javase-jdk16-downloads.html)
### Windows 10+
* [Microsoft Visual Studio C++ (The Bds Maneger Documentation)](<https://docs.bdsmaneger.com/docs/Bds Maneger core/WindowsFixDll/#windows-server>)
## Documentation ## Documentation
We have a separate repository for all Bds Maneger Project documentation, <a href="https://docs.bdsmaneger.com/Bds Maneger core" target="_blank">link here from the main page</a>, <a href="https://github.com/The-Bds-Maneger/Bds-Manager-Project-Documentation" target="_blank">Repository link</a> We have a separate repository for all Bds Maneger Project documentation, [link here from the main page](<https://docs.bdsmaneger.com/Bds Maneger core>), [Repository link](https://github.com/The-Bds-Maneger/Bds-Manager-Project-Documentation)
## Badges ## Badges
@ -19,50 +26,65 @@ We have a separate repository for all Bds Maneger Project documentation, <a href
[![Language grade: JavaScript](https://img.shields.io/lgtm/grade/javascript/g/Bds-Maneger/bds_maneger_api.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/Bds-Maneger/bds_maneger_api/context:javascript) [![Language grade: JavaScript](https://img.shields.io/lgtm/grade/javascript/g/Bds-Maneger/bds_maneger_api.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/Bds-Maneger/bds_maneger_api/context:javascript)
[![DeepScan grade](https://deepscan.io/api/teams/13683/projects/16691/branches/363172/badge/grade.svg)](https://deepscan.io/dashboard#view=project&tid=13683&pid=16691&bid=363172) [![DeepScan grade](https://deepscan.io/api/teams/13683/projects/16691/branches/363172/badge/grade.svg)](https://deepscan.io/dashboard#view=project&tid=13683&pid=16691&bid=363172)
## Start our Docker image, making everything easier ## Start Bds Maneger Core with npx
Windows: ### CLI
All options can be found in the bds maneger core documentation.
`npx --package=@the-bds-maneger/core@latest bds_maneger -sk`
### Telegram Bot
`npx --package=@the-bds-maneger/core@latest bds_telegram`
## Install Bds Maneger Core globally
The commands available after installation:
* bds_maneger
* bds_telegram
`npm i -g @the-bds-maneger/core@latest`
## Launch Bds Maneger Core with a docker image
### Windows
```cmd ```cmd
$ docker run --rm -d --name BdsManegerCore -v BdsCore:/home/bds/bds_core ^ docker run --rm -d --name BdsManegerCore -v BdsCore:/home/bds/bds_core ^
--restart=always ^ --restart=always -p 19132:19132/udp -p 19133:19133/udp -p 1932:1932/tcp ^
-p 19132:19132/udp -p 19133:19133/udp -p 1932:1932/tcp ^
-e TELEGRAM_TOKEN="null" ^
-e DESCRIPTION="running Minecraft Bedrock Server on the docker by Bds Manager" ^ -e DESCRIPTION="running Minecraft Bedrock Server on the docker by Bds Manager" ^
-e WORLD_NAME="Bds Maneger Docker" ^ -e WORLD_NAME="Bds Maneger Docker" ^
-e GAMEMODE="survival" ^ -e GAMEMODE="survival" ^
-e DIFFICULTY="normal" ^ -e DIFFICULTY="normal" ^
-e XBOX_ACCOUNT="false" ^ -e ACCOUNT="false" ^
-e PLAYERS="13" ^ -e PLAYERS="13" ^
-e SERVER="bedrock" ^ -e SERVER="bedrock" ^
-e ENABLE_COMMANDS="false" ^ -e ENABLE_COMMANDS="false" ^
bdsmaneger/core:latest bdsmaneger/core:latest
``` ```
Linux/MacOS: ### Linux/MacOS
```bash ```bash
$ docker run --rm -d --name BdsManegerCore -v BdsCore/:/home/bds/bds_core \ docker run --rm -d --name BdsManegerCore -v BdsCore/:/home/bds/bds_core \
--restart=always \ --restart=always -p 19132:19132/udp -p 19133:19133/udp -p 1932:1932/tcp \
-p 19132:19132/udp -p 19133:19133/udp -p 1932:1932/tcp \
-e TELEGRAM_TOKEN="null" \
-e DESCRIPTION="running Minecraft Bedrock Server on the docker by Bds Manager" \ -e DESCRIPTION="running Minecraft Bedrock Server on the docker by Bds Manager" \
-e WORLD_NAME="Bds Maneger Docker" \ -e WORLD_NAME="Bds Maneger Docker" \
-e GAMEMODE="survival" \ -e GAMEMODE="survival" \
-e DIFFICULTY="normal" \ -e DIFFICULTY="normal" \
-e XBOX_ACCOUNT="false" \ -e ACCOUNT="false" \
-e PLAYERS="13" \ -e PLAYERS="13" \
-e SERVER="bedrock" \ -e SERVER="bedrock" \
-e ENABLE_COMMANDS="false" -e ENABLE_COMMANDS="false" \
bdsmaneger/core:latest bdsmaneger/core:latest
``` ```
## We also have some Implementation Models for Azure ## Azure Container and Azure VM
### Microsoft Azure Virtual machine We've separate the repository for azure deploy templates, [go here](https://github.com/The-Bds-Maneger/Azure#azure-deploys) if you want to deploy to azure.
Here we have a virtual machine totally dedicated to Bds Maneger Core, it still uses Docker to deploy Docker images. ## Oracle Cloud
[![Deploy to Azure](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FThe-Bds-Maneger%2FAzure_VMs%2Fmain%2Fdeploy.json) soon!
More Information Access the repository: [Azure VMs](https://github.com/The-Bds-Maneger/Azure_VMs)

View File

@ -1,11 +1,23 @@
#!/usr/bin/env node #!/usr/bin/env node
process.env.BDS_DOCKER_IMAGE = true;
const path = require("path");
const fs = require("fs");
const BdsCore = require("../index"); const BdsCore = require("../index");
const { GetPlatform } = require("../lib/BdsSettings"); const { GetPlatform, bds_dir } = require("../lib/BdsSettings");
const { Servers } = require("../lib/ServerURL");
const { CronJob } = require("cron"); const { CronJob } = require("cron");
const BdsInfo = require("../BdsManegerInfo.json"); const BdsInfo = require("../BdsManegerInfo.json");
process.env.BDS_DOCKER_IMAGE = true; // Get Current Tokens and Show in the console
function ShowToken() {
const TokenFilePath = path.join(bds_dir, "bds_tokens.json");
let Tokens = 1
if (fs.existsSync(TokenFilePath)) {
[...JSON.parse(fs.readFileSync(TokenFilePath, "utf8"))].slice(0, 5).forEach(token => {console.log(Tokens+":", "Bds API Token:", token.token); Tokens++});
} else {
console.log("No Tokens Found");
}
}
function StartServer(){ function StartServer(){
console.log("The entire log can be accessed via the api and/or the docker log"); console.log("The entire log can be accessed via the api and/or the docker log");
@ -13,32 +25,35 @@ function StartServer(){
ServerStarted.log(a => process.stdout.write(a)); ServerStarted.log(a => process.stdout.write(a));
ServerStarted.exit(process.exit); ServerStarted.exit(process.exit);
BdsCore.api(); BdsCore.api();
new CronJob("0 */1 * * *", async () => { ShowToken();
try { if (process.env.UPDATE_SERVER === "true") {
const CurrentLocalVersion = BdsCore.getBdsConfig().server.versions[GetPlatform()], new CronJob("0 */1 * * *", async () => {
CurrentRemoteVersion = Object.getOwnPropertyNames((await (await fetch(BdsInfo.download.servers)).json())[GetPlatform()])[0]; try {
if (CurrentLocalVersion !== CurrentRemoteVersion) { const CurrentLocalVersion = BdsCore.getBdsConfig().server.versions[GetPlatform()],
let currenttime = `Hello we are starting the server upgrade from version ${CurrentLocalVersion} to version ${CurrentRemoteVersion}, you have 20 seconds to exit the server` CurrentRemoteVersion = Object.getOwnPropertyNames((await (await fetch(BdsInfo.Fetchs.servers)).json())[GetPlatform()])[0];
console.log("Update Server:", currenttime); if (CurrentLocalVersion !== CurrentRemoteVersion) {
ServerStarted.say(currenttime); let currenttime = `Hello we are starting the server upgrade from version ${CurrentLocalVersion} to version ${CurrentRemoteVersion}, you have 20 seconds to exit the server`
let countdown = 20; console.log("Update Server:", currenttime);
while (countdown > 1) { ServerStarted.say(currenttime);
currenttime = `${countdown} seconds remaining to stop Server!`; let countdown = 20;
while (countdown > 1) {
currenttime = `${countdown} seconds remaining to stop Server!`;
console.log(currenttime);
ServerStarted.say(currenttime);
countdown--;
await new Promise(resolve => setTimeout(resolve, 1000));
}
currenttime = "Stopping the server"
console.log(currenttime); console.log(currenttime);
ServerStarted.say(currenttime); ServerStarted.say(currenttime);
countdown--; await new Promise(resolve => setTimeout(resolve, 600));
await new Promise(resolve => setTimeout(resolve, 1000)); ServerStarted.stop();
} }
currenttime = "Stopping the server" } catch (err) {
console.log(currenttime); console.log(err);
ServerStarted.say(currenttime);
await new Promise(resolve => setTimeout(resolve, 600));
ServerStarted.stop();
} }
} catch (err) { });
console.log(err); }
}
});
} }
// Check Installed Server // Check Installed Server
@ -53,22 +68,24 @@ if (Object.getOwnPropertyNames(AllVersions).filter(platform => AllVersions[platf
StartServer(); StartServer();
}); });
} else { } else {
// Check for Update (async () => {
if (AllVersions[GetPlatform()] === Object.getOwnPropertyNames(Servers[GetPlatform()])[0]) { // Check for Update
console.log("The entire log can be accessed via the api and/or the docker log"); if (AllVersions[GetPlatform()] === Object.getOwnPropertyNames((await (await fetch(BdsInfo.Fetchs.servers)).json())[GetPlatform()])[0]) {
const ServerStarted = BdsCore.start(); console.log("The entire log can be accessed via the api and/or the docker log");
ServerStarted.log(a => process.stdout.write(a)); const ServerStarted = BdsCore.start();
ServerStarted.exit(process.exit); ServerStarted.log(a => process.stdout.write(a));
BdsCore.api(); ServerStarted.exit(process.exit);
} else { BdsCore.api();
BdsCore.download(true, true, (err) => { } else {
if (err) { BdsCore.download(true, true, (err) => {
console.log(err); if (err) {
process.exit(1); console.log(err);
} process.exit(1);
StartServer(); }
}); StartServer();
} });
}
})();
} }
} else { } else {
console.log("Server is not installed, starting server implementation"); console.log("Server is not installed, starting server implementation");
@ -94,6 +111,7 @@ if (Object.getOwnPropertyNames(AllVersions).filter(platform => AllVersions[platf
port: 19132, port: 19132,
portv6: 19133, portv6: 19133,
} }
BdsCore.bds_maneger_token_register(["admin"]);
BdsCore.set_config(ServerConfig); BdsCore.set_config(ServerConfig);
StartServer(); StartServer();
}); });

View File

@ -8,10 +8,11 @@ const argv = require("minimist")(process.argv.slice(2));
if (Object.getOwnPropertyNames(argv).length <= 1) argv.help = true if (Object.getOwnPropertyNames(argv).length <= 1) argv.help = true
const bds = require("../index"); const bds = require("../index");
const { valid_platform } = require("../lib/BdsSystemInfo"); const SystemInfo = require("../lib/BdsSystemInfo");
const { bds_dir, GetServerVersion, GetPlatform, UpdatePlatform, GetServerPaths, GetPaths } = require("../lib/BdsSettings"); const { bds_dir, GetServerVersion, GetPlatform, UpdatePlatform, GetServerPaths, GetPaths } = require("../lib/BdsSettings");
const commandExits = require("../lib/commandExist"); const commandExits = require("../lib/commandExist");
const download = require("../src/BdsServersDownload"); const download = require("../src/BdsServersDownload");
const BdsConfigAndInfo = require("../BdsManegerInfo.json");
// Options // Options
const const
@ -32,8 +33,8 @@ if (kill) bds.kill();
// Set Bds Platform // Set Bds Platform
if (server) UpdatePlatform(server); if (server) UpdatePlatform(server);
function StartServer(){ async function StartServer(){
const { Servers } = require("../lib/ServerURL"); const Servers = (await (await fetch(BdsConfigAndInfo.Fetchs.servers)).json());
// Check Server Update // Check Server Update
if (Versions[GetPlatform()] !== null) { if (Versions[GetPlatform()] !== null) {
if (Versions[GetPlatform()] !== Servers.latest[GetPlatform()]) { if (Versions[GetPlatform()] !== Servers.latest[GetPlatform()]) {
@ -143,10 +144,10 @@ if (SystemCheck) {
"*", "*",
"**************************************************************", "**************************************************************",
"* Servers currently available:", "* Servers currently available:",
`* - Bedrock: ${valid_platform.bedrock}`, `* - Bedrock: ${SystemInfo.valid_platform.bedrock}`,
`* - Java: ${valid_platform.java}`, `* - Java: ${SystemInfo.valid_platform.java}`,
`* - Pocketmine-MP: ${valid_platform.pocketmine}`, `* - Pocketmine-MP: ${SystemInfo.valid_platform.pocketmine}`,
`* - JSPrismarine: ${valid_platform.jsprismarine}`, `* - JSPrismarine: ${SystemInfo.valid_platform.jsprismarine}`,
"*", "*",
"**************************************************************" "**************************************************************"
]; ];
@ -156,38 +157,39 @@ if (SystemCheck) {
// Download server // Download server
if (bds_version){ if (bds_version){
try { (async () => {
if (argv.interactive) { try {
const LoadVersion = require("../lib/ServerURL").Servers[GetPlatform()] if (argv.interactive) {
const Version = Object.getOwnPropertyNames(LoadVersion) const LoadVersion = (await (await fetch(BdsConfigAndInfo.Fetchs.servers)).json())[GetPlatform()]
const Version = Object.getOwnPropertyNames(LoadVersion)
const StartQuestion = (Readline) => {
Readline.question("Select a version to download: ", input => { const StartQuestion = (Readline) => {
if (Version[parseInt(input) - 1]) { Readline.question("Select a version to download: ", input => {
Readline.close(); if (Version[parseInt(input) - 1]) {
download(Version[parseInt(input) - 1], true, function(){ Readline.close();
if (start) return StartServer(); download(Version[parseInt(input) - 1], true, function(){
console.log("Installation was successful, so start the server with the -s option"); if (start) return StartServer();
process.exit(0); console.log("Installation was successful, so start the server with the -s option");
}) process.exit(0);
} else { })
console.log("Invalid Option"); } else {
StartQuestion(Readline); console.log("Invalid Option");
} StartQuestion(Readline);
}); }
});
}
console.log(`Selected platform: ${GetPlatform()}, Total available versions: ${Version.length}`);
console.log("Option Version");
for (let option in Version) console.log(`${parseInt(option) + 1} -------- ${Version[option]}`);
StartQuestion(readline.createInterface({input: process.stdin,output: process.stdout}));
} }
else bds.download(bds_version, true, function(){
console.log(`Selected platform: ${GetPlatform()}, Total available versions: ${Version.length}`); if (start) StartServer();
console.log("Option Version"); })
} catch (error) {console.error(error);process.exit(165);}
for (let option in Version) console.log(`${parseInt(option) + 1} -------- ${Version[option]}`); })();
StartQuestion(readline.createInterface({input: process.stdin,output: process.stdout}));
}
else bds.download(bds_version, true, function(){
if (start) StartServer();
})
}
catch (error) {console.error(error);process.exit(165);}
} }
// Start server // Start server

View File

@ -1,11 +1,12 @@
#!/usr/bin/env node
const fs = require("fs"); const fs = require("fs");
const { Telegraf, Markup } = require("telegraf"); const { Telegraf, Markup } = require("telegraf");
const bds = require("../index"); const bds = require("../index");
const { GetPlatform, GetPaths, GetTelegramToken } = require("../lib/BdsSettings"); const { GetPlatform, GetPaths, GetTelegramToken } = require("../lib/BdsSettings");
const { GetKernel, arch, system } = require("../lib/BdsSystemInfo"); const { GetKernel, arch, system } = require("../lib/BdsSystemInfo");
const { Detect } = require("../src/CheckKill"); const { Detect } = require("../src/CheckKill");
const { Servers } = require("../lib/ServerURL"); const { CheckTelegramUser } = require("../src/UsersAndtokenChecks");
const { CheckTelegramUser } = require("../src/UsersAndtokenChecks") const BdsInfo = require("../BdsManegerInfo.json");
// Bot Start And Help messages // Bot Start And Help messages
const HelpAndStart = [ const HelpAndStart = [
@ -203,7 +204,7 @@ bot.command("download", async ctx => {
ctx.reply(`Sucess install ${GetPlatform()} with version ${version}`); ctx.reply(`Sucess install ${GetPlatform()} with version ${version}`);
} else { } else {
await ctx.deleteMessage(); await ctx.deleteMessage();
const KeyboardVersion = Markup.keyboard(Object.getOwnPropertyNames(Servers[GetPlatform()]).map(version => { const KeyboardVersion = Markup.keyboard(Object.getOwnPropertyNames((await (await fetch(BdsInfo.Fetchs.servers)).json())[GetPlatform()]).map(version => {
return { return {
text: `/download ${version}` text: `/download ${version}`
} }

View File

@ -2,10 +2,7 @@ const { join, resolve, basename } = require("path");
const { existsSync, writeFileSync, mkdirSync, readFileSync } = require("fs"); const { existsSync, writeFileSync, mkdirSync, readFileSync } = require("fs");
const { homedir } = require("os"); const { homedir } = require("os");
const { valid_platform } = require("./BdsSystemInfo"); const { valid_platform } = require("./BdsSystemInfo");
const yaml = { const yaml = require("js-yaml");
parse: require("js-yaml").load,
stringify: require("js-yaml").dump
}
// PATHs // PATHs
const home = homedir(); const home = homedir();
@ -34,6 +31,7 @@ var Config = {
platform: default_platformConfig, platform: default_platformConfig,
BackupCron: [ BackupCron: [
{ {
enabled: false,
cron: "0 1 * * */3", cron: "0 1 * * */3",
Azure: false, Azure: false,
Oracle: false, Oracle: false,
@ -71,7 +69,6 @@ var Config = {
ban: [ ban: [
{ {
username: "Steve", username: "Steve",
telegram: true,
bedrock: true, bedrock: true,
java: true, java: true,
pocketmine: true, pocketmine: true,
@ -80,7 +77,6 @@ var Config = {
}, },
{ {
username: "Alex", username: "Alex",
telegram: true,
bedrock: true, bedrock: true,
java: true, java: true,
pocketmine: true, pocketmine: true,
@ -89,7 +85,6 @@ var Config = {
}, },
{ {
username: "steve", username: "steve",
telegram: true,
bedrock: true, bedrock: true,
java: true, java: true,
pocketmine: true, pocketmine: true,
@ -98,7 +93,6 @@ var Config = {
}, },
{ {
username: "alex", username: "alex",
telegram: true,
bedrock: true, bedrock: true,
java: true, java: true,
pocketmine: true, pocketmine: true,
@ -108,17 +102,18 @@ var Config = {
], ],
telegram: { telegram: {
admins: ["all_users"], admins: ["all_users"],
ban: ["Steve_mine_mine"],
token: null token: null
} }
} }
// Config // Config
const ConfigPath = join(resolve(homedir(), "bds_core"), "BdsConfig.yaml") const ConfigPath = join(resolve(homedir(), "bds_core"), "BdsConfig.yaml")
function SaveConfig(){writeFileSync(ConfigPath, yaml.stringify(Config));} function SaveConfig(){writeFileSync(ConfigPath, yaml.dump(Config));}
if (existsSync(ConfigPath)) Config = { if (existsSync(ConfigPath)) Config = {
...Config, ...Config,
...yaml.parse(readFileSync(ConfigPath, "utf8")) ...yaml.load(readFileSync(ConfigPath, "utf8"))
}; else writeFileSync(ConfigPath, yaml.stringify(Config)) }; else writeFileSync(ConfigPath, yaml.dump(Config))
process.on("exit", () => SaveConfig()) process.on("exit", () => SaveConfig())
// Paths // Paths
@ -131,7 +126,6 @@ const ServersPaths = {
bedrock: join(Config.paths.servers, "Bedrock"), bedrock: join(Config.paths.servers, "Bedrock"),
java: join(Config.paths.servers, "Java"), java: join(Config.paths.servers, "Java"),
pocketmine: join(Config.paths.servers, "Pocketmine-MP"), pocketmine: join(Config.paths.servers, "Pocketmine-MP"),
jsprismarine: join(Config.paths.servers, "JSPrismarine"),
dragonfly: join(Config.paths.servers, "Dragonfly_go"), dragonfly: join(Config.paths.servers, "Dragonfly_go"),
spigot: join(Config.paths.servers, "Spigot") spigot: join(Config.paths.servers, "Spigot")
} }
@ -181,9 +175,6 @@ function UpdatePlatform(platform = Config.server.platform){
} else if (/spigot/.test(platform)) { } else if (/spigot/.test(platform)) {
Config.server.platform = "spigot"; Config.server.platform = "spigot";
SaveConfig() SaveConfig()
} else if (/jsprismarine/.test(platform)) {
Config.server.platform = "jsprismarine";
SaveConfig()
} else throw new Error("platform no Exists") } else throw new Error("platform no Exists")
return platform return platform
} }

View File

@ -2,7 +2,11 @@ const { execSync } = require("child_process");
const { release } = require("os"); const { release } = require("os");
const { readdirSync } = require("fs"); const { readdirSync } = require("fs");
const commadExist = require("./commandExist"); const commadExist = require("./commandExist");
const { PHPBin, Servers } = require("./ServerURL"); const fetchSync = require("@the-bds-maneger/fetchsync");
// Load JSON for Server and PHP Zip files
const PHPBin = fetchSync("https://raw.githubusercontent.com/The-Bds-Maneger/Php_Static_Binary/main/binarys.json").json(),
Servers = fetchSync("https://raw.githubusercontent.com/The-Bds-Maneger/external_files/main/Server.json").json();
// System Architect (x64, aarch64 and others) // System Architect (x64, aarch64 and others)
var arch; var arch;

View File

@ -1,5 +0,0 @@
const fetchSync = require("@the-bds-maneger/fetchsync");
module.exports = {
Servers: fetchSync("https://raw.githubusercontent.com/The-Bds-Maneger/external_files/main/Server.json").json(),
PHPBin: fetchSync("https://raw.githubusercontent.com/The-Bds-Maneger/Php_Static_Binary/main/binarys.json").json()
}

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "@the-bds-maneger/core", "name": "@the-bds-maneger/core",
"version": "1.13.4", "version": "1.13.5",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@the-bds-maneger/core", "name": "@the-bds-maneger/core",
"version": "1.13.4", "version": "1.13.5",
"license": "AGPL-3.0-or-later", "license": "AGPL-3.0-or-later",
"dependencies": { "dependencies": {
"@azure/storage-blob": "^12.6.0", "@azure/storage-blob": "^12.6.0",

View File

@ -19,8 +19,8 @@
"Docker": "node .Build/DockerImage.js" "Docker": "node .Build/DockerImage.js"
}, },
"bin": { "bin": {
"bds_maneger": "./bin/bds_maneger.js", "bds_maneger": "bin/bds_maneger.js",
"bds_telegram": "./bin/telegram_bot.js" "bds_telegram": "bin/telegram_bot.js"
}, },
"repository": { "repository": {
"type": "git", "type": "git",

View File

@ -22,7 +22,9 @@ function start() {
command: String, command: String,
args: [], args: [],
cwd: String, cwd: String,
env: process.env, env: {
...process.env
},
} }
// Minecraft Bedrock Oficial // Minecraft Bedrock Oficial
@ -85,11 +87,17 @@ function start() {
// Post Start // Post Start
if (GetPlatform() === "java") { if (GetPlatform() === "java") {
const eula_file = path.join(GetServerPaths("java"), "eula.txt"); const eula_file_path = path.join(GetServerPaths("java"), "eula.txt");
console.log(fs.readFileSync(eula_file, "utf8")); if (fs.existsSync(eula_file_path)) {
if (fs.readFileSync(eula_file, "utf8").includes("eula=false")) { const eula_file = fs.readFileSync(eula_file_path, "utf8");
fs.writeFileSync(eula_file, fs.readFileSync(eula_file, "utf8").replaceAll("eula=false", "eula=true")); console.log(eula_file);
throw new Error("Restart application/CLI") 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")
} }
} }

View File

@ -18,14 +18,9 @@ module.exports = async function (version, force_install, callback) {
bds_dir_dragonfly = GetServerPaths("dragonfly"); bds_dir_dragonfly = GetServerPaths("dragonfly");
// JSON Configs and others // JSON Configs and others
const Servers = (await (await fetch(Extra.download.servers)).json()); const Servers = (await (await fetch(Extra.Fetchs.servers)).json());
const ServerVersion = GetServerVersion(); const ServerVersion = GetServerVersion();
const CurrentPlatform = GetPlatform(); const CurrentPlatform = GetPlatform();
if (force_install === true) {
ServerVersion.java = "latest";
ServerVersion.bedrock = "latest"
ServerVersion.pocketmine = "latest"
}
if (!(version) || version === true || version === "true" || version === "latest") version = Servers.latest[CurrentPlatform] if (!(version) || version === true || version === "true" || version === "latest") version = Servers.latest[CurrentPlatform]
var url; var url;
@ -152,7 +147,7 @@ module.exports = async function (version, force_install, callback) {
async function php_download() { async function php_download() {
const bds_dir_pocketmine = GetServerPaths("pocketmine"); const bds_dir_pocketmine = GetServerPaths("pocketmine");
const PHPBin = (await (await fetch(Extra.download.php)).json()); const PHPBin = (await (await fetch(Extra.Fetchs.php)).json());
const phpFolder = resolve(bds_dir_pocketmine, "bin"); const phpFolder = resolve(bds_dir_pocketmine, "bin");
const phpExtensiosnsDir = resolve(bds_dir_pocketmine, "bin/php7/lib/php/extensions"); const phpExtensiosnsDir = resolve(bds_dir_pocketmine, "bin/php7/lib/php/extensions");