Pocketmine init #79

Merged
Sirherobrine23 merged 10 commits from pocketMine into main 2021-04-10 03:23:21 +00:00
44 changed files with 1142 additions and 237 deletions

View File

@ -1,4 +1,5 @@
node_modules/ node_modules/
Docker/ Docker/
!Docker/base !Docker/root_path
!Docker/etc .git/
Docker.sh

View File

@ -1,8 +1,6 @@
name: The nightly Docker Image name: The Docker Image Check
on: on:
push: pull_request:
branches-ignore:
- dependabot/**
jobs: jobs:
Docker: Docker:
@ -27,9 +25,8 @@ jobs:
id: docker_build id: docker_build
uses: docker/build-push-action@v2 uses: docker/build-push-action@v2
with: with:
push: true
file: Docker/Dockerfile file: Docker/Dockerfile
push: false
tags: | tags: |
sirherobrine23/bdsmaneger:nightly bdsmaneger:test_${{ github.run_id }}
bdsmaneger/maneger:nightly
platforms: linux/amd64,linux/arm64 platforms: linux/amd64,linux/arm64

View File

@ -2,9 +2,11 @@ name: "CodeQL"
on: on:
push: push:
branches: [ main, stable ] branches:
- main
pull_request: pull_request:
branches: [ main, stable ] branches:
- main
schedule: schedule:
- cron: "38 17 * * */3" - cron: "38 17 * * */3"

View File

@ -1,4 +1,4 @@
name: Npm dev package Publish name: Dev Publish NPM and Docker Image
on: on:
push: push:
branches: branches:
@ -11,18 +11,16 @@ on:
- 'CHANGELOG.md' - 'CHANGELOG.md'
- 'Docker/*/**' - 'Docker/*/**'
jobs: jobs:
Npm-Publish: Npm-Publish-Dev:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@master uses: actions/checkout@master
- name: Npm and Node Setup - name: Npm and Node Setup
uses: actions/setup-node@v1 uses: actions/setup-node@v1
with: with:
node-version: 15.x node-version: 15.x
registry-url: https://registry.npmjs.org/ registry-url: https://registry.npmjs.org/
- name: Edit Version - name: Edit Version
run: | run: |
id_run1=$(echo ${{ github.run_id }} |cut -b 1-2) 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 sed "s|$old|\"version\": \"$new_version\",|g" package.json > package2.json
cat package2.json > package.json cat package2.json > package.json
rm -rfv package2.json rm -rfv package2.json
- name: Install Packages - name: Install Packages
run: npm install 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

View File

