Docker image #205
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -1,2 +1,2 @@
|
||||
* text=LF eol=LF
|
||||
* text=lf eol=lf
|
||||
*.sh text=lf eol=lf
|
200
.github/workflows/main.yml
vendored
200
.github/workflows/main.yml
vendored
@ -1,101 +1,101 @@
|
||||
name: Publish dev npm package and Docker Image
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
env:
|
||||
DOCKER_ARCH: linux/amd64,linux/arm64,linux/arm/v7
|
||||
|
||||
jobs:
|
||||
CodeQL:
|
||||
name: Analyze
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v1
|
||||
with:
|
||||
languages: "javascript"
|
||||
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v1
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v1
|
||||
|
||||
npm:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@master
|
||||
- name: Npm and Node Setup
|
||||
uses: actions/setup-node@v2.4.1
|
||||
with:
|
||||
node-version: 16.x
|
||||
registry-url: https://registry.npmjs.org/
|
||||
|
||||
- name: Edit Version
|
||||
env:
|
||||
RunID: ${{ github.run_id }}
|
||||
run: node .github/ChangeVersion.js
|
||||
|
||||
- name: Install Packages
|
||||
run: npm install
|
||||
|
||||
- name: NPM Publish
|
||||
run: npm publish --tag dev
|
||||
env:
|
||||
NODE_AUTH_TOKEN: '${{ secrets.NPM_ORG_TOKEN }}'
|
||||
|
||||
DockerImage:
|
||||
needs:
|
||||
- npm
|
||||
runs-on: ubuntu-latest
|
||||
name: Build Docker Image to Bds Core and Bds Base
|
||||
steps:
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: checkout
|
||||
uses: actions/checkout@master
|
||||
|
||||
- name: Install Node Depedencies
|
||||
run: npm install --no-save -d
|
||||
|
||||
- name: Get And Export Release Version
|
||||
shell: node
|
||||
run: |
|
||||
const version = require("./package.json").version;
|
||||
const ActionsCore = require("@actions/core");
|
||||
console.log(version);
|
||||
ActionsCore.exportVariable("BdsCoreVersion", version);
|
||||
|
||||
- name: Build Docker image (Bds Maneger Base)
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
push: true
|
||||
target: bdsbase
|
||||
tags: ghcr.io/the-bds-maneger/base:main
|
||||
platforms: ${{ env.DOCKER_ARCH }}
|
||||
|
||||
- name: Build Docker image (Bds Maneger core)
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
push: true
|
||||
target: bdscore
|
||||
cache-from: ghcr.io/the-bds-maneger/base:main
|
||||
tags: ghcr.io/the-bds-maneger/core:main
|
||||
name: Publish dev npm package and Docker Image
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
env:
|
||||
DOCKER_ARCH: linux/amd64,linux/arm64,linux/arm/v7
|
||||
|
||||
jobs:
|
||||
CodeQL:
|
||||
name: Analyze
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v1
|
||||
with:
|
||||
languages: "javascript"
|
||||
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v1
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v1
|
||||
|
||||
npm:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@master
|
||||
- name: Npm and Node Setup
|
||||
uses: actions/setup-node@v2.4.1
|
||||
with:
|
||||
node-version: 16.x
|
||||
registry-url: https://registry.npmjs.org/
|
||||
|
||||
- name: Edit Version
|
||||
env:
|
||||
RunID: ${{ github.run_id }}
|
||||
run: node .github/ChangeVersion.js
|
||||
|
||||
- name: Install Packages
|
||||
run: npm install
|
||||
|
||||
- name: NPM Publish
|
||||
run: npm publish --tag dev
|
||||
env:
|
||||
NODE_AUTH_TOKEN: '${{ secrets.NPM_ORG_TOKEN }}'
|
||||
|
||||
DockerImage:
|
||||
needs:
|
||||
- npm
|
||||
runs-on: ubuntu-latest
|
||||
name: Build Docker Image to Bds Core and Bds Base
|
||||
steps:
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: checkout
|
||||
uses: actions/checkout@master
|
||||
|
||||
- name: Install Node Depedencies
|
||||
run: npm install --no-save -d
|
||||
|
||||
- name: Get And Export Release Version
|
||||
shell: node -p '{0}'
|
||||
run: |
|
||||
const version = require("./package.json").version;
|
||||
const ActionsCore = require("@actions/core");
|
||||
console.log(version);
|
||||
ActionsCore.exportVariable("BdsCoreVersion", version);
|
||||
|
||||
- name: Build Docker image (Bds Maneger Base)
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
push: true
|
||||
target: bdsbase
|
||||
tags: ghcr.io/the-bds-maneger/base:main
|
||||
platforms: ${{ env.DOCKER_ARCH }}
|
||||
|
||||
- name: Build Docker image (Bds Maneger core)
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
push: true
|
||||
target: bdscore
|
||||
cache-from: ghcr.io/the-bds-maneger/base:main
|
||||
tags: ghcr.io/the-bds-maneger/core:main
|
||||
platforms: ${{ env.DOCKER_ARCH }}
|
88
Dockerfile
88
Dockerfile
@ -1,44 +1,44 @@
|
||||
# Setup Bds Manerger Project Docker Base
|
||||
FROM debian:testing AS bdsbase
|
||||
USER root
|
||||
ENV DEBIAN_FRONTEND="noninteractive" DOCKER_IMAGE="true"
|
||||
|
||||
# Copy Docker Files
|
||||
COPY .Build/Docker/* /tmp
|
||||
|
||||
# Configure BASE
|
||||
RUN bash /tmp/Configure.sh
|
||||
|
||||
# Setup bdsmaneger/core
|
||||
FROM bdsbase AS bdscore
|
||||
|
||||
# Create Volume to Storage Server And Config
|
||||
VOLUME [ "/root/bds_core" ]
|
||||
|
||||
# Set default ENVs to Bds Core
|
||||
ENV PLAYERS="5" \
|
||||
WORLD_NAME="The Ultimate Server" \
|
||||
DESCRIPTION="running Minecraft Server on Bds Maneger by Bds Manager Project" \
|
||||
GAMEMODE="survival" \
|
||||
DIFFICULTY="normal" \
|
||||
ENABLE_COMMANDS="false" \
|
||||
ACCOUNT="false" \
|
||||
SERVER="bedrock" \
|
||||
UPDATE_SERVER="true"
|
||||
|
||||
# Bds Maneger Core required ports
|
||||
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
|
||||
ENTRYPOINT [ "node", "./bin/Docker.js" ]
|
||||
# Setup Bds Manerger Project Docker Base
|
||||
FROM debian:testing AS bdsbase
|
||||
USER root
|
||||
ENV DEBIAN_FRONTEND="noninteractive" DOCKER_IMAGE="true"
|
||||
|
||||
# Copy Docker Files
|
||||
COPY .Build/Docker/* /tmp
|
||||
|
||||
# Configure BASE
|
||||
RUN bash /tmp/Configure.sh
|
||||
|
||||
# Setup bdsmaneger/core
|
||||
FROM bdsbase AS bdscore
|
||||
|
||||
# Create Volume to Storage Server And Config
|
||||
VOLUME [ "/root/bds_core" ]
|
||||
|
||||
# Set default ENVs to Bds Core
|
||||
ENV PLAYERS="5" \
|
||||
WORLD_NAME="The Ultimate Server" \
|
||||
DESCRIPTION="running Minecraft Server on Bds Maneger by Bds Manager Project" \
|
||||
GAMEMODE="survival" \
|
||||
DIFFICULTY="normal" \
|
||||
ENABLE_COMMANDS="false" \
|
||||
ACCOUNT="false" \
|
||||
SERVER="bedrock" \
|
||||
UPDATE_SERVER="true"
|
||||
|
||||
# Bds Maneger Core required ports
|
||||
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
|
||||
ENTRYPOINT [ "node", "./bin/Docker.js" ]
|
||||
|
@ -1,85 +1,85 @@
|
||||
// Import Node Modules
|
||||
const fs = require("fs");
|
||||
|
||||
// Import external modules
|
||||
const inquirer = require("inquirer");
|
||||
|
||||
// Bds Core
|
||||
const { getBdsConfig } = require("../../index");
|
||||
const { GetPaths } = require("../../lib/BdsSettings");
|
||||
|
||||
const GetPlayers = (Platform = getBdsConfig().server.platform) => [...JSON.parse(fs.readFileSync(GetPaths("player"), "utf8"))[Platform]];
|
||||
|
||||
async function TpMenu() {
|
||||
const { BdsRun } = require("../../src/BdsManegerServer");
|
||||
const playerList = GetPlayers().map(player => player.Player && player.Action === "connect" ? player.Player : null).filter(a => a);
|
||||
|
||||
// Check if there are players online
|
||||
if (playerList.length > 0) {
|
||||
const Player = await inquirer.prompt([
|
||||
{
|
||||
type: "list",
|
||||
name: "player",
|
||||
message: "Select a player",
|
||||
choices: playerList
|
||||
}
|
||||
]);
|
||||
|
||||
// Ask X, Y and Z Cordinates
|
||||
const cords = await inquirer.prompt([
|
||||
{
|
||||
type: "input",
|
||||
name: "x",
|
||||
message: "X Cordinate",
|
||||
validate: function (value) {
|
||||
if (isNaN(value) === false) {
|
||||
return true;
|
||||
}
|
||||
return "Please enter a number";
|
||||
}
|
||||
},
|
||||
{
|
||||
type: "input",
|
||||
name: "y",
|
||||
message: "Y Cordinate",
|
||||
validate: function (value) {
|
||||
if (isNaN(value) === false) {
|
||||
return true;
|
||||
}
|
||||
return "Please enter a number";
|
||||
}
|
||||
},
|
||||
{
|
||||
type: "input",
|
||||
name: "z",
|
||||
message: "Z Cordinate",
|
||||
validate: function (value) {
|
||||
if (isNaN(value) === false) {
|
||||
return true;
|
||||
}
|
||||
return "Please enter a number";
|
||||
}
|
||||
}
|
||||
]);
|
||||
return BdsRun.tp(Player.player, {
|
||||
x: parseInt(cords.x),
|
||||
y: parseInt(cords.y),
|
||||
z: parseInt(cords.z)
|
||||
});
|
||||
} else throw new Error("No players online");
|
||||
}
|
||||
|
||||
async function Command() {
|
||||
const { BdsRun } = require("../../src/BdsManegerServer");
|
||||
const Command = await inquirer.prompt([
|
||||
{
|
||||
type: "input",
|
||||
name: "command",
|
||||
message: "Enter a command"
|
||||
}
|
||||
]);
|
||||
return BdsRun.command(Command.command);
|
||||
}
|
||||
|
||||
module.exports.Command = Command;
|
||||
// Import Node Modules
|
||||
const fs = require("fs");
|
||||
|
||||
// Import external modules
|
||||
const inquirer = require("inquirer");
|
||||
|
||||
// Bds Core
|
||||
const { getBdsConfig } = require("../../index");
|
||||
const { GetPaths } = require("../../lib/BdsSettings");
|
||||
|
||||
const GetPlayers = (Platform = getBdsConfig().server.platform) => [...JSON.parse(fs.readFileSync(GetPaths("player"), "utf8"))[Platform]];
|
||||
|
||||
async function TpMenu() {
|
||||
const { BdsRun } = require("../../src/BdsManegerServer");
|
||||
const playerList = GetPlayers().map(player => player.Player && player.Action === "connect" ? player.Player : null).filter(a => a);
|
||||
|
||||
// Check if there are players online
|
||||
if (playerList.length > 0) {
|
||||
const Player = await inquirer.prompt([
|
||||
{
|
||||
type: "list",
|
||||
name: "player",
|
||||
message: "Select a player",
|
||||
choices: playerList
|
||||
}
|
||||
]);
|
||||
|
||||
// Ask X, Y and Z Cordinates
|
||||
const cords = await inquirer.prompt([
|
||||
{
|
||||
type: "input",
|
||||
name: "x",
|
||||
message: "X Cordinate",
|
||||
validate: function (value) {
|
||||
if (isNaN(value) === false) {
|
||||
return true;
|
||||
}
|
||||
return "Please enter a number";
|
||||
}
|
||||
},
|
||||
{
|
||||
type: "input",
|
||||
name: "y",
|
||||
message: "Y Cordinate",
|
||||
validate: function (value) {
|
||||
if (isNaN(value) === false) {
|
||||
return true;
|
||||
}
|
||||
return "Please enter a number";
|
||||
}
|
||||
},
|
||||
{
|
||||
type: "input",
|
||||
name: "z",
|
||||
message: "Z Cordinate",
|
||||
validate: function (value) {
|
||||
if (isNaN(value) === false) {
|
||||
return true;
|
||||
}
|
||||
return "Please enter a number";
|
||||
}
|
||||
}
|
||||
]);
|
||||
return BdsRun.tp(Player.player, {
|
||||
x: parseInt(cords.x),
|
||||
y: parseInt(cords.y),
|
||||
z: parseInt(cords.z)
|
||||
});
|
||||
} else throw new Error("No players online");
|
||||
}
|
||||
|
||||
async function Command() {
|
||||
const { BdsRun } = require("../../src/BdsManegerServer");
|
||||
const Command = await inquirer.prompt([
|
||||
{
|
||||
type: "input",
|
||||
name: "command",
|
||||
message: "Enter a command"
|
||||
}
|
||||
]);
|
||||
return BdsRun.command(Command.command);
|
||||
}
|
||||
|
||||
module.exports.Command = Command;
|
||||
module.exports.TpMenu = TpMenu;
|
@ -1,116 +1,116 @@
|
||||
#!/usr/bin/env node
|
||||
if (process.platform === "win32") process.title = "Bds Maneger CLI"; else process.title = "Bds-Manger-CLI";
|
||||
process.env.IS_BDS_CLI = process.env.IS_BIN_BDS = true;
|
||||
|
||||
// External Modules
|
||||
const cli_color = require("cli-color");
|
||||
const serverline = require("serverline");
|
||||
const inquirer = require("inquirer");
|
||||
|
||||
// Bin Args
|
||||
const ProcessArgs = require("minimist")(process.argv.slice(2));
|
||||
|
||||
// Import Bds Core
|
||||
const BdsCore = require("../index");
|
||||
const BdsReq = require("../lib/Requests");
|
||||
const BdsExtraInfo = require("../BdsManegerInfo.json");
|
||||
const commandExits = require("../lib/commandExist");
|
||||
const BdsMenus = require("./bds_maneger/menus");
|
||||
|
||||
// Async functiona
|
||||
async function Runner() {
|
||||
// ESM Modules
|
||||
const ora = (await import("ora")).default;
|
||||
|
||||
// Update Bds Core Platform
|
||||
if (ProcessArgs.platform || ProcessArgs.p) {
|
||||
const UpdatePla = ora("Updating Bds Platform").start();
|
||||
try {
|
||||
BdsCore.platform_update(ProcessArgs.platform || ProcessArgs.p);
|
||||
UpdatePla.succeed(`Now the platform is the ${ProcessArgs.platform || ProcessArgs.p}`);
|
||||
} catch (error) {
|
||||
UpdatePla.fail(`Unable to update platform to ${ProcessArgs.platform || ProcessArgs.p}`);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
// Print Info about Bds Core and Platforms
|
||||
if (ProcessArgs.info || ProcessArgs.i) {
|
||||
const { valid_platform } = await (require("../lib/BdsSystemInfo"))();
|
||||
var checkothearch = "";
|
||||
if (process.platform === "linux" && BdsCore.arch !== "x64"){checkothearch = `qemu-x86_64-static is installed to emulate an x64 system: ${commandExits("qemu-x86_64-static")}\n`}
|
||||
if (process.platform === "android" && BdsCore.arch !== "x64"){checkothearch = `qemu-x86_64 is installed to emulate an x64 system: ${commandExits("qemu-x86_64")}\n`}
|
||||
const help = [
|
||||
`Bds Maneger Core And Bds Maneger CLI version: ${cli_color.magentaBright(BdsCore.package_json.version)}`,
|
||||
`System: ${cli_color.yellow(process.platform)}, architecture: ${cli_color.blue(BdsCore.arch)}`,
|
||||
checkothearch,
|
||||
"**************************************************************",
|
||||
"* Servers currently available:",
|
||||
`* - Bedrock: ${valid_platform.bedrock}`,
|
||||
`* - Pocketmine-MP: ${valid_platform.pocketmine}`,
|
||||
`* - Dragonfly: ${valid_platform.dragonfly}`,
|
||||
`* - Java: ${valid_platform.java}`,
|
||||
`* - Spigot: ${valid_platform.java}`,
|
||||
"*",
|
||||
"**************************************************************"
|
||||
];
|
||||
console.log(cli_color.whiteBright(help.join("\n").replace(/true/gi, cli_color.greenBright("true")).replace(/false/gi, cli_color.redBright("false")).replace(/undefined/gi, cli_color.red("undefined"))));
|
||||
// End
|
||||
return;
|
||||
}
|
||||
|
||||
// Download
|
||||
if (ProcessArgs.download || ProcessArgs.d) {
|
||||
const VersionList = Object.getOwnPropertyNames((await BdsReq.json(BdsExtraInfo.Fetchs.servers))[BdsCore.BdsSettigs.GetPlatform()]).map(version => ({
|
||||
name: `${BdsCore.BdsSettigs.GetPlatform()}: v${version}`,
|
||||
value: version,
|
||||
}))
|
||||
if ((ProcessArgs.download || ProcessArgs.d) === true || (ProcessArgs.download || ProcessArgs.d) === "latest") ProcessArgs.d = ProcessArgs.download = (await inquirer.prompt([
|
||||
{
|
||||
type: "list",
|
||||
name: "download",
|
||||
message: "Select the platform to download",
|
||||
choices: VersionList
|
||||
}
|
||||
])).download;
|
||||
const oraDownload = ora(`Downloading ${BdsCore.BdsSettigs.GetPlatform()} on version ${ProcessArgs.d || ProcessArgs.download}`).start();
|
||||
try {
|
||||
const DownloadInfo = await BdsCore.download.v2(ProcessArgs.d || ProcessArgs.download, true);
|
||||
const DownloadSucess = ["Downloaded Successfully"];
|
||||
if (DownloadInfo.version) DownloadSucess.push(`Version: ${DownloadInfo.version}`);
|
||||
if (DownloadInfo.data) DownloadSucess.push(`Data: ${DownloadInfo.data}`);
|
||||
if (DownloadInfo.platform) DownloadSucess.push(`Bds Core Platform: ${DownloadInfo.platform}`);
|
||||
oraDownload.succeed(DownloadSucess.join(", "))
|
||||
} catch (error) {
|
||||
oraDownload.fail(error.message);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (!(ProcessArgs.start || ProcessArgs.s)) return;
|
||||
|
||||
// Start
|
||||
const BdsCoreStart = BdsCore.start();
|
||||
BdsCoreStart.log(data => console.log(cli_color.blueBright(data.replace(/\n$/gi, ""))));
|
||||
BdsCoreStart.exit(code => {
|
||||
console.log(cli_color.redBright(`Bds Core Exit with code ${code}, Uptimed: ${BdsCoreStart.uptime}`));
|
||||
process.exit(code);
|
||||
});
|
||||
serverline.init();
|
||||
serverline.setCompletion(["tp"]);
|
||||
serverline.setPrompt("Command > ");
|
||||
serverline.on("line", async function(line) {
|
||||
if (/^@/.test(line)) {
|
||||
serverline.close();
|
||||
if (/^@stop/.test(line)) {
|
||||
BdsCoreStart.stop();
|
||||
return;
|
||||
} else if (/^@tp/.test(line)) {
|
||||
await BdsMenus.TpMenu();
|
||||
}
|
||||
return serverline.init();
|
||||
} else BdsCoreStart.command(line);
|
||||
});
|
||||
if (!(ProcessArgs["no-api"])) BdsCore.api()
|
||||
}
|
||||
Runner();
|
||||
#!/usr/bin/env node
|
||||
if (process.platform === "win32") process.title = "Bds Maneger CLI"; else process.title = "Bds-Manger-CLI";
|
||||
process.env.IS_BDS_CLI = process.env.IS_BIN_BDS = true;
|
||||
|
||||
// External Modules
|
||||
const cli_color = require("cli-color");
|
||||
const serverline = require("serverline");
|
||||
const inquirer = require("inquirer");
|
||||
|
||||
// Bin Args
|
||||
const ProcessArgs = require("minimist")(process.argv.slice(2));
|
||||
|
||||
// Import Bds Core
|
||||
const BdsCore = require("../index");
|
||||
const BdsReq = require("../lib/Requests");
|
||||
const BdsExtraInfo = require("../BdsManegerInfo.json");
|
||||
const commandExits = require("../lib/commandExist");
|
||||
const BdsMenus = require("./bds_maneger/menus");
|
||||
|
||||
// Async functiona
|
||||
async function Runner() {
|
||||
// ESM Modules
|
||||
const ora = (await import("ora")).default;
|
||||
|
||||
// Update Bds Core Platform
|
||||
if (ProcessArgs.platform || ProcessArgs.p) {
|
||||
const UpdatePla = ora("Updating Bds Platform").start();
|
||||
try {
|
||||
BdsCore.platform_update(ProcessArgs.platform || ProcessArgs.p);
|
||||
UpdatePla.succeed(`Now the platform is the ${ProcessArgs.platform || ProcessArgs.p}`);
|
||||
} catch (error) {
|
||||
UpdatePla.fail(`Unable to update platform to ${ProcessArgs.platform || ProcessArgs.p}`);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
// Print Info about Bds Core and Platforms
|
||||
if (ProcessArgs.info || ProcessArgs.i) {
|
||||
const { valid_platform } = await (require("../lib/BdsSystemInfo"))();
|
||||
var checkothearch = "";
|
||||
if (process.platform === "linux" && BdsCore.arch !== "x64"){checkothearch = `qemu-x86_64-static is installed to emulate an x64 system: ${commandExits("qemu-x86_64-static")}\n`}
|
||||
if (process.platform === "android" && BdsCore.arch !== "x64"){checkothearch = `qemu-x86_64 is installed to emulate an x64 system: ${commandExits("qemu-x86_64")}\n`}
|
||||
const help = [
|
||||
`Bds Maneger Core And Bds Maneger CLI version: ${cli_color.magentaBright(BdsCore.package_json.version)}`,
|
||||
`System: ${cli_color.yellow(process.platform)}, architecture: ${cli_color.blue(BdsCore.arch)}`,
|
||||
checkothearch,
|
||||
"**************************************************************",
|
||||
"* Servers currently available:",
|
||||
`* - Bedrock: ${valid_platform.bedrock}`,
|
||||
`* - Pocketmine-MP: ${valid_platform.pocketmine}`,
|
||||
`* - Dragonfly: ${valid_platform.dragonfly}`,
|
||||
`* - Java: ${valid_platform.java}`,
|
||||
`* - Spigot: ${valid_platform.java}`,
|
||||
"*",
|
||||
"**************************************************************"
|
||||
];
|
||||
console.log(cli_color.whiteBright(help.join("\n").replace(/true/gi, cli_color.greenBright("true")).replace(/false/gi, cli_color.redBright("false")).replace(/undefined/gi, cli_color.red("undefined"))));
|
||||
// End
|
||||
return;
|
||||
}
|
||||
|
||||
// Download
|
||||
if (ProcessArgs.download || ProcessArgs.d) {
|
||||
const VersionList = Object.getOwnPropertyNames((await BdsReq.json(BdsExtraInfo.Fetchs.servers))[BdsCore.BdsSettigs.GetPlatform()]).map(version => ({
|
||||
name: `${BdsCore.BdsSettigs.GetPlatform()}: v${version}`,
|
||||
value: version,
|
||||
}))
|
||||
if ((ProcessArgs.download || ProcessArgs.d) === true || (ProcessArgs.download || ProcessArgs.d) === "latest") ProcessArgs.d = ProcessArgs.download = (await inquirer.prompt([
|
||||
{
|
||||
type: "list",
|
||||
name: "download",
|
||||
message: "Select the platform to download",
|
||||
choices: VersionList
|
||||
}
|
||||
])).download;
|
||||
const oraDownload = ora(`Downloading ${BdsCore.BdsSettigs.GetPlatform()} on version ${ProcessArgs.d || ProcessArgs.download}`).start();
|
||||
try {
|
||||
const DownloadInfo = await BdsCore.download.v2(ProcessArgs.d || ProcessArgs.download, true);
|
||||
const DownloadSucess = ["Downloaded Successfully"];
|
||||
if (DownloadInfo.version) DownloadSucess.push(`Version: ${DownloadInfo.version}`);
|
||||
if (DownloadInfo.data) DownloadSucess.push(`Data: ${DownloadInfo.data}`);
|
||||
if (DownloadInfo.platform) DownloadSucess.push(`Bds Core Platform: ${DownloadInfo.platform}`);
|
||||
oraDownload.succeed(DownloadSucess.join(", "))
|
||||
} catch (error) {
|
||||
oraDownload.fail(error.message);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (!(ProcessArgs.start || ProcessArgs.s)) return;
|
||||
|
||||
// Start
|
||||
const BdsCoreStart = BdsCore.start();
|
||||
BdsCoreStart.log(data => console.log(cli_color.blueBright(data.replace(/\n$/gi, ""))));
|
||||
BdsCoreStart.exit(code => {
|
||||
console.log(cli_color.redBright(`Bds Core Exit with code ${code}, Uptimed: ${BdsCoreStart.uptime}`));
|
||||
process.exit(code);
|
||||
});
|
||||
serverline.init();
|
||||
serverline.setCompletion(["tp"]);
|
||||
serverline.setPrompt("Command > ");
|
||||
serverline.on("line", async function(line) {
|
||||
if (/^@/.test(line)) {
|
||||
serverline.close();
|
||||
if (/^@stop/.test(line)) {
|
||||
BdsCoreStart.stop();
|
||||
return;
|
||||
} else if (/^@tp/.test(line)) {
|
||||
await BdsMenus.TpMenu();
|
||||
}
|
||||
return serverline.init();
|
||||
} else BdsCoreStart.command(line);
|
||||
});
|
||||
if (!(ProcessArgs["no-api"])) BdsCore.api()
|
||||
}
|
||||
Runner();
|
||||
|
@ -1,162 +1,162 @@
|
||||
// Node Internal modules
|
||||
const fs = require("fs");
|
||||
|
||||
// Bds Manager Core modules
|
||||
const BdsCore = require("../../../../index");
|
||||
const BdsChecks = require("../../../UsersAndtokenChecks");
|
||||
const BdsSettings = require("../../../../lib/BdsSettings");
|
||||
|
||||
// Express
|
||||
const express = require("express");
|
||||
const app = express.Router();
|
||||
|
||||
// Find Player
|
||||
const GetPlayerJson = (Platform = BdsCore.getBdsConfig().server.platform) => ([...{...JSON.parse(fs.readFileSync(BdsCore.BdsSettigs.GetPaths("player"), "utf8"))}[Platform]]);
|
||||
|
||||
// Routes
|
||||
app.get("/", (req, res) => {
|
||||
const { Platform = BdsSettings.GetPlatform(), Player = null, Action = null } = req.query;
|
||||
let PlayerList = GetPlayerJson(Platform);
|
||||
if (Player) PlayerList = PlayerList.filter(PLS => PLS.Player === Player);
|
||||
if (Action) PlayerList = PlayerList.filter(PLS => PLS.Action === Action);
|
||||
|
||||
if (Player || Action) {
|
||||
if (PlayerList.length > 0) res.json(PlayerList);
|
||||
else res.status(404).json({
|
||||
Error: "Player not found",
|
||||
querys: req.query
|
||||
});
|
||||
return;
|
||||
}
|
||||
res.json(PlayerList);
|
||||
return;
|
||||
});
|
||||
|
||||
// Players Actions in Backside Manager
|
||||
// kick player
|
||||
app.get("/kick", (req, res) => {
|
||||
const { Token = null, Player = "Sirherobrine", Text = "You have been removed from the Server" } = req.query;
|
||||
if (!Token) return res.status(400).json({ error: "Token is required" });
|
||||
if (!BdsChecks.token_verify(Token)) return res.status(400).json({ error: "Token is invalid" });
|
||||
|
||||
// Kick player
|
||||
const RunnerServer = require("../../../BdsManegerServer").BdsRun;
|
||||
try {
|
||||
RunnerServer.kick(Player, Text);
|
||||
res.json({ success: true });
|
||||
} catch (error) {
|
||||
res.status(400).json({
|
||||
error: "Server nots Run",
|
||||
text: `${error}`
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Ban player
|
||||
app.get("/ban", (req, res) => {
|
||||
const { Token = null, Player = "Sirherobrine" } = req.query;
|
||||
if (!Token) return res.status(400).json({ error: "Token is required" });
|
||||
if (!BdsChecks.token_verify(Token)) return res.status(400).json({ error: "Token is invalid" });
|
||||
|
||||
// Ban player
|
||||
const RunnerServer = require("../../../BdsManegerServer").BdsRun;
|
||||
try {
|
||||
RunnerServer.ban(Player);
|
||||
res.json({ success: true });
|
||||
} catch (error) {
|
||||
res.status(400).json({
|
||||
error: "Server nots Run",
|
||||
text: `${error}`
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Op player
|
||||
app.get("/op", (req, res) => {
|
||||
const { Token = null, Player = "Sirherobrine" } = req.query;
|
||||
if (!Token) return res.status(400).json({ error: "Token is required" });
|
||||
if (!BdsChecks.token_verify(Token)) return res.status(400).json({ error: "Token is invalid" });
|
||||
|
||||
// Op player
|
||||
const RunnerServer = require("../../../BdsManegerServer").BdsRun;
|
||||
try {
|
||||
RunnerServer.op(Player);
|
||||
res.json({ success: true });
|
||||
} catch (error) {
|
||||
res.status(400).json({
|
||||
error: "Server nots Run",
|
||||
text: `${error}`
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Deop player
|
||||
app.get("/deop", (req, res) => {
|
||||
const { Token = null, Player = "Sirherobrine" } = req.query;
|
||||
if (!Token) return res.status(400).json({ error: "Token is required" });
|
||||
if (!BdsChecks.token_verify(Token)) return res.status(400).json({ error: "Token is invalid" });
|
||||
|
||||
// Deop player
|
||||
const RunnerServer = require("../../../BdsManegerServer").BdsRun;
|
||||
try {
|
||||
RunnerServer.deop(Player);
|
||||
res.json({ success: true });
|
||||
} catch (error) {
|
||||
res.status(400).json({
|
||||
error: "Server nots Run",
|
||||
text: `${error}`
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Say to Server
|
||||
app.get("/say", (req, res) => {
|
||||
const { Token = null, Text = "Hello Server" } = req.query;
|
||||
if (!Token) return res.status(400).json({ error: "Token is required" });
|
||||
if (!BdsChecks.token_verify(Token)) return res.status(400).json({ error: "Token is invalid" });
|
||||
|
||||
// Say to Server
|
||||
const RunnerServer = require("../../../BdsManegerServer").BdsRun;
|
||||
try {
|
||||
RunnerServer.say(Text);
|
||||
res.json({ success: true });
|
||||
} catch (error) {
|
||||
res.status(400).json({
|
||||
error: "Server nots Run",
|
||||
text: `${error}`
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Tp player
|
||||
app.get("/tp", (req, res) => {
|
||||
const { Token = null, Player = "Sirherobrine", X = 0, Y = 0, Z = 0 } = req.query;
|
||||
if (!Token) return res.status(400).json({ error: "Token is required" });
|
||||
if (!BdsChecks.token_verify(Token)) return res.status(400).json({ error: "Token is invalid" });
|
||||
|
||||
// Tp player
|
||||
const RunnerServer = require("../../../BdsManegerServer").BdsRun;
|
||||
try {
|
||||
RunnerServer.tp(Player, {
|
||||
x: X,
|
||||
y: Y,
|
||||
z: Z
|
||||
});
|
||||
res.json({ success: true });
|
||||
} catch (error) {
|
||||
res.status(400).json({
|
||||
error: "Server nots Run",
|
||||
text: `${error}`
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Export Routes
|
||||
module.exports = app;
|
||||
module.exports.APIPaths = [...app.stack.map(d => {
|
||||
if (d.route) {
|
||||
if (d.route.path) return d.route.path;
|
||||
else return d.route.regexp.source;
|
||||
}
|
||||
return null;
|
||||
// Node Internal modules
|
||||
const fs = require("fs");
|
||||
|
||||
// Bds Manager Core modules
|
||||
const BdsCore = require("../../../../index");
|
||||
const BdsChecks = require("../../../UsersAndtokenChecks");
|
||||
const BdsSettings = require("../../../../lib/BdsSettings");
|
||||
|
||||
// Express
|
||||
const express = require("express");
|
||||
const app = express.Router();
|
||||
|
||||
// Find Player
|
||||
const GetPlayerJson = (Platform = BdsCore.getBdsConfig().server.platform) => ([...{...JSON.parse(fs.readFileSync(BdsCore.BdsSettigs.GetPaths("player"), "utf8"))}[Platform]]);
|
||||
|
||||
// Routes
|
||||
app.get("/", (req, res) => {
|
||||
const { Platform = BdsSettings.GetPlatform(), Player = null, Action = null } = req.query;
|
||||
let PlayerList = GetPlayerJson(Platform);
|
||||
if (Player) PlayerList = PlayerList.filter(PLS => PLS.Player === Player);
|
||||
if (Action) PlayerList = PlayerList.filter(PLS => PLS.Action === Action);
|
||||
|
||||
if (Player || Action) {
|
||||
if (PlayerList.length > 0) res.json(PlayerList);
|
||||
else res.status(404).json({
|
||||
Error: "Player not found",
|
||||
querys: req.query
|
||||
});
|
||||
return;
|
||||
}
|
||||
res.json(PlayerList);
|
||||
return;
|
||||
});
|
||||
|
||||
// Players Actions in Backside Manager
|
||||
// kick player
|
||||
app.get("/kick", (req, res) => {
|
||||
const { Token = null, Player = "Sirherobrine", Text = "You have been removed from the Server" } = req.query;
|
||||
if (!Token) return res.status(400).json({ error: "Token is required" });
|
||||
if (!BdsChecks.token_verify(Token)) return res.status(400).json({ error: "Token is invalid" });
|
||||
|
||||
// Kick player
|
||||
const RunnerServer = require("../../../BdsManegerServer").BdsRun;
|
||||
try {
|
||||
RunnerServer.kick(Player, Text);
|
||||
res.json({ success: true });
|
||||
} catch (error) {
|
||||
res.status(400).json({
|
||||
error: "Server nots Run",
|
||||
text: `${error}`
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Ban player
|
||||
app.get("/ban", (req, res) => {
|
||||
const { Token = null, Player = "Sirherobrine" } = req.query;
|
||||
if (!Token) return res.status(400).json({ error: "Token is required" });
|
||||
if (!BdsChecks.token_verify(Token)) return res.status(400).json({ error: "Token is invalid" });
|
||||
|
||||
// Ban player
|
||||
const RunnerServer = require("../../../BdsManegerServer").BdsRun;
|
||||
try {
|
||||
RunnerServer.ban(Player);
|
||||
res.json({ success: true });
|
||||
} catch (error) {
|
||||
res.status(400).json({
|
||||
error: "Server nots Run",
|
||||
text: `${error}`
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Op player
|
||||
app.get("/op", (req, res) => {
|
||||
const { Token = null, Player = "Sirherobrine" } = req.query;
|
||||
if (!Token) return res.status(400).json({ error: "Token is required" });
|
||||
if (!BdsChecks.token_verify(Token)) return res.status(400).json({ error: "Token is invalid" });
|
||||
|
||||
// Op player
|
||||
const RunnerServer = require("../../../BdsManegerServer").BdsRun;
|
||||
try {
|
||||
RunnerServer.op(Player);
|
||||
res.json({ success: true });
|
||||
} catch (error) {
|
||||
res.status(400).json({
|
||||
error: "Server nots Run",
|
||||
text: `${error}`
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Deop player
|
||||
app.get("/deop", (req, res) => {
|
||||
const { Token = null, Player = "Sirherobrine" } = req.query;
|
||||
if (!Token) return res.status(400).json({ error: "Token is required" });
|
||||
if (!BdsChecks.token_verify(Token)) return res.status(400).json({ error: "Token is invalid" });
|
||||
|
||||
// Deop player
|
||||
const RunnerServer = require("../../../BdsManegerServer").BdsRun;
|
||||
try {
|
||||
RunnerServer.deop(Player);
|
||||
res.json({ success: true });
|
||||
} catch (error) {
|
||||
res.status(400).json({
|
||||
error: "Server nots Run",
|
||||
text: `${error}`
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Say to Server
|
||||
app.get("/say", (req, res) => {
|
||||
const { Token = null, Text = "Hello Server" } = req.query;
|
||||
if (!Token) return res.status(400).json({ error: "Token is required" });
|
||||
if (!BdsChecks.token_verify(Token)) return res.status(400).json({ error: "Token is invalid" });
|
||||
|
||||
// Say to Server
|
||||
const RunnerServer = require("../../../BdsManegerServer").BdsRun;
|
||||
try {
|
||||
RunnerServer.say(Text);
|
||||
res.json({ success: true });
|
||||
} catch (error) {
|
||||
res.status(400).json({
|
||||
error: "Server nots Run",
|
||||
text: `${error}`
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Tp player
|
||||
app.get("/tp", (req, res) => {
|
||||
const { Token = null, Player = "Sirherobrine", X = 0, Y = 0, Z = 0 } = req.query;
|
||||
if (!Token) return res.status(400).json({ error: "Token is required" });
|
||||
if (!BdsChecks.token_verify(Token)) return res.status(400).json({ error: "Token is invalid" });
|
||||
|
||||
// Tp player
|
||||
const RunnerServer = require("../../../BdsManegerServer").BdsRun;
|
||||
try {
|
||||
RunnerServer.tp(Player, {
|
||||
x: X,
|
||||
y: Y,
|
||||
z: Z
|
||||
});
|
||||
res.json({ success: true });
|
||||
} catch (error) {
|
||||
res.status(400).json({
|
||||
error: "Server nots Run",
|
||||
text: `${error}`
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Export Routes
|
||||
module.exports = app;
|
||||
module.exports.APIPaths = [...app.stack.map(d => {
|
||||
if (d.route) {
|
||||
if (d.route.path) return d.route.path;
|
||||
else return d.route.regexp.source;
|
||||
}
|
||||
return null;
|
||||
}).filter(d => d)];
|
Reference in New Issue
Block a user