diff --git a/.dockerignore b/.dockerignore
index be0edca..57351dc 100644
--- a/.dockerignore
+++ b/.dockerignore
@@ -1,4 +1,5 @@
node_modules/
Docker/
-!Docker/base
-!Docker/etc
\ No newline at end of file
+!Docker/root_path
+.git/
+Docker.sh
diff --git a/.github/workflows/nightly_docker.yml b/.github/workflows/DockerCheck.yml
similarity index 77%
rename from .github/workflows/nightly_docker.yml
rename to .github/workflows/DockerCheck.yml
index 477abdb..c542180 100644
--- a/.github/workflows/nightly_docker.yml
+++ b/.github/workflows/DockerCheck.yml
@@ -1,8 +1,6 @@
-name: The nightly Docker Image
+name: The Docker Image Check
on:
- push:
- branches-ignore:
- - dependabot/**
+ pull_request:
jobs:
Docker:
@@ -27,9 +25,8 @@ jobs:
id: docker_build
uses: docker/build-push-action@v2
with:
- push: true
file: Docker/Dockerfile
+ push: false
tags: |
- sirherobrine23/bdsmaneger:nightly
- bdsmaneger/maneger:nightly
+ bdsmaneger:test_${{ github.run_id }}
platforms: linux/amd64,linux/arm64
\ No newline at end of file
diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml
index 3c4aa3f..c308787 100644
--- a/.github/workflows/codeql-analysis.yml
+++ b/.github/workflows/codeql-analysis.yml
@@ -2,9 +2,11 @@ name: "CodeQL"
on:
push:
- branches: [ main, stable ]
+ branches:
+ - main
pull_request:
- branches: [ main, stable ]
+ branches:
+ - main
schedule:
- cron: "38 17 * * */3"
diff --git a/.github/workflows/npm_dev.yml b/.github/workflows/main.yml
similarity index 55%
rename from .github/workflows/npm_dev.yml
rename to .github/workflows/main.yml
index 008a7b2..2e74f93 100644
--- a/.github/workflows/npm_dev.yml
+++ b/.github/workflows/main.yml
@@ -1,4 +1,4 @@
-name: Npm dev package Publish
+name: Dev Publish NPM and Docker Image
on:
push:
branches:
@@ -11,18 +11,16 @@ on:
- 'CHANGELOG.md'
- 'Docker/*/**'
jobs:
- Npm-Publish:
+ Npm-Publish-Dev:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@master
-
- name: Npm and Node Setup
uses: actions/setup-node@v1
with:
node-version: 15.x
registry-url: https://registry.npmjs.org/
-
- name: Edit Version
run: |
id_run1=$(echo ${{ github.run_id }} |cut -b 1-2)
@@ -33,6 +31,31 @@ jobs:
sed "s|$old|\"version\": \"$new_version\",|g" package.json > package2.json
cat package2.json > package.json
rm -rfv package2.json
-
- name: Install Packages
run: npm install
+
+ Docker:
+ runs-on: ubuntu-latest
+ 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:
+ username: ${{ secrets.DOCKER_ORG_USER }}
+ password: ${{ secrets.DOCKER_ORG_PASS }}
+ - name: checkout
+ uses: actions/checkout@master
+
+ - name: Build Nightly Image
+ id: docker_build
+ uses: docker/build-push-action@v2
+ with:
+ push: true
+ file: Docker/Dockerfile
+ tags: |
+ sirherobrine23/bdsmaneger:nightly
+ bdsmaneger/maneger:nightly
+ platforms: linux/amd64,linux/arm64
\ No newline at end of file
diff --git a/.github/workflows/merge_depedencies.yaml b/.github/workflows/merge_depedencies.yaml
index f574a0e..e264a60 100644
--- a/.github/workflows/merge_depedencies.yaml
+++ b/.github/workflows/merge_depedencies.yaml
@@ -1,10 +1,8 @@
name: "Dependabot Automerge - Action"
on:
pull_request:
- check_suite:
- types:
- - completed
- status: {}
+ branches:
+ - dependabot/**
jobs:
automerge:
runs-on: ubuntu-latest
diff --git a/Docker.sh b/Docker.sh
new file mode 100755
index 0000000..195e357
--- /dev/null
+++ b/Docker.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+docker_image_name='thebdsmaneger/maneger'
+docker build -f Docker/Dockerfile ${1} --tag ${docker_image_name} . && {
+ echo "----------------------------------------------"
+ if [ -e "/tmp/start_image" ];then DockerRun="y"; else read -rp "Run Image? (Y/n) " -e -i "y" DockerRun;fi
+ if [ -e "/tmp/start_image" ] || [ "${DockerRun}" == "y" ] || [ "${DockerRun}" == "Y" ];then [ -e "/tmp/start_image" ]|| touch /tmp/start_image ; docker run -ti --rm -p 8887:80/tcp -p 19132/udp -p 19133/udp -v /tmp/bds:/home/bds ${2} ${docker_image_name};
+ else echo "Run: \"docker run -ti --rm -p 8887:80 -p 19132/udp -p 19133/udp -v /tmp/bds:/home/bds ${2} ${docker_image_name}\"";
+ fi
+}
\ No newline at end of file
diff --git a/Docker/Dockerfile b/Docker/Dockerfile
index a616322..404727f 100644
--- a/Docker/Dockerfile
+++ b/Docker/Dockerfile
@@ -6,23 +6,34 @@ RUN \
echo "Arch: $(uname -m)"; \
apt update && \
apt install -y git curl openjdk-14-jdk openjdk-14-jre wget jq sudo unzip zip screen nginx python make build-essential $(case $(uname -m) in "x86_64") echo "";; *) echo "qemu-user-static binfmt-support";; esac) && \
+case $(uname -m) in "x86_64") echo "";; \
+*) wget https://raw.githubusercontent.com/The-Bds-Maneger/Raw_files/main/linux_libries.zip -O /tmp/libries.zip && unzip /tmp/libries.zip -d / && rm -rfv /tmp/libries.zip ;; \
+esac ;\
rm -rf /var/cache/apt/archives/* /var/lib/apt/lists/* /tmp/* && \
-mkdir -p /home/bds/ && rm -rfv /etc/nginx/sites-available/default
+mkdir -p /home/bds/ && rm -rfv /etc/nginx/sites-*/default
-# Copy Files
-COPY ./Docker/base/ /base/
-COPY ./Docker/etc/ /etc/
-COPY ./ /opt/bdsCore/
-RUN cd /opt/bdsCore/ && npm install --no-save
-ENV TELEGRAM_TOKEN="null" DESCRIPTION="running Minecraft Bedrock Server on the docker by Bds Manager" \
-WORLD_NAME="Bds Maneger Docker" GAMEMODE="survival" DIFFICULTY="normal" XBOX_ACCOUNT="false" PLAYERS="13" \
-BDS_VERSION="latest" SERVER="bedrock" BDS_REINSTALL="true" Docker_Debug_Script="false" \
-ngrok_token=""
-
-RUN mkdir -p /home/bds/.config/bds_core
+ENV \
+TELEGRAM_TOKEN="null" \
+DESCRIPTION="running Minecraft Bedrock Server on the docker by Bds Manager" \
+WORLD_NAME="Bds Maneger Docker" \
+GAMEMODE="survival" \
+DIFFICULTY="normal" \
+XBOX_ACCOUNT="false" \
+PLAYERS="13" \
+BDS_VERSION="latest" \
+SERVER="bedrock" \
+BDS_REINSTALL="true" \
+Docker_Debug_Script="false"
EXPOSE 80/tcp 19132/udp 19133/udp
ENV BDS_DOCKER_IMAGE="true" HOME="/home/bds/"
+# Copy Files
+COPY ./Docker/root_path/ /
+COPY ./ /opt/bdsCore/
+RUN cd /opt/bdsCore/ && npm install --no-save
+
+RUN mkdir -p /home/bds/.config/bds_core
+
# Entrypint
WORKDIR /home/bds/
RUN chmod +x /base/init.sh
diff --git a/Docker/etc/nginx/sites-available/default b/Docker/etc/nginx/sites-available/default
deleted file mode 100644
index 1024e58..0000000
--- a/Docker/etc/nginx/sites-available/default
+++ /dev/null
@@ -1,11 +0,0 @@
-server {
- listen [::]:80 ipv6only=on;
- listen 80;
- server_name _;
- location /log {
- proxy_pass http://localhost:6565/;
- }
- location / {
- proxy_pass http://localhost:1932;
- }
-}
\ No newline at end of file
diff --git a/Docker/base/init.sh b/Docker/root_path/base/init.sh
similarity index 100%
rename from Docker/base/init.sh
rename to Docker/root_path/base/init.sh
diff --git a/Docker/base/server_start.js b/Docker/root_path/base/server_start.js
similarity index 96%
rename from Docker/base/server_start.js
rename to Docker/root_path/base/server_start.js
index c8f0867..4a9c950 100644
--- a/Docker/base/server_start.js
+++ b/Docker/root_path/base/server_start.js
@@ -1,10 +1,9 @@
const bds = require("/opt/bdsCore/index");
-// const {bds_dir} = require("/opt/bdsCore/index");
const { existsSync, readFileSync } = require("fs")
const { resolve, join } = require("path")
// Enable APIs
-bds.api();
+bds.rest();
// Log function
function output(dados){var out = dados; if (out.slice(-1) == "\n") out = out.slice(0, -1); console.log(out)}
diff --git a/Docker/base/setup_node.js b/Docker/root_path/base/setup_node.js
similarity index 92%
rename from Docker/base/setup_node.js
rename to Docker/root_path/base/setup_node.js
index 895c180..2fb2acd 100644
--- a/Docker/base/setup_node.js
+++ b/Docker/root_path/base/setup_node.js
@@ -24,6 +24,6 @@ else if (existsSync(join(bds.bds_dir_java, "server.jar"))) bds_software = true
if (bds_software){
// ------------------------------
- /* Install version */if (process.env.BDS_REINSTALL === "true") bds.download(process.env.BDS_VERSION);/* Skipping */ else console.log("Skipping reinstallation")
+ /* Install version */if (process.env.BDS_REINSTALL === "true") bds.download("latest");/* Skipping */ else console.log("Skipping reinstallation")
// ------------------------------
} else bds.download(process.env.BDS_VERSION)
diff --git a/Docker/root_path/etc/nginx/conf.d/largerequest.conf b/Docker/root_path/etc/nginx/conf.d/largerequest.conf
new file mode 100644
index 0000000..b2db3b9
--- /dev/null
+++ b/Docker/root_path/etc/nginx/conf.d/largerequest.conf
@@ -0,0 +1 @@
+client_max_body_size 512M;
\ No newline at end of file
diff --git a/Docker/root_path/etc/nginx/sites-available/default b/Docker/root_path/etc/nginx/sites-available/default
new file mode 100644
index 0000000..3772ffe
--- /dev/null
+++ b/Docker/root_path/etc/nginx/sites-available/default
@@ -0,0 +1,20 @@
+server {
+ listen [::]:80 ipv6only=on;
+ listen 80;
+ server_name _;
+ root /html;
+ index index.html;
+ location /api/log {
+ proxy_pass http://localhost:6565/;
+ }
+ location /api {
+ proxy_pass http://localhost:1932/;
+ }
+ #
+ location /api/log/ {
+ proxy_pass http://localhost:6565/;
+ }
+ location /api/ {
+ proxy_pass http://localhost:1932/;
+ }
+}
\ No newline at end of file
diff --git a/Docker/root_path/etc/nginx/sites-enabled/default b/Docker/root_path/etc/nginx/sites-enabled/default
new file mode 120000
index 0000000..ad35b83
--- /dev/null
+++ b/Docker/root_path/etc/nginx/sites-enabled/default
@@ -0,0 +1 @@
+/etc/nginx/sites-available/default
\ No newline at end of file
diff --git a/Docker/root_path/html/README.md b/Docker/root_path/html/README.md
new file mode 100644
index 0000000..fb1e5ea
--- /dev/null
+++ b/Docker/root_path/html/README.md
@@ -0,0 +1,11 @@
+Controlling your Minecraft server straight from the web.
+
+### Attention
+
+This requires that Bds_Maneger_Api is running in a Docker pool with Image ``sirherobrine23/bdsmaneger:latest``, or your own computer with the nodejs and the API running.
+
+----
+
+This page works with the Bds Maneger APIs. do not try with any other platform will not work.
+
+Your data is also not saved, everything that is requested will be saved a ``sessionStorage`` after leaving the tab everything will be deleted.
diff --git a/Docker/root_path/html/assents/css/Minecraft.ttf b/Docker/root_path/html/assents/css/Minecraft.ttf
new file mode 100644
index 0000000..85c1472
Binary files /dev/null and b/Docker/root_path/html/assents/css/Minecraft.ttf differ
diff --git a/Docker/root_path/html/assents/css/Mojang-Bold.ttf b/Docker/root_path/html/assents/css/Mojang-Bold.ttf
new file mode 100644
index 0000000..fc71ca3
Binary files /dev/null and b/Docker/root_path/html/assents/css/Mojang-Bold.ttf differ
diff --git a/Docker/root_path/html/assents/css/Mojang-Regular.ttf b/Docker/root_path/html/assents/css/Mojang-Regular.ttf
new file mode 100644
index 0000000..da89fa7
Binary files /dev/null and b/Docker/root_path/html/assents/css/Mojang-Regular.ttf differ
diff --git a/Docker/root_path/html/assents/css/check.css b/Docker/root_path/html/assents/css/check.css
new file mode 100644
index 0000000..781cd10
--- /dev/null
+++ b/Docker/root_path/html/assents/css/check.css
@@ -0,0 +1,64 @@
+/* The switch - the box around the slider */
+.switch {
+ position: relative;
+ display: inline-block;
+ width: 33px;
+ height: 19px;
+ margin-right: 3.5px;
+ }
+
+ /* Hide default HTML checkbox */
+ .switch input {
+ opacity: 0;
+ width: 0;
+ height: 0;
+ }
+
+ /* The slider */
+ .slider {
+ position: absolute;
+ cursor: pointer;
+ top: 0;
+ left: 0;
+ right: 0;
+ bottom: 0;
+ background-color: #ccc;
+ -webkit-transition: .4s;
+ transition: .4s;
+ }
+
+ .slider:before {
+ position: absolute;
+ content: "";
+ height: 12px;
+ width: 12px;
+ left: 4px;
+ bottom: 4px;
+ background-color: white;
+ -webkit-transition: .4s;
+ transition: .4s;
+ }
+
+ input:checked + .slider {
+ background-color: #2196F3;
+ }
+
+ input:focus + .slider {
+ box-shadow: 0 0 1px #2196F3;
+ }
+
+ input:checked + .slider:before {
+ -webkit-transform: translateX(10px);
+ -ms-transform: translateX(10px);
+ transform: translateX(10px);
+ }
+
+ /* Rounded sliders */
+ .slider.round {
+ border-radius: 34px;
+ margin-left: 4px;
+ }
+
+ .slider.round:before {
+ border-radius: 50%;
+ }
\ No newline at end of file
diff --git a/Docker/root_path/html/assents/css/complete.css b/Docker/root_path/html/assents/css/complete.css
new file mode 100644
index 0000000..7929fea
--- /dev/null
+++ b/Docker/root_path/html/assents/css/complete.css
@@ -0,0 +1,11 @@
+.svg_sucess {
+ --svg-color: #1fff1f;
+}
+.svg_erro {
+ --svg-color: red;
+}
+
+.svg_color {
+ fill: var(--svg-color);
+ display: none;
+}
\ No newline at end of file
diff --git a/Docker/root_path/html/assents/css/main.css b/Docker/root_path/html/assents/css/main.css
new file mode 100644
index 0000000..0fe658e
--- /dev/null
+++ b/Docker/root_path/html/assents/css/main.css
@@ -0,0 +1,253 @@
+@font-face {
+ font-family: minecraft;
+ src: url(Minecraft.ttf);
+}
+@font-face {
+ font-family: minecraft-bold;
+ src: url(Mojang-Bold.ttf);
+}
+@font-face {
+ font-family: minecraft-regular;
+ src: url(Mojang-Regular.ttf);
+}
+
+*{
+ font-family: "minecraft", "minecraft-bold", "minecraft-regular";
+ color: var(--text-primary)
+}
+
+.Log_div_Title {
+ text-align: center;
+ font-size: 4vh;
+ margin-bottom: 1.5vh;
+}
+
+.bds_log{
+ color: var(--text-secondary);
+ background-color: var(--bg-secondary);
+ font-family: minecraft;
+ font-size: 2.4vh !important;
+ border-radius: 2px;
+ min-width: 100%;
+ min-height: 100%;
+}
+
+/* .bds_log{
+ line-height: 4.5vh;
+} */
+
+fieldset{
+ border-radius: 5px;
+ min-height: 100%;
+ min-width: 90%;
+}
+
+input{
+ color: var(--text-primary);
+ background-color: var(--bg-secondary);
+ font-size: 2.4vh;
+}
+
+input[type="text"], input[type="number"], input[type="file"]{
+ min-width: 90%;
+ max-width: 1%;
+}
+
+.bds_aiptoken{
+ border-radius: 12px;
+ margin-left: 6px;
+ height: 18px;
+ text-align: center;
+ width: 10rem;
+}
+
+select{
+ color: var(--text-primary);
+ background-color: var(--bg-secondary)
+}
+button{
+ color: var(--text-primary);
+ background-color: var(--bg-secondary)
+}
+label,div{
+ color: var(--text-primary);
+}
+
+div,html{
+ background-color: var(--bg-primary);
+}
+
+:root {
+ /* font-size: 16px; */
+ color: var(--text-primary);
+ --transition-speed: 600ms;
+}
+
+.command_area {
+ height: 100%;
+ width: 80%;
+}
+
+.command_send {
+ height: 100%;
+ font-size: 2.4vh;
+ margin-left: 1vh;
+}
+
+.root{
+ align-content: center;
+ display: flex;
+ justify-content: center;
+ margin-right: -1.3vh;
+}
+
+.buttons {
+ align-items: center;
+ display: flex;
+ flex-direction: row;
+ flex-wrap: wrap;
+ justify-content: center;
+}
+
+.bds_service {
+ margin-top: 12px;
+ width: 10rem;
+ height: 90%;
+ border-color: var(--bg-secondary);
+ background-color: var(--bg-secondary);
+ text-align: center;
+ border-radius: 12rem;
+ cursor: pointer;
+}
+.space {
+ width: 10px;
+}
+
+body {
+ color: var(--text-primary);
+ background-color: var(--bg-primary);
+ margin-right: 1rem;
+ /* margin-left: 0.5rem; */
+ padding: 0;
+}
+
+
+
+@media only screen and (min-height: 1000px) {
+ .bds_log {
+ height: 10rem;
+ }
+}
+
+*::-webkit-scrollbar {
+width: 0.45rem;
+}
+*::-webkit-scrollbar-track {
+background: var(--bg-secondary);
+}
+
+*::-webkit-scrollbar-thumb {
+ background: var(--text-primary);
+}
+
+.dark {
+ --text-primary: #b6b6b6;
+ --text-secondary: #ececec;
+ --bg-primary: #23232e;
+ --bg-secondary: #141418;
+ --box-primary: rgba(0,0,0,0.4);
+ --border-color: rgba(255, 255, 255, 0.5);
+}
+
+.light {
+ --text-primary: #1f1f1f;
+ --text-secondary: #000000;
+ --bg-primary: #ffffff;
+ --bg-secondary: #e4e4e4;
+ --box-primary: rgba(0,0,0,0.4);
+ --border-color: rgba(0,0,0,0.5);
+}
+
+.system{
+ --text-primary: #fff;
+ --text-secondary: #fff;
+ --bg-primary: #1d1d1d;
+ --bg-secondary: #3e3e3e;
+ --box-primary: rgba(0,0,0,0.4);
+ --border-color: rgba(0,0,0,0.5);
+}
+
+.loading {
+ z-index: 1;
+ font-size: 3rem !important;
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+ text-align: center;
+ min-height: 100vh;
+ /* ------------------------------------------------------- */
+ position: fixed; /* Stay in place */
+ z-index: 1; /* Sit on top */
+ padding-top: 10px; /* Location of the box */
+ left: 0;
+ top: 0;
+ width: 100%; /* Full width */
+ height: 100%; /* Full height */
+ overflow: auto; /* Enable scroll if needed */
+ display: none;
+ cursor: progress;
+}
+
+@media only screen and (max-width: 970px) {
+ .config_space {
+ margin-top: 15px;
+ display: block !important;
+ }
+}
+.config_space {
+ display: none;
+ background-color: var(--bg-secondary);
+}
+.config {
+ z-index: 1;
+ left: 0;
+ top: 0;
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+ position: fixed;
+ padding-top: 10px;
+ width: 100%;
+ height: 100%;
+ overflow: auto;
+ background: rgba(124, 124, 124, 0.635);
+ display: none;
+}
+.config_conatainer {
+ border-radius: 0.5rem;
+ width: 90%;
+ height: 90%;
+ margin-left: 5%;
+ margin-right: 10;
+ margin-top: 1%;
+ background-color: var(--bg-secondary);
+}
+.config_root {
+ background: var(--bg-secondary);
+ background-color: var(--bg-secondary);
+ padding-left: 1vh;
+ padding-right: 4vh;
+ padding-top: 4vh;
+}
+.close {
+ float: right;
+ background-color: var(--bg-secondary);
+ color: var(--text-secondary);
+ margin-right: 12px;
+ margin-left: 12px;
+ margin-top: 12px;
+ border-radius: 1rem;
+ cursor: pointer;
+}
\ No newline at end of file
diff --git a/Docker/root_path/html/assents/image/cancelar.svg b/Docker/root_path/html/assents/image/cancelar.svg
new file mode 100644
index 0000000..1aee3ee
--- /dev/null
+++ b/Docker/root_path/html/assents/image/cancelar.svg
@@ -0,0 +1,3 @@
+
\ No newline at end of file
diff --git a/Docker/root_path/html/assents/image/confirm.svg b/Docker/root_path/html/assents/image/confirm.svg
new file mode 100644
index 0000000..bfd2d71
--- /dev/null
+++ b/Docker/root_path/html/assents/image/confirm.svg
@@ -0,0 +1,3 @@
+
\ No newline at end of file
diff --git a/Docker/root_path/html/assents/image/favicon.ico b/Docker/root_path/html/assents/image/favicon.ico
new file mode 100644
index 0000000..fca8e91
Binary files /dev/null and b/Docker/root_path/html/assents/image/favicon.ico differ
diff --git a/Docker/root_path/html/assents/image/google-drive-svgrepo-com.svg b/Docker/root_path/html/assents/image/google-drive-svgrepo-com.svg
new file mode 100644
index 0000000..4662799
--- /dev/null
+++ b/Docker/root_path/html/assents/image/google-drive-svgrepo-com.svg
@@ -0,0 +1,40 @@
+
+
+
+
diff --git a/Docker/root_path/html/assents/image/settings-24px.svg b/Docker/root_path/html/assents/image/settings-24px.svg
new file mode 100644
index 0000000..e40c849
--- /dev/null
+++ b/Docker/root_path/html/assents/image/settings-24px.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/Docker/root_path/html/assents/image/shopping_cart-24px.svg b/Docker/root_path/html/assents/image/shopping_cart-24px.svg
new file mode 100644
index 0000000..81e8dcd
--- /dev/null
+++ b/Docker/root_path/html/assents/image/shopping_cart-24px.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/Docker/root_path/html/assents/image/text_snippet-24px.svg b/Docker/root_path/html/assents/image/text_snippet-24px.svg
new file mode 100644
index 0000000..8de5950
--- /dev/null
+++ b/Docker/root_path/html/assents/image/text_snippet-24px.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/Docker/root_path/html/assents/image/trip_origin-24px.svg b/Docker/root_path/html/assents/image/trip_origin-24px.svg
new file mode 100644
index 0000000..561f848
--- /dev/null
+++ b/Docker/root_path/html/assents/image/trip_origin-24px.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/Docker/root_path/html/assents/js/modal.js b/Docker/root_path/html/assents/js/modal.js
new file mode 100644
index 0000000..4b26ef8
--- /dev/null
+++ b/Docker/root_path/html/assents/js/modal.js
@@ -0,0 +1,14 @@
+// Info Box
+document.getElementById("InfoB").onclick = function() {document.getElementById("Info").style.display = "block";}
+document.getElementsByClassName("infoclose")[0].onclick = function() {document.getElementById("Info").style.display = "none";}
+window.onclick = function(event) {if (event.target == document.getElementById("Info")) {document.getElementById("Info").style.display = "none";}}
+
+// Config Modal
+document.getElementById("configbuttom").onclick = function() {document.getElementById("configmodal").style.display = "block";}
+ document.getElementsByClassName("closeConfig")[0].onclick = function() {document.getElementById("configmodal").style.display = "none"}
+ window.onclick = function(event) {if (event.target == document.getElementById("configmodal")) {document.getElementById("configmodal").style.display = "none"}
+}
+// Give Item
+// document.getElementById("giveMENU").onclick = function() {document.getElementById("GIVEM").style.display = "block"}
+// document.getElementsByClassName("closeG")[0].onclick = function() {document.getElementById("GIVEM").style.display = "none"}
+// window.onclick = function(event) {if (event.target == document.getElementById("GIVEM")) {document.getElementById("GIVEM").style.display = "none"}}
diff --git a/Docker/root_path/html/assents/js/setting_server.js b/Docker/root_path/html/assents/js/setting_server.js
new file mode 100644
index 0000000..f3e6c2e
--- /dev/null
+++ b/Docker/root_path/html/assents/js/setting_server.js
@@ -0,0 +1,16 @@
+fetch(`http://${localStorage.getItem("bds_ip-remote")}:1932/configs`).then(response => response.json()).then(CONFIGS => {
+ document.getElementById('name') .value = CONFIGS.server_name;
+ document.getElementById('gameMode') .value = CONFIGS.gamemode;
+ document.getElementById('difficulty') .value = CONFIGS.difficulty;
+ document.getElementById('timeout_server').value = CONFIGS.player_idle_timeout;
+ document.getElementById('level_name') .value = CONFIGS.level_name;
+ document.getElementById('permissions') .value = CONFIGS.default_player_permission_level;
+ document.getElementById('max_pla') .value = CONFIGS.max_players
+
+ // cheats
+ if (CONFIGS.allow_cheats == 'true'){document.getElementById('cheats').checked = true} else {document.getElementById('cheats').checked = false};
+ // online mode
+ if (CONFIGS.online_mode == 'true'){document.getElementById('xbox').checked = true} else {document.getElementById('xbox').checked = false};
+ // cheats
+ if (CONFIGS.white_list == 'true'){document.getElementById('whitelist').checked = true} else {document.getElementById('whitelist').checked = false};
+})
\ No newline at end of file
diff --git a/Docker/root_path/html/index.html b/Docker/root_path/html/index.html
new file mode 100644
index 0000000..c6e88a9
--- /dev/null
+++ b/Docker/root_path/html/index.html
@@ -0,0 +1,118 @@
+
+
+
+
+
+
+
+ Bds Maneger Web
+
+
+
+
+
+
+
+
+
+
+ Bds Maneger Log
+
+
+
+
+
+
+
+
+
+
+
+
+
Wait .
+
Wait ..
+
Wait ...
+
+
\ No newline at end of file
diff --git a/Docker/root_path/html/web_main.js b/Docker/root_path/html/web_main.js
new file mode 100644
index 0000000..cc1f38f
--- /dev/null
+++ b/Docker/root_path/html/web_main.js
@@ -0,0 +1,89 @@
+console.info("Welcome to Bds Maneger Web 2.0")
+const token = (localStorage.getItem("the_token") || undefined)
+document.getElementById("bds_token").value = token
+function basic_service (service){
+ fetch("/api/service",{
+ method: "POST",
+ mode: "cors",
+ body: JSON.stringify({
+ "token": token,
+ "command": service
+ }),
+ headers: {
+ "Accept": "application/json",
+ "Content-Type": "application/json"
+ }
+ }).then(response => response.json()).then(lan => {
+ console.log(lan)
+ })
+}
+function bds_start(){return basic_service("start")}
+
+function bds_stop (){basic_service("stop")}
+
+// eslint-disable-next-line no-unused-vars
+function bds_restart(){
+ let log = document.getElementById("bds_log").innerHTML
+ console.log("restart request")
+ if (!(log.includes("Quit correctly"))) bds_stop()
+ bds_start()
+}
+
+// eslint-disable-next-line no-unused-vars
+function bds_command(){
+ fetch("/api/bds_command", {
+ method: "POST",
+ mode: "cors",
+ body: JSON.stringify({
+ "token": token,
+ "command": document.getElementById("command").value
+ }),
+ headers: {
+ "Accept": "application/json",
+ "Content-Type": "application/json"
+ }
+ }
+ ).then(response => response.json()).then(lan => {
+ console.log(lan);
+ })
+}
+
+// eslint-disable-next-line no-unused-vars
+function UploadWorld(){
+ const input = document.getElementById("WorldUpload").files
+ const formData = new FormData();
+ console.log(input);
+ formData.append(input[0].name, input[0]);
+ for(var pair of formData.entries()) {
+ console.log(pair[0]+ ", "+ JSON.stringify(pair[1]));
+ }
+ fetch("/api/upload_world", {
+ method: "POST",
+ headers: {
+ "Content-Type": "multipart/form-data",
+ "token": token
+ },
+ body: input[0]
+ }).catch(
+ err => {
+ throw Error(err)
+ }
+ )
+}
+
+const logInterval = setInterval(() => {
+ fetch("/api/log?format=html").then(response => response.text()).then(lan => {
+ document.getElementById("bds_log").innerHTML = lan
+ }).catch (function (err){
+ if (confirm("The server crashed or had an error, wants to reload the page")) location.reload(true)
+ else clearInterval(logInterval)
+ throw Error(err)
+ });
+}, 2 * 1000);
+
+// eslint-disable-next-line no-unused-vars
+function settings_display(){
+ const se_display = document.getElementById("config").style.display
+ if (se_display === "block") document.getElementById("config").style.display = "none"
+ else document.getElementById("config").style.display = "block"
+}
diff --git a/README.md b/README.md
index a95cf51..789b193 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,13 @@ For now we are in a version qualified for general use and implementations in com
## CI/CD status
-[![CodeQL](https://github.com/Bds-Maneger/bds_maneger_api/workflows/CodeQL/badge.svg)](https://github.com/The-Bds-Maneger/core/actions/workflows/codeql-analysis.yml) [![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) [![Codacy Badge](https://app.codacy.com/project/badge/Grade/4d19af8fe5b146608a8f4a5e2092f66d)](https://www.codacy.com/gh/Bds-Maneger/bds_maneger_api/dashboard?utm_source=github.com&utm_medium=referral&utm_content=Bds-Maneger/bds_maneger_api&utm_campaign=Badge_Grade)
+[![CodeQL](https://github.com/Bds-Maneger/bds_maneger_api/workflows/CodeQL/badge.svg)](https://github.com/The-Bds-Maneger/core/actions/workflows/codeql-analysis.yml) [![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) [![Codacy Badge](https://app.codacy.com/project/badge/Grade/4d19af8fe5b146608a8f4a5e2092f66d)](https://www.codacy.com/gh/Bds-Maneger/bds_maneger_api/dashboard?utm_source=github.com&utm_medium=referral&utm_content=Bds-Maneger/bds_maneger_api&utm_campaign=Badge_Grade)
+
+## Common Mistakes
+
+* On Windows if you are receiving any error from platform-tools, follow these [steps](https://github.com/nodejs/node-gyp#on-windows) and install [python](https://www.python.org/downloads/).
+
+* If you are using Branch main, there may be several errors and corrections may take time to arrive, I recommend using the Tags.
## Start the Bds Maneger Core docker server
@@ -29,12 +35,12 @@ bdsmaneger/maneger:latest
## Azure Deploys
-**Recommended to use a new resource group**
+### *Recommended to use a new resource group*
-### Microsoft Azure Container
+#### Microsoft Azure Container
[![Deploy to Azure](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FBds-Maneger%2FThe-Bds-Maneger-Docker%2Fmain%2Fazure%2FBdsMangerCore_docker.json)
-### Microsoft Azure Virtual machine
+#### Microsoft Azure Virtual machine
[![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) More Information Access the repository: [Azure VMs](https://github.com/The-Bds-Maneger/Azure_VMs)
diff --git a/bin/bds_maneger.js b/bin/bds_maneger.js
index 2f8271e..05519c9 100755
--- a/bin/bds_maneger.js
+++ b/bin/bds_maneger.js
@@ -54,7 +54,7 @@ if (!(existsSync(server_exec))) {
if (bds_version){
try {
process.env.BDS_DOCKER_IMAGE = true
- bds.download(bds_version)
+ bds.download(bds_version, true)
} catch (error) {
console.error(error)
process.exit(165)
diff --git a/curlCheck.js b/curlCheck.js
new file mode 100644
index 0000000..647fcfa
--- /dev/null
+++ b/curlCheck.js
@@ -0,0 +1,46 @@
+const { existsSync, mkdirSync, writeFileSync, chmodSync } = require("fs")
+const { resolve, join } = require("path")
+const binFolder = resolve((process.env.USERPROFILE||process.env.HOME), "bds_core", "bin")
+
+if (typeof fetch === "undefined") {global.fetch = require("node-fetch")}
+(function (){
+ if (require("command-exists").sync("curl")) {console.log("Curl is already installed.");process.exit(0)}
+ else {
+ if (!(existsSync(binFolder))) mkdirSync(binFolder)
+ if (process.platform === "linux"){
+ fetch("https://api.github.com/repos/moparisthebest/static-curl/releases").then(response => response.json()).then(function (res){
+ var arch = process.arch
+ if (arch === "x64") arch = "amd64"
+ let url = `https://github.com/moparisthebest/static-curl/releases/download/${res[0].tag_name}/curl-${arch}`
+ console.log(url);
+ fetch(url).then(response => response.arrayBuffer()).then(response => Buffer.from(response)).then(response => {
+ writeFileSync(join(binFolder, "curl"), response, "binary")
+ chmodSync(join(binFolder, "curl"), 7777)
+ process.exit(0)
+ }).catch(function (err){if (err) {console.log(err);process.exit(1)}})
+ })
+ } else if (process.platform === "darwin") throw Error("You will have to install cURL manually, download page: https://curl.se/download.html");
+ else if (process.platform === "win32") {
+ // Version major.minor
+ // ------------------------------------------ -------------
+ // Windows 10, Windows Server 2016 10.0
+ // Windows 8.1, Windows Server 2012 R2 6.3
+ // Windows 8, Windows Server 2012 6.2
+ // Windows 7, Windows Server 2008 R2 6.1
+ // Windows Vista, Windows Server 2008 6.0
+ // Windows XP Professional x64 Edition, 5.2
+ // Windows Server 2003, Windows Home Server
+ // Windows XP 5.1
+ // Windows 2000 5.0
+ var WindowsVersion = require("os").release()
+ if (WindowsVersion.includes("10.0")) WindowsVersion = 10
+ else if (WindowsVersion.includes("6.3")) WindowsVersion = 8.1
+ else if (WindowsVersion.includes("6.2")) WindowsVersion = 8
+ else if (WindowsVersion.includes("6.1")) WindowsVersion = 7
+ else WindowsVersion = "unsupported"
+
+ if (WindowsVersion === 10) throw Error("Please make sure you are on the latest version of Windows 10");
+ else throw Error(`Please manually install curl for Windows ${WindowsVersion}, download page: https://curl.se/download.html`)
+ } else throw Error("Please install curl manually, download page: https://curl.se/download.html")
+ }
+})()
\ No newline at end of file
diff --git a/docker_build_image.sh b/docker_build_image.sh
deleted file mode 100644
index 0ff683b..0000000
--- a/docker_build_image.sh
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/bash
-docker_image_name='thebdsmaneger/maneger'
-docker build -f Docker/Dockerfile --tag ${docker_image_name} . && \
-echo "Run: \"docker run -ti --rm -P -v /tmp/bds:/home/bds ${1} ${docker_image_name}\""
\ No newline at end of file
diff --git a/index.js b/index.js
index 98a2eec..5cb56e9 100644
--- a/index.js
+++ b/index.js
@@ -5,6 +5,7 @@ const { resolve } = require("path");
const { error } = console;
const shell = require("shelljs");
const {getDesktopFolder, getConfigHome} = require("platform-folders")
+const { execSync } = require("child_process");
const bds_core_package = resolve(__dirname, "package.json")
const bds_maneger_version = require(bds_core_package).version
@@ -40,9 +41,10 @@ module.exports.package_path = bds_core_package
if (process.platform == "win32") {
home = process.env.USERPROFILE;
tmp = process.env.TMP
- system = "windows";
+ system = "Windows";
valid_platform = {
"bedrock": true,
+ "pocketmine": true,
"java": true
}
} else if (process.platform == "linux") {
@@ -50,19 +52,22 @@ if (process.platform == "win32") {
if (process.env.BDS_DOCKER_IMAGE) desktop = "/home/bds/"
else desktop = "/tmp"
tmp = "/tmp";
- system = "linux";
+ system = "Linux";
valid_platform = {
"bedrock": true,
+ "pocketmine": true,
"java": true
}
+ if (process.arch === "aarch64") valid_platform.pocketmine = false;
} else if (process.platform == "darwin") {
if (arch === "arm64") require("open")("https://github.com/The-Bds-Maneger/core/wiki/system_support#information-for-users-of-macbooks-and-imacs-with-m1-processor")
else require("open")("https://github.com/The-Bds-Maneger/core/wiki/system_support#macos-with-intel-processors");
home = process.env.HOME;
tmp = "/tmp";
- system = "macOS";
+ system = "MacOS";
valid_platform = {
"bedrock": false,
+ "pocketmine": true,
"java": true
}
} else {
@@ -165,6 +170,15 @@ if (!(fs.existsSync(bds_dir_bedrock))){
}
module.exports.bds_dir_bedrock = bds_dir_bedrock
+/* PocketMine Path */
+const bds_dir_pocketmine = path.join(bds_dir, "pocketmine");
+if (!(fs.existsSync(bds_dir_pocketmine))){
+ console.log("Creating the bds directory to Pocketmine")
+ fs.mkdirSync(bds_dir_pocketmine)
+ if (!(fs.existsSync(bds_dir_pocketmine))) shell.mkdir("-p", bds_dir_pocketmine);
+}
+module.exports.bds_dir_pocketmine = bds_dir_pocketmine
+
// Create backup folder
if (!(fs.existsSync(bds_dir_backup))){
fs.mkdirSync(bds_dir_backup)
@@ -192,39 +206,43 @@ if (!(fs.existsSync(log_dir))){
if (typeof fetch === "undefined") global.fetch = require("node-fetch");
if (typeof localStorage === "undefined") global.localStorage = new require("node-localstorage").LocalStorage(path.join(LocalStorageFolder, "Local_Storage"));
+/* Minecraft Servers URLs and depedencies */
+// urls
+const SERVER_URLs = JSON.parse(execSync("curl -sS \"https://raw.githubusercontent.com/Bds-Maneger/Raw_files/main/Server.json\"").toString())
+module.exports.SERVER_URLs = SERVER_URLs
+
+// PHP Bins
+const PHPbinsUrl = JSON.parse(execSync("curl -sS \"https://raw.githubusercontent.com/The-Bds-Maneger/Raw_files/main/php_bin.json\"").toString())
+module.exports.PHPbinsUrls = PHPbinsUrl
+
+// PHP bins System availble in Json File
+const PHPurlNames = Object.getOwnPropertyNames(PHPbinsUrl)
+module.exports.PHPurlNames = PHPurlNames
+
/* ---------------------------------------------------------------------------- Variables ---------------------------------------------------------------------------- */
// Configs
var bds_config, bds_config_file = path.join(bds_dir, "bds_config.json");
const current_version_bds_core = bds_maneger_version
-var default_porcess;
-if (process.platform.includes("win32", "linux")) default_porcess = "bedrock"
-else default_porcess = "java"
+var default_platformConfig;
+if (process.platform.includes("win32", "linux")) default_platformConfig = "bedrock"
+else default_platformConfig = "java"
if (fs.existsSync(bds_config_file)){
bds_config = JSON.parse(fs.readFileSync(bds_config_file, "utf8"))
if (bds_config.version !== current_version_bds_core){
- let ram_total = Math.trunc((require("os").freemem() / 1000 / 1000) - 212)
- if (ram_total >= 1000) ram_total = ram_total - 1000
+
if (bds_config.platform_version === undefined) bds_config.platform_version = {}
- if (bds_config.bedrock_config === undefined) bds_config.bedrock_config = {}
+ // New Config JSon
bds_config = {
"version": current_version_bds_core,
"bds_pages": (bds_config.bds_pages||"default"),
- "bds_platform": (bds_config.bds_platform||default_porcess),
+ "bds_platform": (bds_config.bds_platform||default_platformConfig),
"platform_version": {
"bedrock": (bds_config.platform_version.bedrock||"latest"),
"java": (bds_config.platform_version.java||"latest")
},
"bds_ban": (bds_config.bds_ban||["Steve", "Alex", "steve", "alex"]),
"telegram_token": (bds_config.telegram_token||undefined),
- "Google_Drive_root_backup_id": (bds_config.Google_Drive_root_backup_id||undefined),
- "telegram_admin": (bds_config.telegram_admin||["all_users"]),
- "java_config": {
- "max": ram_total
- },
- "bedrock_config": {
- "from": (bds_config.bedrock_config.from||"oficial"), // Use the official version provided by Mojang Studios AB
- "url": (bds_config.bedrock_config.from||null) // JSON Array file with versions and download url
- }
+ "Google_Drive_root_backup_id": (bds_config.Google_Drive_root_backup_id||undefined)
}
fs.writeFileSync(bds_config_file, JSON.stringify(bds_config, null, 4))
bds_config_export()
@@ -235,7 +253,7 @@ if (fs.existsSync(bds_config_file)){
bds_config = {
"version": current_version_bds_core,
"bds_pages": "default",
- "bds_platform": default_porcess,
+ "bds_platform": default_platformConfig,
"platform_version": {
"bedrock": "latest",
"java": "latest"
@@ -245,15 +263,7 @@ if (fs.existsSync(bds_config_file)){
"Google_Drive_root_backup_id": undefined,
"telegram_admin": [
"all_users"
- ],
- "java_config": {
- "max": ram_total
- },
- // bedrock_config is not yet in use
- "bedrock_config": {
- "from": "oficial", // Bedrock Server software, such as the one provided by Mojang, lifeboat, pocketmine-mp. more information: https://github.com/The-Bds-Maneger/core/wiki/bedrock_software#minecraft-bedrock-servers
- "url": undefined // JSON Array file with versions and download url
- }
+ ]
}
fs.writeFileSync(bds_config_file, JSON.stringify(bds_config, null, 4))
}
@@ -264,6 +274,11 @@ module.exports.platform_version_update = function (version){
fs.writeFileSync(bds_config_file, JSON.stringify(bds_config, null, 4))
bds_config_export()
}
+
+
+/**
+ * Save ID Google Drive folder to Backups
+ */
module.exports.save_google_id = function (id){
let bds_config = JSON.parse(fs.readFileSync(bds_config_file, "utf8"))
bds_config.Google_Drive_root_backup_id = id
@@ -272,39 +287,12 @@ module.exports.save_google_id = function (id){
return true
}
module.exports.platform = bds_config.bds_platform
-function update_java_memory(total){
- if (total.includes("GB")) total = (total = Math.trunc(total / 1024))
- else if (total.includes("GIB")) total = (total = Math.trunc(total / 1000))
- else if (total.includes("gb")) total = (total = Math.trunc(total / 1024))
- else if (total.includes("gib")) total = (total = Math.trunc(total / 1000))
- else if (total.includes("MB")) total = (total = Math.trunc(total))
- else if (total.includes("mb")) total = (total = Math.trunc(total))
- else if (total.includes("mib")) total = (total = Math.trunc(total))
- else if (total.includes("MIB")) total = (total = Math.trunc(total))
- else throw new Error("Please enter a valid value such as: 1GB, 1gb, 1024mb ,1024MB, 1000MIB, 10000mib ,1GIB ,1gib")
- if (bds_config.bds_platform === "java"){
- bds_config.java_config.max =
- fs.writeFileSync(bds_config_file, JSON.stringify(bds_config, null, 4))
- }
-}
-
-const log_file = path.join(log_dir, `${date()}_${bds_config.bds_platform}_Bds_log.log`);
-module.exports.log_file = log_file
/**
- * Update the value of how much java will use ram when the java platform is selected
- *
- * the following values are: 1024mb, 1024MB, 1000MIB, 1000mib, 1GB, 1gb, 1GIB, 1gib
+ * Bds Maneger Latest log file.
*/
-module.exports.memory_for_the_java = update_java_memory
-
-if (process.env.AUTOUPDATE_JAVA_RAM !== undefined||undefined){
- setInterval(() => {
- let ram_total = Math.trunc((require("os").freemem() / 1000 / 1000) - 212)
- if (ram_total >= 1000) ram_total = ram_total - 1000
- update_java_memory(ram_total+"mb")
- }, 2500);
-}
+const log_file = path.join(log_dir, `${date()}_${bds_config.bds_platform}_Bds_log.log`);
+module.exports.log_file = log_file
function bds_config_export (){
/**
@@ -376,7 +364,7 @@ if (require("fs").existsSync(path.join(bds_dir, "telegram_token.txt"))){
throw new error("It was not possible to move the old telegram token file to the new bds maneger api file")
}
}
-const getSize = require("get-folder-size")
+const getSize = require("get-folder-size");
getSize(bds_dir_backup, function(err, info) {
if (err) throw err
function toGB(x) {return (x / (1024 * 1024 * 1024)).toFixed(1);}
diff --git a/package-lock.json b/package-lock.json
index 320bded..2c90ae1 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,13 @@
{
"name": "@the-bds-maneger/core",
- "version": "1.8.5.5",
+ "version": "1.8.6.6",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@the-bds-maneger/core",
- "version": "1.8.5.5",
+ "version": "1.8.6.6",
+ "hasInstallScript": true,
"license": "AGPL-3.0-or-later",
"dependencies": {
"adm-zip": "^0.5.1",
@@ -15,6 +16,7 @@
"cors": "^2.8.5",
"crypto": "^1.0.1",
"express": "^4.17.1",
+ "express-fileupload": "^1.2.1",
"express-rate-limit": "^5.2.3",
"get-folder-size": "^2.0.1",
"googleapis": "^71.0.0",
@@ -482,6 +484,17 @@
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz",
"integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A=="
},
+ "node_modules/busboy": {
+ "version": "0.3.1",
+ "resolved": "https://registry.npmjs.org/busboy/-/busboy-0.3.1.tgz",
+ "integrity": "sha512-y7tTxhGKXcyBxRKAni+awqx8uqaJKrSFSNFSeRG5CsWNdmy2BIK+6VGWEW7TZnIO/533mtMEA4rOevQV815YJw==",
+ "dependencies": {
+ "dicer": "0.3.0"
+ },
+ "engines": {
+ "node": ">=4.5.0"
+ }
+ },
"node_modules/bytes": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz",
@@ -726,6 +739,17 @@
"resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz",
"integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA="
},
+ "node_modules/dicer": {
+ "version": "0.3.0",
+ "resolved": "https://registry.npmjs.org/dicer/-/dicer-0.3.0.tgz",
+ "integrity": "sha512-MdceRRWqltEG2dZqO769g27N/3PXfcKl04VhYnBlo2YhH7zPi88VebsjTKclaOyiuMaGU72hTfw3VkUitGcVCA==",
+ "dependencies": {
+ "streamsearch": "0.1.2"
+ },
+ "engines": {
+ "node": ">=4.5.0"
+ }
+ },
"node_modules/dijkstrajs": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/dijkstrajs/-/dijkstrajs-1.0.1.tgz",
@@ -1071,6 +1095,17 @@
"node": ">= 0.10.0"
}
},
+ "node_modules/express-fileupload": {
+ "version": "1.2.1",
+ "resolved": "https://registry.npmjs.org/express-fileupload/-/express-fileupload-1.2.1.tgz",
+ "integrity": "sha512-fWPNAkBj+Azt9Itmcz/Reqdg3LeBfaXptDEev2JM8bCC0yDptglCnlizhf0YZauyU5X/g6v7v4Xxqhg8tmEfEA==",
+ "dependencies": {
+ "busboy": "^0.3.1"
+ },
+ "engines": {
+ "node": ">=8.0.0"
+ }
+ },
"node_modules/express-rate-limit": {
"version": "5.2.6",
"resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-5.2.6.tgz",
@@ -2492,6 +2527,14 @@
"node": ">= 0.6"
}
},
+ "node_modules/streamsearch": {
+ "version": "0.1.2",
+ "resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-0.1.2.tgz",
+ "integrity": "sha1-gIudDlb8Jz2Am6VzOOkpkZoanxo=",
+ "engines": {
+ "node": ">=0.8.0"
+ }
+ },
"node_modules/string-width": {
"version": "4.2.2",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.2.tgz",
@@ -3302,6 +3345,14 @@
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz",
"integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A=="
},
+ "busboy": {
+ "version": "0.3.1",
+ "resolved": "https://registry.npmjs.org/busboy/-/busboy-0.3.1.tgz",
+ "integrity": "sha512-y7tTxhGKXcyBxRKAni+awqx8uqaJKrSFSNFSeRG5CsWNdmy2BIK+6VGWEW7TZnIO/533mtMEA4rOevQV815YJw==",
+ "requires": {
+ "dicer": "0.3.0"
+ }
+ },
"bytes": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz",
@@ -3490,6 +3541,14 @@
"resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz",
"integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA="
},
+ "dicer": {
+ "version": "0.3.0",
+ "resolved": "https://registry.npmjs.org/dicer/-/dicer-0.3.0.tgz",
+ "integrity": "sha512-MdceRRWqltEG2dZqO769g27N/3PXfcKl04VhYnBlo2YhH7zPi88VebsjTKclaOyiuMaGU72hTfw3VkUitGcVCA==",
+ "requires": {
+ "streamsearch": "0.1.2"
+ }
+ },
"dijkstrajs": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/dijkstrajs/-/dijkstrajs-1.0.1.tgz",
@@ -3761,6 +3820,14 @@
"vary": "~1.1.2"
}
},
+ "express-fileupload": {
+ "version": "1.2.1",
+ "resolved": "https://registry.npmjs.org/express-fileupload/-/express-fileupload-1.2.1.tgz",
+ "integrity": "sha512-fWPNAkBj+Azt9Itmcz/Reqdg3LeBfaXptDEev2JM8bCC0yDptglCnlizhf0YZauyU5X/g6v7v4Xxqhg8tmEfEA==",
+ "requires": {
+ "busboy": "^0.3.1"
+ }
+ },
"express-rate-limit": {
"version": "5.2.6",
"resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-5.2.6.tgz",
@@ -4815,6 +4882,11 @@
"resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz",
"integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow="
},
+ "streamsearch": {
+ "version": "0.1.2",
+ "resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-0.1.2.tgz",
+ "integrity": "sha1-gIudDlb8Jz2Am6VzOOkpkZoanxo="
+ },
"string-width": {
"version": "4.2.2",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.2.tgz",
diff --git a/package.json b/package.json
index 9546092..95c6167 100644
--- a/package.json
+++ b/package.json
@@ -3,16 +3,17 @@
"publishConfig": {
"access": "public"
},
- "version": "1.8.5.5",
+ "version": "1.8.6.6",
"description": "scripts to manage minecraft bedrock server",
"private": false,
"main": "index.js",
"scripts": {
- "test": "",
+ "test": "exit 0",
"eslint": "eslint .",
"eslint:fix": "eslint --fix .",
"start": "node bin/bds_maneger.js",
- "debug": "node bin/debug.js"
+ "debug": "node bin/debug.js",
+ "postinstall": "node curlCheck.js"
},
"bin": {
"bds_maneger": "./bin/bds_maneger.js"
@@ -49,6 +50,7 @@
"cors": "^2.8.5",
"crypto": "^1.0.1",
"express": "^4.17.1",
+ "express-fileupload": "^1.2.1",
"express-rate-limit": "^5.2.3",
"get-folder-size": "^2.0.1",
"googleapis": "^71.0.0",
diff --git a/rest/api.js b/rest/api.js
index 7e2af6c..9aec441 100644
--- a/rest/api.js
+++ b/rest/api.js
@@ -6,17 +6,21 @@ var cors = require("cors");
const rateLimit = require("express-rate-limit");
const token_verify = require("./token_api_check")
const bodyParser = require("body-parser");
+const fileUpload = require("express-fileupload");
function api(port_api){
const app = express();
- // Enable if you're behind a reverse proxy (Heroku, Bluemix, AWS ELB, Nginx, etc)
+ // Enable if you"re behind a reverse proxy (Heroku, Bluemix, AWS ELB, Nginx, etc)
// see https://expressjs.com/en/guide/behind-proxies.html
- // app.set('trust proxy', 1);
+ // app.set("trust proxy", 1);
const limiter = rateLimit({
windowMs: 15 * 60 * 1000, // 15 minutes
max: 100 // limit each IP to 100 requests per windowMs
});
+ app.use(fileUpload({
+ limits: { fileSize: 512 * 1024 }
+ }));
app.use(cors());
app.use(bodyParser.json()); /* https://github.com/github/fetch/issues/323#issuecomment-331477498 */
app.use(bodyParser.urlencoded({ extended: true }));
@@ -24,13 +28,6 @@ function api(port_api){
// app.get("/configs", (req, res) => {return res.send(bds.get_config());});
app.get("/info", (req, res) => {
const config = bds.get_config()
- var java;
- if (bds.platform === "bedrock") java = {}
- else java = {
- java: {
- "max_ram_memory": bds.bds_config.java_config.max
- }
- }
var json_http = {
"server": {
"bds_config_version": bds.bds_config.version,
@@ -40,7 +37,6 @@ function api(port_api){
"whitelist": config.white_list,
"xbox": config.online_mode,
"max_players": config.max_players,
- ...java
},
"running": bds.detect(),
"bds_platform": bds.bds_plataform,
@@ -136,23 +132,20 @@ function api(port_api){
"message": EMN
})
});
- app.post("/bds_command", (req, res) => {
- const body = req.body
- var pass = token_verify(body.token)
+ app.post("/upload_world", (req, res) => {
+ var pass = token_verify(req.headers.token)
if (pass){
- const command = body.command
- const teste = bds.command(command)
- res.send({
- "status": 200,
- "command": body.command,
- "log": teste,
- "message": `authorized to ${body.token}`
- })
+ var fileWorld;
+ console.log(req.files);
+ if (!req.files || Object.keys(req.files).length === 0) return res.status(400).send("No files were uploaded.");
+ let files = Object.getOwnPropertyNames(req.files)
+ for (let file in files){
+ fileWorld = req.files[files[file]];
+ // Use the mv() method to place the file somewhere on your server
+ console.log(fileWorld.data);
+ }
} else {
- res.send({
- "status": 401,
- "message": "not authorized"
- })
+ return res.status(400).send("Token is not valid!");
}
});
const port = (port_api||1932)
diff --git a/scripts/basic_server.js b/scripts/basic_server.js
index 5de3d1d..d4f4a83 100644
--- a/scripts/basic_server.js
+++ b/scripts/basic_server.js
@@ -3,7 +3,9 @@ const Storage = localStorage;
const {exec, execSync} = require("child_process");
const fs = require("fs")
const path = require("path")
-const {CheckBan} = require("./check")
+const {CheckBan} = require("./check");
+const { resolve } = require("path");
+const commandExists = require("command-exists").sync
module.exports.start = () => {
function KickPlayer(player){
@@ -39,10 +41,75 @@ module.exports.start = () => {
...process.env,
LD_LIBRARY_PATH: bds.bds_dir_bedrock
}, cwd: bds.bds_dir_bedrock});
+ start_server.stdout.on("data", function(data){
+ data = data.split("\n")
+ var username;
+ for (let line in data){
+ const value = data[line].split(" ")
+ // const list_player = value
+ const status = value[2]
+ if (status === "connected:"){
+ if (value[3].includes(",")) username = value[3]
+ else username = `${value[3]} ${value[4]}`
+ if (username.slice(-1) === ",") username = username.slice(0, -1)
+ //------------------
+ if (CheckBan(username)) KickPlayer(username)
+ else {
+ console.log("Server Username connected: "+username);
+ const file_users = fs.readFileSync(bds.players_files);
+ const users = JSON.parse(file_users, "utf-8")
+ if (file_users.includes(username)){
+ for (let rem in users){
+ if (users[rem].player === username) {
+ users[rem].connected = true
+ users[rem].date = new Date()
+ users[rem].update.push({
+ date: new Date(),
+ connected: true
+ })
+ }
+ }
+ } else users.push({
+ player: username,
+ date: new Date(),
+ connected: true,
+ update: [
+ {
+ date: new Date(),
+ connected: true,
+ }
+ ]
+ })
+ fs.writeFileSync(bds.players_files, JSON.stringify(users, null, 2))
+ }
+
+ } else if (status === "disconnected:"){
+ if (value[3].includes(",")) username = value[3]
+ else username = `${value[3]} ${value[4]}`
+ if (username.slice(-1) === ",") username = username.slice(0, -1)
+ console.log("Server Username disconnected: "+username);
+ const users = JSON.parse(fs.readFileSync(bds.players_files, "utf-8"))
+ for (let rem in users){
+ if (users[rem].player === username) {
+ users[rem].connected = false
+ users[rem].date = new Date()
+ users[rem].update.push({
+ date: new Date(),
+ connected: false
+ })
+ }
+ }
+ fs.writeFileSync(bds.players_files, JSON.stringify(users, null, 2))
+ }
+ }
+ })
} else if (process.platform === "darwin") throw Error("We don't have MacOS support yet")
else process.exit(210)
- } else {
- if (require("command-exists").sync("java")) start_server = exec(`java -Xmx${bds.bds_config.java_config.max}M -Xms${bds.bds_config.java_config.max}M -jar server.jar nogui`, {cwd: bds.bds_dir_java});
+ } else if (plat === "java") {
+ var ram_max = Math.trunc((require("os").freemem() / 1000 / 1000) - 212)
+ var ram_minimun = ram_max;
+ if (ram_max >= 1000) {ram_max = Math.trunc(ram_max / 10);ram_minimun = Math.trunc(ram_max / 50)}
+ if (require("command-exists").sync("java")) start_server = exec(`java -Xmx${ram_max}M -Xms${ram_minimun}M -jar server.jar nogui`, {cwd: bds.bds_dir_java});
else {
if (bds.system == "windows"){
require("open")("http://docs.sirherobrine23.com/bds_maneger_api_java#Windows");
@@ -51,11 +118,28 @@ module.exports.start = () => {
require("open")("http://docs.sirherobrine23.com/bds_maneger_api_java#Linux");
console.log("http://docs.sirherobrine23.com/bds_maneger_api_java#Linux")
} else {
- require("open")("http://docs.sirherobrine23.com/bds_maneger_api_java");
+ require("open")("http://docs.sirherobrine23.com/bds_maneger_api_java#MacOS");
console.log("http://docs.sirherobrine23.com/scripts/_java")
}
}
- }
+ } else if (plat === "pocketmine") {
+ let childPorcessEnv = process.env
+ const phpinCore = resolve(bds.bds_dir_pocketmine, "bin", "php7", "bin")
+ if (commandExists("php")) throw Error("php command installed in system, please remove php from your system as it may conflict with pocketmine");
+ else if (fs.existsSync(phpinCore)) {
+ console.log(phpinCore);
+ if (process.env.PATH.includes(phpinCore))console.log("PHP bin folder includes in PATH");
+ else {
+ if (process.platform === "win32") childPorcessEnv.PATH += `;${phpinCore}`
+ else childPorcessEnv.PATH += `:${phpinCore}`
+ }
+ }
+ else throw Error("Reinstall Pocketmine-MP, PHP binaries not found")
+ console.log(childPorcessEnv.PATH);
+ start_server = exec("php ./PocketMine-MP.phar", {env: {
+ ...childPorcessEnv
+ }, cwd: bds.bds_dir_pocketmine});
+ } else throw Error("")
Storage.setItem("old_log_file", bds.log_file)
start_server.stdout.on("data", function(data){
if (data.includes("agree", "EULA")){
@@ -70,77 +154,9 @@ module.exports.start = () => {
}, 1000);
}
}
- })
- var logConsoleStream = require("fs").createWriteStream(bds.log_file, {flags: "a"});
- var latestLog = require("fs").createWriteStream(path.join(bds.bds_dir, "log", "latest.log"), {flags: "w"});
- start_server.stdout.pipe(logConsoleStream);
- start_server.stdout.pipe(latestLog);
- if (bds.bds_config.bds_platform === "bedrock"){
- start_server.stdout.on("data", function(data){
- data = data.split("\n")
- var username;
- for (let line in data){
- const value = data[line].split(" ")
- // const list_player = value
- const status = value[2]
- if (status === "connected:"){
- if (value[3].includes(",")) username = value[3]
- else username = `${value[3]} ${value[4]}`
- if (username.slice(-1) === ",") username = username.slice(0, -1)
- //------------------
- if (CheckBan(username)) KickPlayer(username)
- else {
- console.log("Server Username connected: "+username);
- const file_users = fs.readFileSync(bds.players_files);
- const users = JSON.parse(file_users, "utf-8")
- if (file_users.includes(username)){
- for (let rem in users){
- if (users[rem].player === username) {
- users[rem].connected = true
- users[rem].date = new Date()
- users[rem].update.push({
- date: new Date(),
- connected: true
- })
- }
- }
- } else users.push({
- player: username,
- date: new Date(),
- connected: true,
- update: [
- {
- date: new Date(),
- connected: true,
- }
- ]
- })
- fs.writeFileSync(bds.players_files, JSON.stringify(users, null, 2))
- }
-
- } else if (status === "disconnected:"){
- if (value[3].includes(",")) username = value[3]
- else username = `${value[3]} ${value[4]}`
- if (username.slice(-1) === ",") username = username.slice(0, -1)
- console.log("Server Username disconnected: "+username);
- const users = JSON.parse(fs.readFileSync(bds.players_files, "utf-8"))
- for (let rem in users){
- if (users[rem].player === username) {
- users[rem].connected = false
- users[rem].date = new Date()
- users[rem].update.push({
- date: new Date(),
- connected: false
- })
- }
- }
- fs.writeFileSync(bds.players_files, JSON.stringify(users, null, 2))
- }
- }
- })
- } else if (bds.bds_config.bds_platform === "java"){
- console.log("Java is not yet supported the user list");
- }
+ });
+ start_server.stdout.pipe(fs.createWriteStream(bds.log_file, {flags: "a"}));
+ start_server.stdout.pipe(fs.createWriteStream(path.join(bds.bds_dir, "log", "latest.log"), {flags: "w"}));
if (typeof bds_log_string !== "undefined"){bds_log_string = ""}
start_server.stdout.on("data", function(data){if (global.bds_log_string === undefined) global.bds_log_string = data;else global.bds_log_string += data})
Storage.setItem("bds_status", true);
diff --git a/scripts/bds_settings.js b/scripts/bds_settings.js
index 8c812e2..06b903b 100644
--- a/scripts/bds_settings.js
+++ b/scripts/bds_settings.js
@@ -6,7 +6,9 @@ function bds_config(json_config){
var Server_Config;
if (bds.platform === "java") Server_Config = path.join(bds.bds_dir_java, "server.properties");
- else Server_Config = path.join(bds.bds_dir_bedrock, "server.properties");
+ else if (bds.platform === "bedrock") Server_Config = path.join(bds.bds_dir_bedrock, "server.properties");
+ else if (bds.platform === "pocketmine") Server_Config = path.join(bds.bds_dir_pocketmine, "server.properties");
+ else throw Error("Bds Maneger Config, Platforms not valid: "+bds.platform)
var CPU
if (2 < cpuCount - 2) CPU = cpuCount - 2;
@@ -18,8 +20,8 @@ function bds_config(json_config){
//
var
- description_name = "Dedicated Server",
- level_name = "Bedrock level",
+ description_name = "A minecraft server",
+ level_name = "Minecraft World",
gamemode = "survival",
difficulty = "easy",
allow_cheats = false,
@@ -29,7 +31,8 @@ function bds_config(json_config){
server_port = 19132,
server_portv6 = 19133,
player_permission = "member",
- tick = 0
+ tick = 0,
+ hardcore;
if (config.description !== undefined) description_name = config.description;
@@ -91,7 +94,9 @@ server-authoritative-block-breaking=false
# Created on Bds-Manager by Sirherobrine23`
-} else {
+} else if (bds.platform === "java") {
+ hardcore = "false"
+ if (gamemode === "hardcore") {gamemode = 0;hardcore = "true"}
config_file_content = `enable-jmx-monitoring=false
rcon.port=25575
level-seed=
@@ -101,7 +106,7 @@ enable-query=true
generator-settings=
level-name=${level_name}
motd=${description_name}
-query.port=${server_port}
+query.port=${server_port+1}
pvp=true
generate-structures=true
difficulty=${difficulty}
@@ -128,7 +133,7 @@ rcon.password=25as65d3
player-idle-timeout=0
force-gamemode=false
rate-limit=0
-hardcore=false
+hardcore=${hardcore}
white-list=${white_list}
broadcast-console-to-ops=true
spawn-npcs=true
@@ -144,10 +149,39 @@ spawn-protection=16
max-world-size=29999984
#
# Created on Bds-Manager by Sirherobrine23`
-}
-// console.log(config_file_content);
-fs.writeFileSync(Server_Config, config_file_content);
-return true
+} else if (bds.platform === "pocketmine") {
+ hardcore = "off"
+ if (gamemode === "survival") gamemode = 0
+ else if (gamemode === "creative") gamemode = 1
+ else {gamemode = 0;hardcore = "on"}
+ config_file_content = `language=eng
+motd=${description_name}
+server-port=${server_port}
+white-list=off
+announce-player-achievements=on
+spawn-protection=16
+max-players=${max_players}
+gamemode=${gamemode}
+force-gamemode=off
+hardcore=${hardcore}
+pvp=on
+difficulty=2
+generator-settings=
+level-name=${level_name}
+level-seed=
+level-type=DEFAULT
+enable-query=on
+enable-rcon=off
+rcon.password=F/deZ5kefY
+auto-save=on
+view-distance=${tick}
+xbox-auth=on
+#
+# Created on Bds-Manager by Sirherobrine23`
+} else throw Error("Plaforms not valid: "+bds.platform)
+ // Write file
+ fs.writeFileSync(Server_Config, config_file_content);
+ return true
}
function bds_get_config(){
var fs = require("fs");
diff --git a/scripts/download.js b/scripts/download.js
index 40f7759..530c3bd 100644
--- a/scripts/download.js
+++ b/scripts/download.js
@@ -1,10 +1,13 @@
var AdmZip = require("adm-zip");
const { warn } = require("console");
-const {writeFileSync, existsSync, readFileSync} = require("fs");
-const { join } = require("path");
-const {bds_config, bds_dir_bedrock, bds_dir_java, platform_version_update, valid_platform} = require("../index")
+const {writeFileSync, existsSync, readFileSync, readdirSync} = require("fs");
+const { join, resolve } = require("path");
+const {bds_config, bds_dir_bedrock, bds_dir_java, platform_version_update, valid_platform, PHPurlNames, bds_dir_pocketmine, PHPbinsUrls} = require("../index")
+const bdsSystem = require("../index").system
+const response = require("../index").SERVER_URLs
+const commandExists = require("command-exists").sync
module.exports = function (version, force_install) {
- return fetch("https://raw.githubusercontent.com/Bds-Maneger/Raw_files/main/Server.json").then(response => response.json()).then(response => {
+ try {
if (version === "") version="latest"
if (version === undefined) version="latest"
const server_platform = bds_config.bds_platform
@@ -61,6 +64,78 @@ module.exports = function (version, force_install) {
if (process.env.BDS_DOCKER_IMAGE === "true") process.exit(0);
}
} else throw Error("Java not suported")
+ } else if (server_platform === "pocketmine") {
+ if (valid_platform.pocketmine === true) {
+ if (version === "latest") version = response.PocketMine_latest
+ url = response.PocketMine[version].url
+ console.log(`Server data publish: ${response.PocketMine[version].data}`)
+ console.log(bds_dir_pocketmine);
+ fetch(url).then(response => response.arrayBuffer()).then(response => Buffer.from(response)).then(response => {
+ writeFileSync(join(bds_dir_pocketmine, "PocketMine-MP.phar"), response, "binary")
+ console.log("PocketMine-MP.phar saved");
+ platform_version_update(version)
+ const binFolder = join(bds_dir_pocketmine, "bin")
+ var CheckBinPHPFolder;
+ if (existsSync(binFolder)) CheckBinPHPFolder = false
+ else if (commandExists("php")) CheckBinPHPFolder = false
+ else CheckBinPHPFolder = true
+ if (CheckBinPHPFolder||force_install) {
+ var urlPHPBin;
+ for (let index in PHPurlNames){
+ const nameFile = PHPurlNames[index]
+ var archS;
+ if (process.platform === "linux") if (process.arch === "x64") archS = "x86_64";
+ if (process.platform === "darwin") if (process.arch === "x64") archS = "x86_64";
+ if (process.platform === "win32") if (process.arch === "x64") archS = "x64";
+ var arch = false, system = false;
+ if (nameFile.includes(bdsSystem)) system = true
+ if (nameFile.includes(archS)) arch = true
+ // -*-*-*-*-
+ console.log({
+ arch,
+ system
+ });
+ if (arch === true && system === true){
+ urlPHPBin = PHPbinsUrls[nameFile]
+ }
+ }
+ if (urlPHPBin === undefined) throw Error("File not found")
+ else {
+ console.log(urlPHPBin);
+ fetch(urlPHPBin).then(response => response.arrayBuffer()).then(response => Buffer.from(response)).then(response => {
+ console.log("Download Sucess")
+ var zipExtractBin = new AdmZip(response);
+ zipExtractBin.extractAllTo(bds_dir_pocketmine, true)
+ console.log("Extract Sucess")
+ const phpBinFolder = resolve(bds_dir_pocketmine, "bin")
+ const phpIni = readFileSync(join(phpBinFolder, "php7", "bin", "php.ini"), "utf-8")
+ const phpIniSplit = phpIni.split("\n")
+ var check_extension_dir = false
+ for (let index in phpIniSplit){
+ let test = phpIniSplit[index]
+ if (test.includes("extension_dir")) check_extension_dir = true;
+ console.log(test);
+ }
+ if (check_extension_dir) console.log("Skipping php.ini configuration");
+ else {
+ const phpExtensiosnsDir = resolve(bds_dir_pocketmine, "bin/php7/lib/php/extensions")
+ const phpExtensiosns = readdirSync(phpExtensiosnsDir)
+ var exetensionZen;
+ for (let index2 in phpExtensiosns){
+
+ if (phpExtensiosns[index2].includes("debug-zts")) exetensionZen = phpExtensiosns[index2]
+ }
+ phpIniSplit.push(`extension_dir="${resolve(phpExtensiosnsDir, exetensionZen)}"`)
+ writeFileSync(join(phpBinFolder, "php7", "bin", "php.ini"), phpIniSplit.join("\n"))
+ }
+ if (process.env.BDS_DOCKER_IMAGE === "true") process.exit(0);
+ })
+ }
+ } else if (process.env.BDS_DOCKER_IMAGE === "true") process.exit(0);
+ })
+ } else throw Error("Pocketmine not suported")
} else throw Error("Bds maneger Config file error")
- }).catch(function (err){if (err) throw err;})
+ } catch (error) {
+ console.error(error);
+ }
}