@ -1,10 +1,8 @@
name: "Dependabot Automerge - Action" name: "Dependabot Automerge - Action"
on: on:
pull_request: pull_request:
check_suite: branches:
types: - dependabot/**
- completed
status: {}
jobs: jobs:
automerge: automerge:
runs-on: ubuntu-latest runs-on: ubuntu-latest

9
Docker.sh Executable file
View File

@ -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
}

View File

@ -6,23 +6,34 @@ RUN \
echo "Arch: $(uname -m)"; \ echo "Arch: $(uname -m)"; \
apt update && \ 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) && \ 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/* && \ 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 ENV \
COPY ./Docker/base/ /base/ TELEGRAM_TOKEN="null" \
COPY ./Docker/etc/ /etc/ DESCRIPTION="running Minecraft Bedrock Server on the docker by Bds Manager" \
COPY ./ /opt/bdsCore/ WORLD_NAME="Bds Maneger Docker" \
RUN cd /opt/bdsCore/ && npm install --no-save GAMEMODE="survival" \
ENV TELEGRAM_TOKEN="null" DESCRIPTION="running Minecraft Bedrock Server on the docker by Bds Manager" \ DIFFICULTY="normal" \
WORLD_NAME="Bds Maneger Docker" GAMEMODE="survival" DIFFICULTY="normal" XBOX_ACCOUNT="false" PLAYERS="13" \ XBOX_ACCOUNT="false" \
BDS_VERSION="latest" SERVER="bedrock" BDS_REINSTALL="true" Docker_Debug_Script="false" \ PLAYERS="13" \
ngrok_token="" BDS_VERSION="latest" \
SERVER="bedrock" \
RUN mkdir -p /home/bds/.config/bds_core BDS_REINSTALL="true" \
Docker_Debug_Script="false"
EXPOSE 80/tcp 19132/udp 19133/udp EXPOSE 80/tcp 19132/udp 19133/udp
ENV BDS_DOCKER_IMAGE="true" HOME="/home/bds/" 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 # Entrypint
WORKDIR /home/bds/ WORKDIR /home/bds/
RUN chmod +x /base/init.sh RUN chmod +x /base/init.sh

View File

@ -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;
}
}

View File

@ -1,10 +1,9 @@
const bds = require("/opt/bdsCore/index"); const bds = require("/opt/bdsCore/index");
// const {bds_dir} = require("/opt/bdsCore/index");
const { existsSync, readFileSync } = require("fs") const { existsSync, readFileSync } = require("fs")
const { resolve, join } = require("path") const { resolve, join } = require("path")
// Enable APIs // Enable APIs
bds.api(); bds.rest();
// Log function // Log function
function output(dados){var out = dados; if (out.slice(-1) == "\n") out = out.slice(0, -1); console.log(out)} function output(dados){var out = dados; if (out.slice(-1) == "\n") out = out.slice(0, -1); console.log(out)}

View File

@ -24,6 +24,6 @@ else if (existsSync(join(bds.bds_dir_java, "server.jar"))) bds_software = true
if (bds_software){ 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) } else bds.download(process.env.BDS_VERSION)

View File

@ -0,0 +1 @@
client_max_body_size 512M;

View File

@ -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/;
}
}

View File

@ -0,0 +1 @@
/etc/nginx/sites-available/default

View File

@ -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.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -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%;
}

View File

@ -0,0 +1,11 @@
.svg_sucess {
--svg-color: #1fff1f;
}
.svg_erro {
--svg-color: red;
}
.svg_color {
fill: var(--svg-color);
display: none;
}

View File

@ -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;
}

View File

@ -0,0 +1,3 @@
<svg version="1.1" class="svg_color" fill="currentColor" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 241.171 241.171" width="7pt" height="7pt">
<path fill-rule="evenodd" d="M138.138,120.754l99.118-98.576c4.752-4.704,4.752-12.319,0-17.011c-4.74-4.704-12.439-4.704-17.179,0 l-99.033,98.492L21.095,3.699c-4.74-4.752-12.439-4.752-17.179,0c-4.74,4.764-4.74,12.475,0,17.227l99.876,99.888L3.555,220.497 c-4.74,4.704-4.74,12.319,0,17.011c4.74,4.704,12.439,4.704,17.179,0l100.152-99.599l99.551,99.563 c4.74,4.752,12.439,4.752,17.179,0c4.74-4.764,4.74-12.475,0-17.227L138.138,120.754z"/>
</svg>

After

Width:  |  Height:  |  Size: 650 B

View File

@ -0,0 +1,3 @@
<svg version="1.1" class="svg_color" fill="currentColor" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 492 492" width="7pt" height="7pt">
<path fill-rule="evenodd" d="M484.128,104.478l-16.116-16.116c-5.064-5.068-11.816-7.856-19.024-7.856c-7.208,0-13.964,2.788-19.028,7.856 L203.508,314.81L62.024,173.322c-5.064-5.06-11.82-7.852-19.028-7.852c-7.204,0-13.956,2.792-19.024,7.852l-16.12,16.112 C2.784,194.51,0,201.27,0,208.47c0,7.204,2.784,13.96,7.852,19.028l159.744,159.736c0.212,0.3,0.436,0.58,0.696,0.836 l16.12,15.852c5.064,5.048,11.82,7.572,19.084,7.572h0.084c7.212,0,13.968-2.524,19.024-7.572l16.124-15.992 c0.26-0.256,0.48-0.468,0.612-0.684l244.784-244.76C494.624,132.01,494.624,114.966,484.128,104.478z"/>
</svg>

After

Width:  |  Height:  |  Size: 793 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

View File

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Generator: Adobe Illustrator 18.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 207.027 207.027" style="enable-background:new 0 0 207.027 207.027;" xml:space="preserve">
<path d="M69.866,15.557L0,138.919l28.732,52.552l143.288-0.029l35.008-59.588L136.39,15.735L69.866,15.557z M17.166,139.046
L74.268,38.205L91.21,67.783L33.24,168.447L17.166,139.046z M99.841,82.851l23.805,41.558l-47.732-0.006L99.841,82.851z
M163.434,176.443l-117.332,0.024l21.53-37.065l64.606,0.008l0.067,0.119l52.865-0.085L163.434,176.443z M140.932,124.411
L90.157,35.767l-2.966-5.178l40.751,0.121l57.003,93.706L140.932,124.411z"/>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24" viewBox="0 0 24 24" width="24"><g><path d="M0,0h24v24H0V0z" fill="none"/><path d="M19.14,12.94c0.04-0.3,0.06-0.61,0.06-0.94c0-0.32-0.02-0.64-0.07-0.94l2.03-1.58c0.18-0.14,0.23-0.41,0.12-0.61 l-1.92-3.32c-0.12-0.22-0.37-0.29-0.59-0.22l-2.39,0.96c-0.5-0.38-1.03-0.7-1.62-0.94L14.4,2.81c-0.04-0.24-0.24-0.41-0.48-0.41 h-3.84c-0.24,0-0.43,0.17-0.47,0.41L9.25,5.35C8.66,5.59,8.12,5.92,7.63,6.29L5.24,5.33c-0.22-0.08-0.47,0-0.59,0.22L2.74,8.87 C2.62,9.08,2.66,9.34,2.86,9.48l2.03,1.58C4.84,11.36,4.8,11.69,4.8,12s0.02,0.64,0.07,0.94l-2.03,1.58 c-0.18,0.14-0.23,0.41-0.12,0.61l1.92,3.32c0.12,0.22,0.37,0.29,0.59,0.22l2.39-0.96c0.5,0.38,1.03,0.7,1.62,0.94l0.36,2.54 c0.05,0.24,0.24,0.41,0.48,0.41h3.84c0.24,0,0.44-0.17,0.47-0.41l0.36-2.54c0.59-0.24,1.13-0.56,1.62-0.94l2.39,0.96 c0.22,0.08,0.47,0,0.59-0.22l1.92-3.32c0.12-0.22,0.07-0.47-0.12-0.61L19.14,12.94z M12,15.6c-1.98,0-3.6-1.62-3.6-3.6 s1.62-3.6,3.6-3.6s3.6,1.62,3.6,3.6S13.98,15.6,12,15.6z"/></g></svg>

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M0 0h24v24H0z" fill="none"/><path d="M7 18c-1.1 0-1.99.9-1.99 2S5.9 22 7 22s2-.9 2-2-.9-2-2-2zM1 2v2h2l3.6 7.59-1.35 2.45c-.16.28-.25.61-.25.96 0 1.1.9 2 2 2h12v-2H7.42c-.14 0-.25-.11-.25-.25l.03-.12.9-1.63h7.45c.75 0 1.41-.41 1.75-1.03l3.58-6.49c.08-.14.12-.31.12-.48 0-.55-.45-1-1-1H5.21l-.94-2H1zm16 16c-1.1 0-1.99.9-1.99 2s.89 2 1.99 2 2-.9 2-2-.9-2-2-2z"/></svg>

After

Width:  |  Height:  |  Size: 459 B

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24" viewBox="0 0 24 24" width="24"><g><rect fill="none" height="24" width="24"/><path d="M20.41,8.41l-4.83-4.83C15.21,3.21,14.7,3,14.17,3H5C3.9,3,3,3.9,3,5v14c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V9.83 C21,9.3,20.79,8.79,20.41,8.41z M7,7h7v2H7V7z M17,17H7v-2h10V17z M17,13H7v-2h10V13z"/></g></svg>

After

Width:  |  Height:  |  Size: 376 B

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M0 0h24v24H0z" fill="none"/><path d="M0 0h24v24H0z" fill="none"/><path d="M2 12C2 6.48 6.48 2 12 2s10 4.48 10 10-4.48 10-10 10S2 17.52 2 12zm10 6c3.31 0 6-2.69 6-6s-2.69-6-6-6-6 2.69-6 6 2.69 6 6 6z"/></svg>

After

Width:  |  Height:  |  Size: 299 B

View File

@ -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"}}

View File

@ -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};
})

View File

@ -0,0 +1,118 @@
<!DOCTYPE html>
<html lang="en" translate="no">
<script>
if (location.protocol === "https:") location.replace("http://web.the-bds-maneger.org/?from=https")
const urlParams = new URLSearchParams(window.location.search);
if (urlParams.get("from") === "https") alert("Do not use \"https://web.the-bds-maneger.org\" as you will always have an error")
</script>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bds Maneger Web</title>
<link rel="shortcut icon" href="./assents/image/favicon.ico" />
<link rel="stylesheet" type="text/css" media="screen" href="assents/css/main.css">
<link rel="stylesheet" type="text/css" media="screen" href="assents/css/check.css">
<link rel="stylesheet" type="text/css" media="screen" href="assents/css/complete.css">
<meta name="description" content="Control your Minecraft server remotely (Requires Bds Manager core or Electron)">
<meta name="google" content="notranslate">
</head>
<div id="test"></div>
<div class="svg_sucess">
<svg version="1.1" class="svg_color" fill="currentColor" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 492 492" width="7pt" height="7pt">
<path fill-rule="evenodd" d="M484.128,104.478l-16.116-16.116c-5.064-5.068-11.816-7.856-19.024-7.856c-7.208,0-13.964,2.788-19.028,7.856 L203.508,314.81L62.024,173.322c-5.064-5.06-11.82-7.852-19.028-7.852c-7.204,0-13.956,2.792-19.024,7.852l-16.12,16.112 C2.784,194.51,0,201.27,0,208.47c0,7.204,2.784,13.96,7.852,19.028l159.744,159.736c0.212,0.3,0.436,0.58,0.696,0.836 l16.12,15.852c5.064,5.048,11.82,7.572,19.084,7.572h0.084c7.212,0,13.968-2.524,19.024-7.572l16.124-15.992 c0.26-0.256,0.48-0.468,0.612-0.684l244.784-244.76C494.624,132.01,494.624,114.966,484.128,104.478z"/>
</svg>
<svg version="1.1" class="svg_color" fill="currentColor" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 241.171 241.171" width="7pt" height="7pt">
<path fill-rule="evenodd" d="M138.138,120.754l99.118-98.576c4.752-4.704,4.752-12.319,0-17.011c-4.74-4.704-12.439-4.704-17.179,0 l-99.033,98.492L21.095,3.699c-4.74-4.752-12.439-4.752-17.179,0c-4.74,4.764-4.74,12.475,0,17.227l99.876,99.888L3.555,220.497 c-4.74,4.704-4.74,12.319,0,17.011c4.74,4.704,12.439,4.704,17.179,0l100.152-99.599l99.551,99.563 c4.74,4.752,12.439,4.752,17.179,0c4.74-4.764,4.74-12.475,0-17.227L138.138,120.754z"/>
</svg>
</div>
<body class="system">
<div class="Log_div_Title">Bds Maneger Log</div>
<div class="root">
<div class="bds_log" id="bds_log"></div>
</div>
<div class="root">
<script>
function checkCommand(){
const currentCommand = document.getElementById("command").value;
if (currentCommand.charAt(0) === "/") document.getElementById("command").value = currentCommand.replace("/", "");
}
function clearCommand(){document.getElementById("command").value = ""}
</script>
<input class="command_area" placeholder="The command is here, there is no need to include the '/'" oninput="checkCommand();" type="text" id="command" onkeydown="if(event.keyCode === 13) document.getElementById('command_send').click()">
<input class="command_send" id="command_send" type="submit" onclick="bds_command(); clearCommand()">
</div>
<div class="buttons">
<div class="bds_service" onclick="bds_start()">Start</div> <div class="space"></div>
<div class="bds_service" onclick="bds_stop()">Stop</div> <div class="space"></div>
<div class="bds_service" onclick="bds_restart()">Restart</div> <div class="space"></div>
<div class="bds_service" onclick="settings_display()">Settings and information</div>
</div>
<div id="config" class="config">
<div class="config_conatainer">
<div class="close" onclick="settings_display()">Exit</div>
<div class="config_root">
<!-- -->
<script>
function saveAddress(){
var serverAddr = document.getElementById("bds_addr").value;
localStorage.setItem("the_addr", serverAddr);
console.log(`server Addr Save: ${serverAddr}`);
if (andress !== serverAddr) document.getElementById("ReloadPage").style.display = "block";
else document.getElementById("ReloadPage").style.display = "none";
}
function changeToken(){
var tokenSS = document.getElementById("bds_token").value;
localStorage.setItem("the_token", tokenSS);
console.log(`Token save: ${tokenSS}`);
if (tokenSS !== token) document.getElementById("ReloadPage").style.display = "block";
else document.getElementById("ReloadPage").style.display = "none";
}
</script>
<fieldset>
<span>Bds Maneger Token:</span><input class="bds_aiptoken" type="text" id="bds_token" oninput="changeToken();" onchange="changeToken();">
<p><a style="display: none;" id="ReloadPage" onclick="location.reload()">Reload Page</a></p>
<!------------------------------------------------------------------------------------------------------------>
<div class="config_space">
<input type="file" accept="application/zip" id="WorldUpload" onchange="UploadWorld(this)">
</div>
</fieldset>
<!-- -->
</div>
</div>
</div>
</body>
</html>
<script src="./web_main.js"></script>
<div class="loading" id="loading">
<div id="wait1">Wait .</div>
<div id="wait2">Wait ..</div>
<div id="wait3">Wait ...</div>
<script>
function wait1 (){
document.getElementById("wait1").style.display = "block"
document.getElementById("wait2").style.display = "none"
document.getElementById("wait3").style.display = "none"
}
function wait2 (){
document.getElementById("wait1").style.display = "none"
document.getElementById("wait2").style.display = "block"
document.getElementById("wait3").style.display = "none"
}
function wait3 (){
document.getElementById("wait1").style.display = "none"
document.getElementById("wait2").style.display = "none"
document.getElementById("wait3").style.display = "block"
}
setInterval(() => {
wait1()
setTimeout(() => {
wait2()
setTimeout(() => {
wait3()
}, 100);
}, 100);
}, 1000);
</script>
</div>

View File

@ -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"
}

View File

@ -8,6 +8,12 @@ For now we are in a version qualified for general use and implementations in com
[![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&amp;utm_medium=referral&amp;utm_content=Bds-Maneger/bds_maneger_api&amp;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&amp;utm_medium=referral&amp;utm_content=Bds-Maneger/bds_maneger_api&amp;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 ## Start the Bds Maneger Core docker server
```bash ```bash
@ -29,12 +35,12 @@ bdsmaneger/maneger:latest
## Azure Deploys ## 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) [![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) [![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)

View File

@ -54,7 +54,7 @@ if (!(existsSync(server_exec))) {
if (bds_version){ if (bds_version){
try { try {
process.env.BDS_DOCKER_IMAGE = true process.env.BDS_DOCKER_IMAGE = true
bds.download(bds_version) bds.download(bds_version, true)
} catch (error) { } catch (error) {
console.error(error) console.error(error)
process.exit(165) process.exit(165)

46
curlCheck.js Normal file
View File

@ -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")
}
})()

View File

@ -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}\""

108
index.js
View File

@ -5,6 +5,7 @@ const { resolve } = require("path");
const { error } = console; const { error } = console;
const shell = require("shelljs"); const shell = require("shelljs");
const {getDesktopFolder, getConfigHome} = require("platform-folders") const {getDesktopFolder, getConfigHome} = require("platform-folders")
const { execSync } = require("child_process");
const bds_core_package = resolve(__dirname, "package.json") const bds_core_package = resolve(__dirname, "package.json")
const bds_maneger_version = require(bds_core_package).version const bds_maneger_version = require(bds_core_package).version
@ -40,9 +41,10 @@ module.exports.package_path = bds_core_package
if (process.platform == "win32") { if (process.platform == "win32") {
home = process.env.USERPROFILE; home = process.env.USERPROFILE;
tmp = process.env.TMP tmp = process.env.TMP
system = "windows"; system = "Windows";
valid_platform = { valid_platform = {
"bedrock": true, "bedrock": true,
"pocketmine": true,
"java": true "java": true
} }
} else if (process.platform == "linux") { } else if (process.platform == "linux") {
@ -50,19 +52,22 @@ if (process.platform == "win32") {
if (process.env.BDS_DOCKER_IMAGE) desktop = "/home/bds/" if (process.env.BDS_DOCKER_IMAGE) desktop = "/home/bds/"
else desktop = "/tmp" else desktop = "/tmp"
tmp = "/tmp"; tmp = "/tmp";
system = "linux"; system = "Linux";
valid_platform = { valid_platform = {
"bedrock": true, "bedrock": true,
"pocketmine": true,
"java": true "java": true
} }
if (process.arch === "aarch64") valid_platform.pocketmine = false;
} else if (process.platform == "darwin") { } 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") 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"); else require("open")("https://github.com/The-Bds-Maneger/core/wiki/system_support#macos-with-intel-processors");
home = process.env.HOME; home = process.env.HOME;
tmp = "/tmp"; tmp = "/tmp";
system = "macOS"; system = "MacOS";
valid_platform = { valid_platform = {
"bedrock": false, "bedrock": false,
"pocketmine": true,
"java": true "java": true
} }
} else { } else {
@ -165,6 +170,15 @@ if (!(fs.existsSync(bds_dir_bedrock))){
} }
module.exports.bds_dir_bedrock = 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 // Create backup folder
if (!(fs.existsSync(bds_dir_backup))){ if (!(fs.existsSync(bds_dir_backup))){
fs.mkdirSync(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 fetch === "undefined") global.fetch = require("node-fetch");
if (typeof localStorage === "undefined") global.localStorage = new require("node-localstorage").LocalStorage(path.join(LocalStorageFolder, "Local_Storage")); 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 ---------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------------- Variables ---------------------------------------------------------------------------- */
// Configs // Configs
var bds_config, bds_config_file = path.join(bds_dir, "bds_config.json"); var bds_config, bds_config_file = path.join(bds_dir, "bds_config.json");
const current_version_bds_core = bds_maneger_version const current_version_bds_core = bds_maneger_version
var default_porcess; var default_platformConfig;
if (process.platform.includes("win32", "linux")) default_porcess = "bedrock" if (process.platform.includes("win32", "linux")) default_platformConfig = "bedrock"
else default_porcess = "java" else default_platformConfig = "java"
if (fs.existsSync(bds_config_file)){ if (fs.existsSync(bds_config_file)){
bds_config = JSON.parse(fs.readFileSync(bds_config_file, "utf8")) bds_config = JSON.parse(fs.readFileSync(bds_config_file, "utf8"))
if (bds_config.version !== current_version_bds_core){ 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.platform_version === undefined) bds_config.platform_version = {}
if (bds_config.bedrock_config === undefined) bds_config.bedrock_config = {} // New Config JSon
bds_config = { bds_config = {
"version": current_version_bds_core, "version": current_version_bds_core,
"bds_pages": (bds_config.bds_pages||"default"), "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": { "platform_version": {
"bedrock": (bds_config.platform_version.bedrock||"latest"), "bedrock": (bds_config.platform_version.bedrock||"latest"),
"java": (bds_config.platform_version.java||"latest") "java": (bds_config.platform_version.java||"latest")
}, },
"bds_ban": (bds_config.bds_ban||["Steve", "Alex", "steve", "alex"]), "bds_ban": (bds_config.bds_ban||["Steve", "Alex", "steve", "alex"]),
"telegram_token": (bds_config.telegram_token||undefined), "telegram_token": (bds_config.telegram_token||undefined),
"Google_Drive_root_backup_id": (bds_config.Google_Drive_root_backup_id||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
}
} }
fs.writeFileSync(bds_config_file, JSON.stringify(bds_config, null, 4)) fs.writeFileSync(bds_config_file, JSON.stringify(bds_config, null, 4))
bds_config_export() bds_config_export()
@ -235,7 +253,7 @@ if (fs.existsSync(bds_config_file)){
bds_config = { bds_config = {
"version": current_version_bds_core, "version": current_version_bds_core,
"bds_pages": "default", "bds_pages": "default",
"bds_platform": default_porcess, "bds_platform": default_platformConfig,
"platform_version": { "platform_version": {
"bedrock": "latest", "bedrock": "latest",
"java": "latest" "java": "latest"
@ -245,15 +263,7 @@ if (fs.existsSync(bds_config_file)){
"Google_Drive_root_backup_id": undefined, "Google_Drive_root_backup_id": undefined,
"telegram_admin": [ "telegram_admin": [
"all_users" "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)) 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)) fs.writeFileSync(bds_config_file, JSON.stringify(bds_config, null, 4))
bds_config_export() bds_config_export()
} }
/**
* Save ID Google Drive folder to Backups
*/
module.exports.save_google_id = function (id){ module.exports.save_google_id = function (id){
let bds_config = JSON.parse(fs.readFileSync(bds_config_file, "utf8")) let bds_config = JSON.parse(fs.readFileSync(bds_config_file, "utf8"))
bds_config.Google_Drive_root_backup_id = id bds_config.Google_Drive_root_backup_id = id
@ -272,39 +287,12 @@ module.exports.save_google_id = function (id){
return true return true
} }
module.exports.platform = bds_config.bds_platform 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 * Bds Maneger Latest log file.
*
* the following values are: 1024mb, 1024MB, 1000MIB, 1000mib, 1GB, 1gb, 1GIB, 1gib
*/ */
module.exports.memory_for_the_java = update_java_memory const log_file = path.join(log_dir, `${date()}_${bds_config.bds_platform}_Bds_log.log`);
module.exports.log_file = log_file
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);
}
function bds_config_export (){ 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") 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) { getSize(bds_dir_backup, function(err, info) {
if (err) throw err if (err) throw err
function toGB(x) {return (x / (1024 * 1024 * 1024)).toFixed(1);} function toGB(x) {return (x / (1024 * 1024 * 1024)).toFixed(1);}

76
package-lock.json generated
View File

@ -1,12 +1,13 @@
{ {
"name": "@the-bds-maneger/core", "name": "@the-bds-maneger/core",
"version": "1.8.5.5", "version": "1.8.6.6",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@the-bds-maneger/core", "name": "@the-bds-maneger/core",
"version": "1.8.5.5", "version": "1.8.6.6",
"hasInstallScript": true,
"license": "AGPL-3.0-or-later", "license": "AGPL-3.0-or-later",
"dependencies": { "dependencies": {
"adm-zip": "^0.5.1", "adm-zip": "^0.5.1",
@ -15,6 +16,7 @@
"cors": "^2.8.5", "cors": "^2.8.5",
"crypto": "^1.0.1", "crypto": "^1.0.1",
"express": "^4.17.1", "express": "^4.17.1",
"express-fileupload": "^1.2.1",
"express-rate-limit": "^5.2.3", "express-rate-limit": "^5.2.3",
"get-folder-size": "^2.0.1", "get-folder-size": "^2.0.1",
"googleapis": "^71.0.0", "googleapis": "^71.0.0",
@ -482,6 +484,17 @@
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz",
"integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==" "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": { "node_modules/bytes": {
"version": "3.1.0", "version": "3.1.0",
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", "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", "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz",
"integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" "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": { "node_modules/dijkstrajs": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/dijkstrajs/-/dijkstrajs-1.0.1.tgz", "resolved": "https://registry.npmjs.org/dijkstrajs/-/dijkstrajs-1.0.1.tgz",
@ -1071,6 +1095,17 @@
"node": ">= 0.10.0" "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": { "node_modules/express-rate-limit": {
"version": "5.2.6", "version": "5.2.6",
"resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-5.2.6.tgz", "resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-5.2.6.tgz",
@ -2492,6 +2527,14 @@
"node": ">= 0.6" "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": { "node_modules/string-width": {
"version": "4.2.2", "version": "4.2.2",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.2.tgz", "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", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz",
"integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==" "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": { "bytes": {
"version": "3.1.0", "version": "3.1.0",
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", "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", "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz",
"integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" "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": { "dijkstrajs": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/dijkstrajs/-/dijkstrajs-1.0.1.tgz", "resolved": "https://registry.npmjs.org/dijkstrajs/-/dijkstrajs-1.0.1.tgz",
@ -3761,6 +3820,14 @@
"vary": "~1.1.2" "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": { "express-rate-limit": {
"version": "5.2.6", "version": "5.2.6",
"resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-5.2.6.tgz", "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", "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz",
"integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=" "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow="
}, },
"streamsearch": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-0.1.2.tgz",
"integrity": "sha1-gIudDlb8Jz2Am6VzOOkpkZoanxo="
},
"string-width": { "string-width": {
"version": "4.2.2", "version": "4.2.2",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.2.tgz", "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.2.tgz",

View File

@ -3,16 +3,17 @@
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"
}, },
"version": "1.8.5.5", "version": "1.8.6.6",
"description": "scripts to manage minecraft bedrock server", "description": "scripts to manage minecraft bedrock server",
"private": false, "private": false,
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"test": "", "test": "exit 0",
"eslint": "eslint .", "eslint": "eslint .",
"eslint:fix": "eslint --fix .", "eslint:fix": "eslint --fix .",
"start": "node bin/bds_maneger.js", "start": "node bin/bds_maneger.js",
"debug": "node bin/debug.js" "debug": "node bin/debug.js",
"postinstall": "node curlCheck.js"
}, },
"bin": { "bin": {
"bds_maneger": "./bin/bds_maneger.js" "bds_maneger": "./bin/bds_maneger.js"
@ -49,6 +50,7 @@
"cors": "^2.8.5", "cors": "^2.8.5",
"crypto": "^1.0.1", "crypto": "^1.0.1",
"express": "^4.17.1", "express": "^4.17.1",
"express-fileupload": "^1.2.1",
"express-rate-limit": "^5.2.3", "express-rate-limit": "^5.2.3",
"get-folder-size": "^2.0.1", "get-folder-size": "^2.0.1",
"googleapis": "^71.0.0", "googleapis": "^71.0.0",

View File

@ -6,17 +6,21 @@ var cors = require("cors");
const rateLimit = require("express-rate-limit"); const rateLimit = require("express-rate-limit");
const token_verify = require("./token_api_check") const token_verify = require("./token_api_check")
const bodyParser = require("body-parser"); const bodyParser = require("body-parser");
const fileUpload = require("express-fileupload");
function api(port_api){ function api(port_api){
const app = express(); 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 // see https://expressjs.com/en/guide/behind-proxies.html
// app.set('trust proxy', 1); // app.set("trust proxy", 1);
const limiter = rateLimit({ const limiter = rateLimit({
windowMs: 15 * 60 * 1000, // 15 minutes windowMs: 15 * 60 * 1000, // 15 minutes
max: 100 // limit each IP to 100 requests per windowMs max: 100 // limit each IP to 100 requests per windowMs
}); });
app.use(fileUpload({
limits: { fileSize: 512 * 1024 }
}));
app.use(cors()); app.use(cors());
app.use(bodyParser.json()); /* https://github.com/github/fetch/issues/323#issuecomment-331477498 */ app.use(bodyParser.json()); /* https://github.com/github/fetch/issues/323#issuecomment-331477498 */
app.use(bodyParser.urlencoded({ extended: true })); 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("/configs", (req, res) => {return res.send(bds.get_config());});
app.get("/info", (req, res) => { app.get("/info", (req, res) => {
const config = bds.get_config() 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 = { var json_http = {
"server": { "server": {
"bds_config_version": bds.bds_config.version, "bds_config_version": bds.bds_config.version,
@ -40,7 +37,6 @@ function api(port_api){
"whitelist": config.white_list, "whitelist": config.white_list,
"xbox": config.online_mode, "xbox": config.online_mode,
"max_players": config.max_players, "max_players": config.max_players,
...java
}, },
"running": bds.detect(), "running": bds.detect(),
"bds_platform": bds.bds_plataform, "bds_platform": bds.bds_plataform,
@ -136,23 +132,20 @@ function api(port_api){
"message": EMN "message": EMN
}) })
}); });
app.post("/bds_command", (req, res) => { app.post("/upload_world", (req, res) => {
const body = req.body var pass = token_verify(req.headers.token)
var pass = token_verify(body.token)
if (pass){ if (pass){
const command = body.command var fileWorld;
const teste = bds.command(command) console.log(req.files);
res.send({ if (!req.files || Object.keys(req.files).length === 0) return res.status(400).send("No files were uploaded.");
"status": 200, let files = Object.getOwnPropertyNames(req.files)
"command": body.command, for (let file in files){
"log": teste, fileWorld = req.files[files[file]];
"message": `authorized to ${body.token}` // Use the mv() method to place the file somewhere on your server
}) console.log(fileWorld.data);
}
} else { } else {
res.send({ return res.status(400).send("Token is not valid!");
"status": 401,
"message": "not authorized"
})
} }
}); });
const port = (port_api||1932) const port = (port_api||1932)

View File

@ -3,7 +3,9 @@ const Storage = localStorage;
const {exec, execSync} = require("child_process"); const {exec, execSync} = require("child_process");
const fs = require("fs") const fs = require("fs")
const path = require("path") 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 = () => { module.exports.start = () => {
function KickPlayer(player){ function KickPlayer(player){
@ -39,43 +41,6 @@ module.exports.start = () => {
...process.env, ...process.env,
LD_LIBRARY_PATH: bds.bds_dir_bedrock LD_LIBRARY_PATH: bds.bds_dir_bedrock
}, cwd: bds.bds_dir_bedrock}); }, cwd: bds.bds_dir_bedrock});
} 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 (bds.system == "windows"){
require("open")("http://docs.sirherobrine23.com/bds_maneger_api_java#Windows");
console.log("http://docs.sirherobrine23.com/bds_maneger_api_java#Windows")
} else if (bds.system === "linux"){
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");
console.log("http://docs.sirherobrine23.com/scripts/_java")
}
}
}
Storage.setItem("old_log_file", bds.log_file)
start_server.stdout.on("data", function(data){
if (data.includes("agree", "EULA")){
const path = require("path");
require("open")("https://account.mojang.com/documents/minecraft_eula");
const eula_file = path.join(bds.bds_dir_java, "eula.txt")
fs.writeFileSync(eula_file, fs.readFileSync(eula_file, "utf8").replace("eula=false", "eula=true"))
if (process.argv[0].includes("node")){
console.warn("Ending the process")
setTimeout(() => {
process.exit(0)
}, 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){ start_server.stdout.on("data", function(data){
data = data.split("\n") data = data.split("\n")
var username; var username;
@ -138,9 +103,60 @@ module.exports.start = () => {
} }
} }
}) })
} else if (bds.bds_config.bds_platform === "java"){ } else if (process.platform === "darwin") throw Error("We don't have MacOS support yet")
console.log("Java is not yet supported the user list"); else process.exit(210)
} 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");
console.log("http://docs.sirherobrine23.com/bds_maneger_api_java#Windows")
} else if (bds.system === "linux"){
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#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")){
const path = require("path");
require("open")("https://account.mojang.com/documents/minecraft_eula");
const eula_file = path.join(bds.bds_dir_java, "eula.txt")
fs.writeFileSync(eula_file, fs.readFileSync(eula_file, "utf8").replace("eula=false", "eula=true"))
if (process.argv[0].includes("node")){
console.warn("Ending the process")
setTimeout(() => {
process.exit(0)
}, 1000);
}
}
});
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 = ""} 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}) 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); Storage.setItem("bds_status", true);

View File

@ -6,7 +6,9 @@ function bds_config(json_config){
var Server_Config; var Server_Config;
if (bds.platform === "java") Server_Config = path.join(bds.bds_dir_java, "server.properties"); 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 var CPU
if (2 < cpuCount - 2) CPU = cpuCount - 2; if (2 < cpuCount - 2) CPU = cpuCount - 2;
@ -18,8 +20,8 @@ function bds_config(json_config){
// //
var var
description_name = "Dedicated Server", description_name = "A minecraft server",
level_name = "Bedrock level", level_name = "Minecraft World",
gamemode = "survival", gamemode = "survival",
difficulty = "easy", difficulty = "easy",
allow_cheats = false, allow_cheats = false,
@ -29,7 +31,8 @@ function bds_config(json_config){
server_port = 19132, server_port = 19132,
server_portv6 = 19133, server_portv6 = 19133,
player_permission = "member", player_permission = "member",
tick = 0 tick = 0,
hardcore;
if (config.description !== undefined) description_name = config.description; if (config.description !== undefined) description_name = config.description;
@ -91,7 +94,9 @@ server-authoritative-block-breaking=false
# Created on Bds-Manager by Sirherobrine23` # 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 config_file_content = `enable-jmx-monitoring=false
rcon.port=25575 rcon.port=25575
level-seed= level-seed=
@ -101,7 +106,7 @@ enable-query=true
generator-settings= generator-settings=
level-name=${level_name} level-name=${level_name}
motd=${description_name} motd=${description_name}
query.port=${server_port} query.port=${server_port+1}
pvp=true pvp=true
generate-structures=true generate-structures=true
difficulty=${difficulty} difficulty=${difficulty}
@ -128,7 +133,7 @@ rcon.password=25as65d3
player-idle-timeout=0 player-idle-timeout=0
force-gamemode=false force-gamemode=false
rate-limit=0 rate-limit=0
hardcore=false hardcore=${hardcore}
white-list=${white_list} white-list=${white_list}
broadcast-console-to-ops=true broadcast-console-to-ops=true
spawn-npcs=true spawn-npcs=true
@ -144,10 +149,39 @@ spawn-protection=16
max-world-size=29999984 max-world-size=29999984
# #
# Created on Bds-Manager by Sirherobrine23` # Created on Bds-Manager by Sirherobrine23`
} } else if (bds.platform === "pocketmine") {
// console.log(config_file_content); hardcore = "off"
fs.writeFileSync(Server_Config, config_file_content); if (gamemode === "survival") gamemode = 0
return true 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(){ function bds_get_config(){
var fs = require("fs"); var fs = require("fs");

View File

@ -1,10 +1,13 @@
var AdmZip = require("adm-zip"); var AdmZip = require("adm-zip");
const { warn } = require("console"); const { warn } = require("console");
const {writeFileSync, existsSync, readFileSync} = require("fs"); const {writeFileSync, existsSync, readFileSync, readdirSync} = require("fs");
const { join } = require("path"); const { join, resolve } = require("path");
const {bds_config, bds_dir_bedrock, bds_dir_java, platform_version_update, valid_platform} = require("../index") 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) { 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 === "") version="latest"
if (version === undefined) version="latest" if (version === undefined) version="latest"
const server_platform = bds_config.bds_platform 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); if (process.env.BDS_DOCKER_IMAGE === "true") process.exit(0);
} }
} else throw Error("Java not suported") } 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") } else throw Error("Bds maneger Config file error")
}).catch(function (err){if (err) throw err;}) } catch (error) {
console.error(error);
}
} }