Rewrite in typescrypt #327
@ -1,3 +1,11 @@
|
||||
node_modules/
|
||||
.git/
|
||||
/node_modules/
|
||||
/.git/
|
||||
/.github/
|
||||
/.vscode/
|
||||
/.devcontainer/
|
||||
/*.md
|
||||
.*ignore
|
||||
.gitpod.y*ml
|
||||
dist/
|
||||
Dockerfile
|
||||
docker-compose.y*ml
|
2
.github/workflows/publish_docker_main.yml
vendored
2
.github/workflows/publish_docker_main.yml
vendored
@ -43,7 +43,7 @@ jobs:
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
target: server
|
||||
target: bdscore
|
||||
tags: ${{ env.DOCKERIMAGE }}:latest
|
||||
platforms: ${{ env.DOCKERPLATFORM }}
|
||||
cache-from: type=gha,scope=${{ github.ref }}_${{ hashFiles('**/package-lock.json') }}
|
||||
|
2
.github/workflows/publish_docker_release.yml
vendored
2
.github/workflows/publish_docker_release.yml
vendored
@ -36,7 +36,7 @@ jobs:
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
target: server
|
||||
target: bdscore
|
||||
tags: ${{ env.DOCKERIMAGE }}:latest
|
||||
platforms: ${{ env.DOCKERPLATFORM }}
|
||||
cache-from: type=gha,scope=${{ github.ref }}_${{ hashFiles('**/package-lock.json') }}
|
||||
|
136
Dockerfile
136
Dockerfile
@ -1,74 +1,98 @@
|
||||
FROM debian:latest
|
||||
LABEL name="Bds Maneger Docker"
|
||||
FROM debian:latest AS nodedowload
|
||||
ENV DEBIAN_FRONTEND="noninteractive"
|
||||
RUN apt update && apt -y install wget tar lsb-release
|
||||
|
||||
# Install latest docker image
|
||||
RUN mkdir /tmp/Node && NODEURL=""; NODEVERSION=$(wget -qO- https://api.github.com/repos/nodejs/node/releases | grep tag_name | cut -d '"' -f 4 | sort -V | tail -n 1) && \
|
||||
case $(uname -m) in \
|
||||
x86_64 ) NODEURL="https://nodejs.org/download/release/$NODEVERSION/node-$NODEVERSION-linux-x64.tar.gz";; \
|
||||
aarch64 ) NODEURL="https://nodejs.org/download/release/$NODEVERSION/node-$NODEVERSION-linux-arm64.tar.gz";; \
|
||||
armv7l ) NODEURL="https://nodejs.org/download/release/$NODEVERSION/node-$NODEVERSION-linux-armv7l.tar.gz";; \
|
||||
ppc64le ) NODEURL="https://nodejs.org/download/release/$NODEVERSION/node-$NODEVERSION-linux-ppc64le.tar.gz";; \
|
||||
s390x ) NODEURL="https://nodejs.org/download/release/$NODEVERSION/node-$NODEVERSION-linux-s390x.tar.gz";; \
|
||||
*) echo "Unsupported architecture ($(uname -m))"; exit 1;; \
|
||||
esac && \
|
||||
echo "Node bin Url: ${NODEURL}"; wget -q "${NODEURL}" -O /tmp/node.tar.gz && \
|
||||
tar xfz /tmp/node.tar.gz -C /tmp/Node && \
|
||||
mkdir /tmp/nodebin && cp -rp /tmp/Node/*/* /tmp/nodebin && ls /tmp/nodebin && rm -rfv /tmp/nodebin/LICENSE /tmp/nodebin/*.md
|
||||
|
||||
FROM debian:latest AS libries
|
||||
ENV DEBIAN_FRONTEND="noninteractive"
|
||||
RUN apt update && apt -y install wget unzip zip
|
||||
RUN mkdir -p /libries; mkdir /libries/lib64; \
|
||||
if [ "$(uname -m)" != "x86_64" ];then \
|
||||
apt install -y qemu-user-static; \
|
||||
wget -q "https://github.com/The-Bds-Maneger/external_files/raw/main/Linux/libs_amd64.zip" -O /tmp/libries.zip; \
|
||||
unzip -o /tmp/libries.zip -d /libries; \
|
||||
rm -rfv /tmp/libries.zip; \
|
||||
fi
|
||||
|
||||
FROM debian:latest AS bdscore
|
||||
LABEL org.opencontainers.image.title="Bds Maneger Docker"
|
||||
LABEL org.opencontainers.image.description="Start Minecraft Server with Docker containers and Auto Control Server wirh Bds Maneger Core."
|
||||
LABEL org.opencontainers.image.vendor="Sirherobrine23"
|
||||
LABEL org.opencontainers.image.licenses="MIT"
|
||||
LABEL org.opencontainers.image.source="https://github.com/The-Bds-Maneger/Bds-Maneger-Core.git"
|
||||
ENV DEBIAN_FRONTEND="noninteractive"
|
||||
|
||||
# Install Core Packages
|
||||
RUN apt update && apt install -y curl wget unzip zip xz-utils tar procps
|
||||
|
||||
# Install external Libries to another architecture
|
||||
RUN if [ "$(uname -m)" != "x86_64" ];then \
|
||||
mkdir -p /lib64; \
|
||||
apt install -y qemu-user-static; \
|
||||
wget -q "https://github.com/The-Bds-Maneger/external_files/raw/main/Linux/libs_amd64.zip" -O /tmp/libries.zip; \
|
||||
unzip -o /tmp/libries.zip -d /; \
|
||||
rm -rfv /tmp/libries.zip; \
|
||||
fi
|
||||
COPY --from=libries /libries/ /
|
||||
# Install NodeJS and latest NPM
|
||||
COPY --from=nodedowload /tmp/nodebin/ /usr
|
||||
RUN npm -g install npm@latest
|
||||
|
||||
# Install external Libries to ARM64
|
||||
RUN apt install -y ca-certificates make build-essential procps lsb-release xdg-utils g++ libatomic1 libnss3 libatk-bridge2.0-0 gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxrandr2 libxrender1 libxss1 libxtst6 fonts-liberation libnss3 libgbm-dev
|
||||
|
||||
# Install Node.js
|
||||
RUN NODEVERSION=$(wget -qO- https://api.github.com/repos/nodejs/node/releases | grep tag_name | cut -d '"' -f 4 | sort -V | tail -n 1) && \
|
||||
case $(uname -m) in \
|
||||
x86_64 ) wget -q "https://nodejs.org/download/release/$NODEVERSION/node-$NODEVERSION-linux-x64.tar.xz" -O /tmp/node.tar.xz;; \
|
||||
aarch64 ) wget -q "https://nodejs.org/download/release/$NODEVERSION/node-$NODEVERSION-linux-arm64.tar.xz" -O /tmp/node.tar.xz;; \
|
||||
armv7l ) wget -q "https://nodejs.org/download/release/$NODEVERSION/node-$NODEVERSION-linux-armv7l.tar.xz" -O /tmp/node.tar.xz;; \
|
||||
ppc64el ) wget -q "https://nodejs.org/download/release/$NODEVERSION/node-$NODEVERSION-linux-ppc64le.tar.xz" -O /tmp/node.tar.xz;; \
|
||||
s390x ) wget -q "https://nodejs.org/download/release/$NODEVERSION/node-$NODEVERSION-linux-s390x.tar.xz" -O /tmp/node.tar.xz;; \
|
||||
*) echo "Unsupported architecture"; exit 1;; \
|
||||
esac && \
|
||||
mkdir /tmp/Node && \
|
||||
tar -xJf /tmp/node.tar.xz -C /tmp/Node && \
|
||||
rm -rf /tmp/node.tar.xz && \
|
||||
cp -rf /tmp/Node/*/* /usr && \
|
||||
rm -rf /tmp/Node && \
|
||||
npm -g install npm@latest
|
||||
# Install Core Packages
|
||||
ENV DEBIAN_FRONTEND="noninteractive"
|
||||
RUN apt update && \
|
||||
apt install -y procps ca-certificates procps lsb-release xdg-utils g++ libatomic1 libnss3 \
|
||||
libatk-bridge2.0-0 gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 \
|
||||
libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 \
|
||||
libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 \
|
||||
libxcursor1 libxdamage1 libxext6 libxfixes3 libxrandr2 libxrender1 libxss1 libxtst6 fonts-liberation libnss3 libgbm-dev
|
||||
|
||||
# Install openjdk
|
||||
RUN apt update && \
|
||||
JAVAVERSIONS="$(apt search openjdk|grep '/'|grep "openjdk-"|sed 's|/| |g'|awk '{print $1}'|grep 'jre'|sed -e 's|-jre.*||g'|uniq)";\
|
||||
JAVAVERSIONS="$(apt search openjdk|grep '/'|grep 'openjdk-'|sed 's|/| |g'|awk '{print $1}'|grep 'jre'|sed -e 's|-jre.*||g'|uniq)";\
|
||||
case $JAVAVERSIONS in \
|
||||
*openjdk-17* ) apt install -y openjdk-17*;; \
|
||||
*openjdk-16* ) apt install -y openjdk-16*;; \
|
||||
*17* ) apt install -y openjdk-17*;; \
|
||||
*16* ) apt install -y openjdk-16*;; \
|
||||
*) echo "Unsupported Java Version, avaibles"; echo "$JAVAVERSIONS";exit 0;; \
|
||||
esac
|
||||
|
||||
# Create Volume to Storage Server And Config
|
||||
VOLUME [ "/root/bds_core" ]
|
||||
# Create Volume to Storage Server
|
||||
VOLUME [ "/data" ]
|
||||
|
||||
# App Workspace
|
||||
WORKDIR /app
|
||||
ENTRYPOINT [ "node", "--trace-warnings", "/app/dist/cjs/bin/docker.js" ]
|
||||
|
||||
# Ports
|
||||
EXPOSE 3000/tcp
|
||||
EXPOSE 19132/udp
|
||||
EXPOSE 19133/udp
|
||||
EXPOSE 25565/tcp
|
||||
EXPOSE 25566/tcp
|
||||
|
||||
# Default ENVs
|
||||
ENV NODE_ENV="production"
|
||||
ENV SERVER_PATH="/data/server"
|
||||
ENV BACKUP_PATH="/data/backups"
|
||||
ENV LOG_PATH="/data/logs"
|
||||
ENV EXTRA_PATH="/data/extra"
|
||||
|
||||
# Server Settings
|
||||
ENV DESCRIPTION="My Sample Server"
|
||||
ENV WORLD_NAME="My Map"
|
||||
ENV GAMEMODE="survival"
|
||||
ENV DIFFICULTY="normal"
|
||||
ENV MAXPLAYERS="5"
|
||||
ENV REQUIRED_LOGIN="false"
|
||||
ENV ALLOW_COMMADS="false"
|
||||
|
||||
# Bds Core Settings
|
||||
ENV VERSION="latest"
|
||||
ENV PLATFORM="bedrock"
|
||||
|
||||
# Node packages
|
||||
COPY package*.json ./
|
||||
RUN npm install && npm run build
|
||||
|
||||
# Set default ENVs to Bds Core
|
||||
ENV SERVER_VERSION="true" \
|
||||
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" \
|
||||
LEVEL_SEED="" \
|
||||
SERVER="bedrock" \
|
||||
SERVER_VERSION="latest" \
|
||||
NODE_ENV="production"
|
||||
EXPOSE 19132/udp 19133/udp 1932/tcp
|
||||
WORKDIR /opt/backend_core_scripts/
|
||||
ENTRYPOINT [ "sh", "-c", "node bin/BdsManeger.js start -ak -d ${SERVER_VERSION} -p ${SERVER} --players ${PLAYERS} --world-name ${WORLD_NAME} --description ${DESCRIPTION} --gamemode ${GAMEMODE} --difficulty ${DIFFICULTY} --level-seed ${LEVEL_SEED}" ]
|
||||
RUN npm install --production --no-save
|
||||
COPY ./ ./
|
||||
RUN npm run build:cjs
|
||||
|
146
README.md
146
README.md
@ -1,110 +1,100 @@
|
||||
# Bds Maneger Core
|
||||
|
||||
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.
|
||||
This is a small hub to manage various servers for Minecraft Bedrock and for Minecraft Java, such as installing, starting and keeping up to date with the latest version available.
|
||||
|
||||
Any contribution is welcome, but before a look at [CONTRIBUTING.md](CONTRIBUTING.md), [Bds Manager Core code of conduct](CODE_OF_CONDUCT.md)
|
||||
This module is fully compatible with ESM, CJS and Typescript.
|
||||
|
||||
## Requirements for Bds Maneger Core
|
||||
## Requirements
|
||||
|
||||
### All
|
||||
This module requires some requirements to work:
|
||||
|
||||
* [Nodejs 15.6.0+](https://nodejs.org/en/download/current/)
|
||||
* [OpenJDK 16+](https://www.oracle.com/java/technologies/javase-jdk16-downloads.html)
|
||||
* NodeJS: `^15.x`.
|
||||
* Java: `^8.0` or OpenJDK: `^16`.
|
||||
|
||||
### Windows 10+
|
||||
### For Windows Users
|
||||
|
||||
* [Microsoft Visual Studio C++ (The Bds Maneger Documentation)](<https://docs.bdsmaneger.com/docs/Bds Maneger core/WindowsFixDll/#windows-server>)
|
||||
Minecraft Bedrock needs Visual studio C++ if you are using Windows Server ([More information you can find on the Wiki](<https://github.com/The-Bds-Maneger/Bds-Maneger-Core/wiki/Server-Platforms#minecraft-bedrock-server-alpha>)).
|
||||
|
||||
## Documentation
|
||||
## CLI
|
||||
|
||||
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)
|
||||
This module also includes a simple CLI for managing servers. how:
|
||||
|
||||
## Badges
|
||||
1. Download compatible server versions.
|
||||
2. Update the server.
|
||||
3. Start the server.
|
||||
4. Backup Server.
|
||||
|
||||
[![Total alerts](https://img.shields.io/lgtm/alerts/g/Bds-Maneger/bds_maneger_api.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/Bds-Maneger/bds_maneger_api/alerts/)
|
||||
[![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)
|
||||
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/d357bef9c4ba4198ab16be64a5adf051)](https://www.codacy.com/gh/The-Bds-Maneger/Bds-Maneger-Core/dashboard?utm_source=github.com&utm_medium=referral&utm_content=The-Bds-Maneger/Bds-Maneger-Core&utm_campaign=Badge_Grade)
|
||||
## Install
|
||||
|
||||
## Start Bds Maneger Core with npx
|
||||
To install CLI: `npm install -g @the-bds-maneger/core` (`Linux user Use sudo or root`).
|
||||
|
||||
### CLI
|
||||
To Install module: `npm install @the-bds-maneger/core`.
|
||||
|
||||
All options can be found in the bds maneger core documentation.
|
||||
Run withou install: `npx @the-bds-maneger/core`.
|
||||
|
||||
`npx @the-bds-maneger/core@latest -sk`
|
||||
|
||||
## Install Bds Maneger Core globally
|
||||
|
||||
The commands available after installation:
|
||||
|
||||
* bds_maneger
|
||||
|
||||
`npm i -g @the-bds-maneger/core@latest`
|
||||
|
||||
## Launch Bds Maneger Core with a docker image
|
||||
## Docker and Docker Compose
|
||||
|
||||
### Docker Compose
|
||||
|
||||
[Docker Compose Install guide](https://docs.docker.com/compose/install/)
|
||||
[Docker Compose releases](<https://github.com/docker/compose/releases/latest>).
|
||||
|
||||
```yaml
|
||||
version: "2.1"
|
||||
* MacOS and Windows docker users is already installed by default in Docker Desktop.
|
||||
|
||||
```yml
|
||||
version: "3.9"
|
||||
volumes:
|
||||
server_storage:
|
||||
services:
|
||||
BdsCore:
|
||||
bdscore:
|
||||
image: ghcr.io/the-bds-maneger/core:latest
|
||||
container_name: BdsCore
|
||||
restart: always
|
||||
network_mode: host
|
||||
environment:
|
||||
DESCRIPTION: running Minecraft Bedrock Server on the docker by Bds Manager
|
||||
WORLD_NAME: Bds Maneger Docker
|
||||
GAMEMODE: survival
|
||||
DIFFICULTY: normal
|
||||
ACCOUNT: "false"
|
||||
PLAYERS: 13
|
||||
SERVER: bedrock
|
||||
ENABLE_COMMANDS: "false"
|
||||
volumes:
|
||||
- ./BdsCore:/home/bds/bds_core
|
||||
- server_storage:/data
|
||||
environment:
|
||||
# Server Settings
|
||||
DESCRIPTION: "My Sample Server"
|
||||
WORLD_NAME: "My Map"
|
||||
GAMEMODE: "survival"
|
||||
DIFFICULTY: "normal"
|
||||
MAXPLAYERS: "5"
|
||||
REQUIRED_LOGIN: "false"
|
||||
# Bds Core Settings
|
||||
VERSION: "latest"
|
||||
PLATFORM: "bedrock"
|
||||
ports:
|
||||
# Port to API
|
||||
- 3000:3000/tcp
|
||||
# Server Port to bedrock
|
||||
- 19132:19132/udp
|
||||
- 19133:19133/udp
|
||||
# Server Port to java
|
||||
- 25565:25565/tcp
|
||||
- 25565:25565/udp
|
||||
```
|
||||
|
||||
### Windows
|
||||
### Docker
|
||||
|
||||
```cmd
|
||||
docker run --rm -d --name BdsManegerCore -v BdsCore:/home/bds/bds_core ^
|
||||
--restart=always -p 19132:19132/udp -p 19133:19133/udp -p 1932:1932/tcp ^
|
||||
-e DESCRIPTION="running Minecraft Bedrock Server on the docker by Bds Manager" ^
|
||||
-e WORLD_NAME="Bds Maneger Docker" ^
|
||||
-e GAMEMODE="survival" ^
|
||||
-e DIFFICULTY="normal" ^
|
||||
-e ACCOUNT="false" ^
|
||||
-e PLAYERS="13" ^
|
||||
-e SERVER="bedrock" ^
|
||||
-e ENABLE_COMMANDS="false" ^
|
||||
ghcr.io/the-bds-maneger/core:latest
|
||||
```
|
||||
create Docker volume: `docker volume create --driver local --name bds_server_storage`.
|
||||
|
||||
### Linux/MacOS
|
||||
run image:
|
||||
|
||||
```bash
|
||||
docker run --rm -d --name BdsManegerCore -v BdsCore/:/home/bds/bds_core \
|
||||
--restart=always -p 19132:19132/udp -p 19133:19133/udp -p 1932:1932/tcp \
|
||||
-e DESCRIPTION="running Minecraft Bedrock Server on the docker by Bds Manager" \
|
||||
-e WORLD_NAME="Bds Maneger Docker" \
|
||||
-e GAMEMODE="survival" \
|
||||
-e DIFFICULTY="normal" \
|
||||
-e ACCOUNT="false" \
|
||||
-e PLAYERS="13" \
|
||||
-e SERVER="bedrock" \
|
||||
-e ENABLE_COMMANDS="false" \
|
||||
docker run --rm -d \
|
||||
--name=bdscore \
|
||||
-v bds_server_storage:/data \
|
||||
-p 25565:25565/udp \
|
||||
-p 25565:25565/tcp \
|
||||
-p 19132:19132/udp \
|
||||
-p 19133:19133/udp \
|
||||
-p 3000:3000/tcp \
|
||||
-e DESCRIPTION="My Sample Server" \
|
||||
-e WORLD_NAME="My Map" \
|
||||
-e GAMEMODE="survival" \
|
||||
-e DIFFICULTY="normal" \
|
||||
-e MAXPLAYERS="5" \
|
||||
-e REQUIRED_LOGIN="false" \
|
||||
-e VERSION="latest" \
|
||||
-e PLATFORM="bedrock" \
|
||||
ghcr.io/the-bds-maneger/core:latest
|
||||
```
|
||||
|
||||
## Azure Container and Azure VM
|
||||
|
||||
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.
|
||||
|
||||
## Oracle Cloud
|
||||
|
||||
soon!
|
||||
Get log: `docker logs bdscore`.
|
||||
|
@ -19,7 +19,6 @@ services:
|
||||
BDS_VERSION: "latest"
|
||||
SERVER: "bedrock"
|
||||
ports:
|
||||
- 1932:3000/tcp
|
||||
- 3000:3000/tcp
|
||||
- 19132:19132/udp
|
||||
- 19133:19133/udp
|
8
package-lock.json
generated
8
package-lock.json
generated
@ -22,7 +22,6 @@
|
||||
"express": "^4.17.3",
|
||||
"prismarine-nbt": "^2.2.1",
|
||||
"properties-to-json": "^0.2.1",
|
||||
"typescript": "^4.6.2",
|
||||
"yargs": "^17.4.0"
|
||||
},
|
||||
"bin": {
|
||||
@ -34,7 +33,8 @@
|
||||
"@types/express": "^4.17.13",
|
||||
"@types/node": "^17.0.22",
|
||||
"@types/yargs": "^17.0.10",
|
||||
"npm-run-all": "^4.1.5"
|
||||
"npm-run-all": "^4.1.5",
|
||||
"typescript": "^4.6.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=15.6.0"
|
||||
@ -1786,6 +1786,7 @@
|
||||
"version": "4.6.3",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.3.tgz",
|
||||
"integrity": "sha512-yNIatDa5iaofVozS/uQJEl3JRWLKKGJKh6Yaiv0GLGSuhpFJe7P3SbHZ8/yjAHRQwKRoA6YZqlfjXWmVzoVSMw==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
"tsserver": "bin/tsserver"
|
||||
@ -3260,7 +3261,8 @@
|
||||
"typescript": {
|
||||
"version": "4.6.3",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.3.tgz",
|
||||
"integrity": "sha512-yNIatDa5iaofVozS/uQJEl3JRWLKKGJKh6Yaiv0GLGSuhpFJe7P3SbHZ8/yjAHRQwKRoA6YZqlfjXWmVzoVSMw=="
|
||||
"integrity": "sha512-yNIatDa5iaofVozS/uQJEl3JRWLKKGJKh6Yaiv0GLGSuhpFJe7P3SbHZ8/yjAHRQwKRoA6YZqlfjXWmVzoVSMw==",
|
||||
"dev": true
|
||||
},
|
||||
"unbox-primitive": {
|
||||
"version": "1.0.1",
|
||||
|
18
package.json
18
package.json
@ -6,8 +6,8 @@
|
||||
},
|
||||
"version": "2.0.0",
|
||||
"description": "A very simple way to manage Minecraft servers",
|
||||
"main": "dist/index.js",
|
||||
"types": "src/index.ts",
|
||||
"main": "dist/cjs/index.js",
|
||||
"types": "dist/cjs/index.d.ts",
|
||||
"exports": {
|
||||
"require": "./dist/src/index.js",
|
||||
"import": "./dist/esm/index.js"
|
||||
@ -18,20 +18,21 @@
|
||||
"build:esm": "tsc --module es2020 --outDir dist/esm"
|
||||
},
|
||||
"nodemonConfig": {
|
||||
"delay": 2500,
|
||||
"ext": "json,js,ts",
|
||||
"ignore": [
|
||||
"test/*"
|
||||
],
|
||||
"delay": 2500,
|
||||
"watch": [
|
||||
"src",
|
||||
"bin",
|
||||
"package.json",
|
||||
"package-lock.json"
|
||||
],
|
||||
"exec": "npm run build:cjs && node --trace-warnings ./dist/cjs/index.js start --Develop"
|
||||
"exec": "npm run build:cjs && node --trace-warnings ./dist/cjs/bin/index.js start --Develop"
|
||||
},
|
||||
"bin": {
|
||||
"bds_maneger": "dist/cjs/index.js"
|
||||
"bds_maneger": "dist/cjs/bin/index.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@ -45,7 +46,8 @@
|
||||
"java",
|
||||
"pocketmine",
|
||||
"server_mode",
|
||||
"rest"
|
||||
"rest",
|
||||
"typescript"
|
||||
],
|
||||
"author": "Sirherobrine23",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
@ -70,7 +72,6 @@
|
||||
"express": "^4.17.3",
|
||||
"prismarine-nbt": "^2.2.1",
|
||||
"properties-to-json": "^0.2.1",
|
||||
"typescript": "^4.6.2",
|
||||
"yargs": "^17.4.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
@ -79,6 +80,7 @@
|
||||
"@types/express": "^4.17.13",
|
||||
"@types/node": "^17.0.22",
|
||||
"@types/yargs": "^17.0.10",
|
||||
"npm-run-all": "^4.1.5"
|
||||
"npm-run-all": "^4.1.5",
|
||||
"typescript": "^4.6.3"
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ function ensureFileSync(pathFile: string){
|
||||
let serverPath = null;
|
||||
let worldName = null;
|
||||
|
||||
const providedServerPath = path.resolve(process.env.SERVERPATH||path.join(os.homedir(), "bds_core/servers"), "bedrock");
|
||||
const providedServerPath = path.resolve(process.env.SERVER_PATH||path.join(os.homedir(), "bds_core/servers"), "bedrock");
|
||||
const addonPath = path.resolve(providedServerPath, "../BDS-Addons/");
|
||||
if (!(fs.existsSync(addonPath))) fs.mkdirSync(addonPath, {recursive: true});
|
||||
|
||||
@ -55,7 +55,7 @@ const requiredFiles = ["behavior_packs", "resource_packs", "valid_known_packs.js
|
||||
* Prepares to install addons for the provided Bedrock Dedicated Server.
|
||||
*/
|
||||
export function addonInstaller() {
|
||||
// const providedServerPath = path.resolve(process.env.SERVERPATH||path.join(os.homedir(), "bds_core/servers"), "bedrock");
|
||||
// const providedServerPath = path.resolve(process.env.SERVER_PATH||path.join(os.homedir(), "bds_core/servers"), "bedrock");
|
||||
// Validate server path (path is provided, path is valid, path contains required files)
|
||||
if (!providedServerPath) throw new Error("You must provide a server path for BDSAddonInstaller");
|
||||
if (!fs.existsSync(providedServerPath)) throw new Error("The provided server path does not exist.\n" + providedServerPath);
|
||||
|
@ -5,11 +5,10 @@ import AdmZip from "adm-zip";
|
||||
|
||||
export default CreateBackup;
|
||||
export async function CreateBackup(Platform: "bedrock"|"java"|"pocketmine"|"spigot"|"dragonfly") {
|
||||
const ServerPath = path.resolve(process.env.SERVERPATH||path.join(os.homedir(), "bds_core/servers"), Platform);
|
||||
const BackupPath = path.resolve(process.env.BACKUPPATH||path.join(os.homedir(), "bds_core/backups"));
|
||||
const ServerPath = path.resolve(process.env.SERVER_PATH||path.join(os.homedir(), "bds_core/servers"), Platform);
|
||||
const BackupPath = path.resolve(process.env.BACKUP_PATH||path.join(os.homedir(), "bds_core/backups"));
|
||||
if (!(fs.existsSync(ServerPath))) throw new Error("Server no Installed or path not found");
|
||||
if (!(fs.existsSync(BackupPath))) fs.mkdirSync(BackupPath, {recursive: true});
|
||||
const BackupFile = path.resolve(BackupPath, `${Platform}_${new Date().toISOString().replace(/:/g, "-")}.zip`);
|
||||
const Backup = new AdmZip();
|
||||
if (Platform === "bedrock") {
|
||||
if (fs.existsSync(path.join(ServerPath, "worlds"))) Backup.addLocalFolder(path.join(ServerPath, "worlds"));
|
||||
@ -17,7 +16,8 @@ export async function CreateBackup(Platform: "bedrock"|"java"|"pocketmine"|"spig
|
||||
if (fs.existsSync(path.join(ServerPath, "permissions.json"))) Backup.addLocalFile(path.join(ServerPath, "permissions.json"));
|
||||
}
|
||||
|
||||
const BackupFile = path.resolve(BackupPath, `${Platform}_${new Date().toString().replace(/[-\(\)\:\s+]/gi, "_")}.zip`);
|
||||
const zipBuffer = Backup.toBuffer();
|
||||
fs.writeFileSync(BackupFile, zipBuffer);
|
||||
return zipBuffer;
|
||||
return {zipBuffer, BackupFile};
|
||||
}
|
28
src/bin/docker.ts
Normal file
28
src/bin/docker.ts
Normal file
@ -0,0 +1,28 @@
|
||||
import * as BdsCore from "../index";
|
||||
import * as BdsTypes from "../globalType";
|
||||
|
||||
const {
|
||||
VERSION = "latest",
|
||||
PLATFORM = "bedrock",
|
||||
DESCRIPTION = "My Sample Server",
|
||||
WORLD_NAME = "My Map",
|
||||
GAMEMODE = "survival",
|
||||
DIFFICULTY = "normal",
|
||||
MAXPLAYERS = "5",
|
||||
REQUIRED_LOGIN = "false",
|
||||
ALLOW_COMMADS = "false",
|
||||
} = process.env;
|
||||
|
||||
(async () => {
|
||||
if (VERSION === "latest") {
|
||||
await BdsCore.DownloadServer.DownloadServer(PLATFORM as BdsTypes.Platform, true);
|
||||
} else if (VERSION !== "latest") {
|
||||
await BdsCore.DownloadServer.DownloadServer(PLATFORM as BdsTypes.Platform, VERSION);
|
||||
} else {
|
||||
console.log("Invalid Version");
|
||||
}
|
||||
const Server = await BdsCore.Server.Start(PLATFORM as BdsTypes.Platform);
|
||||
Server.on("all", data => process.stdout.write(data));
|
||||
Server.exit(process.exit);
|
||||
|
||||
})();
|
@ -31,7 +31,7 @@ async function InstallPHP(PathToInstall: string) {
|
||||
}
|
||||
|
||||
export async function DownloadServer(Platform: bdsTypes.Platform, Version: string|boolean) {
|
||||
const ServerPath = path.resolve(process.env.SERVERPATH||path.join(os.homedir(), "bds_core/servers"), Platform);
|
||||
const ServerPath = path.resolve(process.env.SERVER_PATH||path.join(os.homedir(), "bds_core/servers"), Platform);
|
||||
const versions = await getVersions()
|
||||
const info = versions.platform.filter(v => v.name === Platform).find(v => v.version === (typeof Version === "boolean"?versions.latest[Platform]:Version));
|
||||
if (Platform === "bedrock") {
|
||||
@ -43,6 +43,7 @@ export async function DownloadServer(Platform: bdsTypes.Platform, Version: strin
|
||||
const JavaPath = path.resolve(ServerPath);
|
||||
if (!(await fs.existsSync(JavaPath))) fs.mkdirSync(JavaPath, {recursive: true});
|
||||
await fs.promises.writeFile(path.resolve(JavaPath, "Server.jar"), await getBuffer(String(info.data)));
|
||||
await fs.promises.writeFile(path.resolve(JavaPath, "eula.txt"), "eula=true");
|
||||
} else if (Platform === "spigot") {
|
||||
const SpigotPath = path.resolve(ServerPath);
|
||||
if (!(await fs.existsSync(SpigotPath))) fs.mkdirSync(SpigotPath, {recursive: true});
|
||||
|
@ -2,6 +2,7 @@ import * as Server from "./server";
|
||||
import * as Backup from "./backup";
|
||||
import * as DownloadServer from "./download_server";
|
||||
import * as API from "./api";
|
||||
import * as serverConfig from "./serverConfig";
|
||||
|
||||
export default {Server, Backup, DownloadServer, API};
|
||||
export {Server, Backup, DownloadServer, API};
|
||||
export default {Server, Backup, DownloadServer, API, serverConfig};
|
||||
export {Server, Backup, DownloadServer, API, serverConfig};
|
@ -34,7 +34,7 @@ export function getSessions() {return Sessions;}
|
||||
|
||||
// Start Server
|
||||
export async function Start(Platform: bdsTypes.Platform): Promise<BdsSession> {
|
||||
const ServerPath = path.resolve(process.env.SERVERPATH||path.join(os.homedir(), "bds_core/servers"), Platform);
|
||||
const ServerPath = path.resolve(process.env.SERVER_PATH||path.join(os.homedir(), "bds_core/servers"), Platform);
|
||||
if (!(fs.existsSync(ServerPath))) fs.mkdirSync(ServerPath, {recursive: true});
|
||||
const Process: {command: string; args: Array<string>; env: {[env: string]: string}; cwd: string;} = {
|
||||
command: "",
|
||||
@ -156,7 +156,12 @@ export async function Start(Platform: bdsTypes.Platform): Promise<BdsSession> {
|
||||
},
|
||||
creteBackup: (crontime: string|Date) => {
|
||||
const cronJob = new node_cron.CronJob(crontime, async () => {
|
||||
bdsBackup.CreateBackup(Platform);
|
||||
if (Platform === "bedrock") {
|
||||
execCommand("save hold");
|
||||
execCommand("save query");
|
||||
}
|
||||
await bdsBackup.CreateBackup(Platform);
|
||||
if (Platform === "bedrock") execCommand("save resume");
|
||||
});
|
||||
cronJob.start();
|
||||
return;
|
||||
@ -175,9 +180,10 @@ export async function Start(Platform: bdsTypes.Platform): Promise<BdsSession> {
|
||||
const bedrockConfig = await serverConfig.parseConfig(Platform);
|
||||
Seesion.seed = bedrockConfig.nbt.parsed.value.RandomSeed.value.toString();
|
||||
}
|
||||
const logFile = path.resolve(ServerPath, `../log/${Seesion.id}.log`);
|
||||
const logFile = path.resolve(process.env.LOG_PATH||path.resolve(ServerPath, "../log"), `${Platform}_${Seesion.id}.log`);
|
||||
if(!(fs.existsSync(path.parse(logFile).dir))) fs.mkdirSync(path.parse(logFile).dir, {recursive: true});
|
||||
const logStream = fs.createWriteStream(logFile, {flags: "w+"});
|
||||
logStream.write(`[${StartDate.toISOString()}] Server started\n\n`);
|
||||
onLog("all", data => logStream.write(data));
|
||||
Sessions[Seesion.id] = Seesion;
|
||||
return Seesion;
|
||||
|
@ -1,3 +1,4 @@
|
||||
import crypto from "crypto";
|
||||
import path from "path";
|
||||
import os from "os";
|
||||
import fs from "fs";
|
||||
@ -5,10 +6,10 @@ import * as prismarineNbt from "prismarine-nbt";
|
||||
import properties_to_json from "properties-to-json";
|
||||
import * as bdsType from "./globalType";
|
||||
|
||||
type BdsConfigGet = {
|
||||
export type BdsConfigGet = {
|
||||
world: string;
|
||||
description: string;
|
||||
gamemode: string;
|
||||
gamemode: "survival"|"creative"|"adventure"|"spectator";
|
||||
difficulty: "peaceful"|"easy"|"normal"|"hard";
|
||||
players: number;
|
||||
whitelist: true|false;
|
||||
@ -22,7 +23,7 @@ type BdsConfigGet = {
|
||||
}
|
||||
|
||||
export async function parseConfig(Platform: bdsType.Platform): Promise<BdsConfigGet> {
|
||||
const serverPath = path.resolve(process.env.SERVERPATH||path.join(os.homedir(), "bds_core/servers"), Platform);
|
||||
const serverPath = path.resolve(process.env.SERVER_PATH||path.join(os.homedir(), "bds_core/servers"), Platform);
|
||||
if (Platform === "bedrock") {
|
||||
const bedrockConfigPath = path.join(serverPath, "server.properties");
|
||||
if (!(fs.existsSync(bedrockConfigPath))) throw new Error("Bedrock server config not found");
|
||||
@ -42,3 +43,121 @@ export async function parseConfig(Platform: bdsType.Platform): Promise<BdsConfig
|
||||
}
|
||||
throw new Error("Platform not supported");
|
||||
}
|
||||
|
||||
export type BdsConfigSet = {
|
||||
world: string;
|
||||
seed?: string;
|
||||
description: string;
|
||||
gamemode: "survival"|"creative"|"adventure"|"hardcore";
|
||||
difficulty: "peaceful"|"easy"|"normal"|"hard";
|
||||
players: number;
|
||||
whitelist: true|false;
|
||||
require_login: true|false;
|
||||
cheats_command: true|false;
|
||||
portv4: number;
|
||||
portv6: number;
|
||||
}
|
||||
|
||||
export async function createConfig(Platform: bdsType.Platform, config: BdsConfigSet): Promise<void> {
|
||||
const serverPath = path.resolve(process.env.SERVER_PATH||path.join(os.homedir(), "bds_core/servers"), Platform);
|
||||
if (Platform === "bedrock") {
|
||||
const bedrockConfigArray = [
|
||||
"view-distance=32",
|
||||
"tick-distance=4",
|
||||
"player-idle-timeout=0",
|
||||
"max-threads=8",
|
||||
"default-player-permission-level=member",
|
||||
"texturepack-required=true",
|
||||
"content-log-file-enabled=false",
|
||||
"compression-threshold=1",
|
||||
"server-authoritative-movement=server-auth",
|
||||
"player-movement-score-threshold=20",
|
||||
"player-movement-action-direction-threshold=0.85",
|
||||
"player-movement-distance-threshold=0.3",
|
||||
"player-movement-duration-threshold-in-ms=500",
|
||||
"correct-player-movement=false",
|
||||
"server-authoritative-block-breaking=false",
|
||||
"force-gamemode=false",
|
||||
];
|
||||
bedrockConfigArray.push(`level-name=${config.world}`);
|
||||
if (config.seed) bedrockConfigArray.push(`level-seed=${config.seed}`);
|
||||
else bedrockConfigArray.push("level-seed=");
|
||||
bedrockConfigArray.push(`server-name=${config.description}`);
|
||||
bedrockConfigArray.push(`gamemode=${config.gamemode}`);
|
||||
bedrockConfigArray.push(`difficulty=${config.difficulty}`);
|
||||
bedrockConfigArray.push(`allow-cheats=${config.cheats_command}`);
|
||||
bedrockConfigArray.push(`max-players=${config.players}`);
|
||||
bedrockConfigArray.push(`online-mode=${config.require_login}`);
|
||||
bedrockConfigArray.push(`allow-list=${config.whitelist}`);
|
||||
bedrockConfigArray.push(`server-port=${config.portv4}`);
|
||||
bedrockConfigArray.push(`server-portv6=${config.portv6}`);
|
||||
const bedrockConfig = bedrockConfigArray.join("\n");
|
||||
fs.writeFileSync(path.join(serverPath, "server.properties"), bedrockConfig);
|
||||
return;
|
||||
} else if (Platform === "java") {
|
||||
const javaConfigArray = [
|
||||
"query.port=65551",
|
||||
"enable-jmx-monitoring=false",
|
||||
"enable-query=true",
|
||||
"generator-settings=",
|
||||
"generate-structures=true",
|
||||
"network-compression-threshold=256",
|
||||
"max-tick-time=60000",
|
||||
"use-native-transport=true",
|
||||
"enable-status=true",
|
||||
"allow-flight=false",
|
||||
"view-distance=32",
|
||||
"max-build-height=256",
|
||||
"server-ip=",
|
||||
"sync-chunk-writes=true",
|
||||
"prevent-proxy-connections=false",
|
||||
"resource-pack=",
|
||||
"entity-broadcast-range-percentage=100",
|
||||
"player-idle-timeout=0",
|
||||
"force-gamemode=false",
|
||||
"rate-limit=0",
|
||||
"broadcast-console-to-ops=true",
|
||||
"spawn-npcs=true",
|
||||
"spawn-animals=true",
|
||||
"snooper-enabled=true",
|
||||
"function-permission-level=2",
|
||||
"text-filtering-config=",
|
||||
"spawn-monsters=true",
|
||||
"enforce-whitelist=false",
|
||||
"resource-pack-sha1=",
|
||||
"spawn-protection=16",
|
||||
"max-world-size=29999984",
|
||||
"require-resource-pack=true",
|
||||
"resource-pack-prompt=",
|
||||
"hide-online-players=false",
|
||||
"simulation-distance=10",
|
||||
"enable-rcon=false",
|
||||
`rcon.password=${crypto.randomBytes(6).toString("hex")}`,
|
||||
"rcon.port=25575",
|
||||
"broadcast-rcon-to-ops=true"
|
||||
];
|
||||
javaConfigArray.push(`level-name=${config.world}`);
|
||||
javaConfigArray.push(`motd=${config.description}`);
|
||||
if (config.gamemode === "hardcore") {
|
||||
javaConfigArray.push("gamemode=survival");
|
||||
javaConfigArray.push("hardcore=true");
|
||||
} else {
|
||||
javaConfigArray.push(`gamemode=${config.gamemode}`);
|
||||
javaConfigArray.push(`hardcore=false`);
|
||||
}
|
||||
javaConfigArray.push(`difficulty=${config.difficulty}`);
|
||||
if (config.seed) javaConfigArray.push(`level-seed=${config.seed}`);
|
||||
else javaConfigArray.push("level-seed=");
|
||||
javaConfigArray.push(`enable-command-block=${config.cheats_command}`);
|
||||
javaConfigArray.push(`max-players=${config.players}`);
|
||||
javaConfigArray.push(`online-mode=${config.require_login}`);
|
||||
javaConfigArray.push(`white-list=${config.whitelist}`);
|
||||
javaConfigArray.push(`server-port=${config.portv4}`);
|
||||
javaConfigArray.push("level-type=default");
|
||||
javaConfigArray.push("op-permission-level=4");
|
||||
javaConfigArray.push("pvp=true");
|
||||
javaConfigArray.push("allow-nether=true");
|
||||
await fs.promises.writeFile(path.join(serverPath, "server.properties"), javaConfigArray.join("\n"));
|
||||
} else if (Platform === "pocketmine") {}
|
||||
throw new Error("Platform not supported");
|
||||
}
|
Reference in New Issue
Block a user