Giter Site home page Giter Site logo

alfaridi / minecraft-bedrock-server-bridge Goto Github PK

View Code? Open in Web Editor NEW

This project forked from macchie/minecraft-bedrock-server-bridge

0.0 1.0 0.0 4.58 MB

Minecraft Bedrock Server Bridge

License: Apache License 2.0

TypeScript 95.61% Dockerfile 4.39%

minecraft-bedrock-server-bridge's Introduction

Docker Pulls GitHub Issues

Minecraft Bedrock Server Bridge

RCON replacement for Minecraft Bedrock Dedicated Servers.

Currently allows you to bridge your server console to a Telegram Bot.

Setup

Create a Telegram Bot and obtain the Token

Extend your itzg/docker-minecraft-bedrock-server docker-compose.yml file to produce something similar:

version: '3.4'

services:
  bds:
    image: itzg/minecraft-bedrock-server
    environment:
      EULA: "TRUE"
      GAMEMODE: creative
      SERVER_NAME: Your Server Name
    ports:
      - 19132:19132/udp
#      - 39133:39133/udp
    volumes:
      - /path/to/your/data:/data
    labels:
      minecraft_bedrock_server: "true"
    stdin_open: true
    tty: true
    sysctls:
      net.ipv4.ip_local_port_range: 39132 39133
  
  bds_bridge:
    image: macchie/minecraft-bedrock-server-bridge
    environment:
      - TELEGRAM_BOT_TOKEN=12345
      - TELEGRAM_BOT_ADMINS=username1,username2
    volume:
      - /var/run/docker.sock:/var/run/docker.sock

Make sure you set your Server with:

stdin_open: true
tty: true
labels:
  minecraft_bedrock_server: "true"

Remeber to set stdin_open and tty, these two properties allows you attach to the Docker container to run commands through the console.

Add a minecraft_bedrock_server label under the labels list (value is not important) to flag this container so that the bridge can succesfully discover it.

Also, add a new bds_bridge service and set TELEGRAM_BOT_TOKEN and TELEGRAM_BOT_ADMINS:

bds_bridge:
  image: macchie/minecraft-bedrock-server-bridge
  environment:
    - TELEGRAM_BOT_TOKEN=12345
    - TELEGRAM_BOT_ADMINS=username1,username2
  volume:
    - /var/run/docker.sock:/var/run/docker.sock

Configuration

Configuration is achieved via environment variables on your bridge container, here is a list of available env variables:

  • BDS_CONTAINER_LABEL - used to change the Docker container label (optional, default: minecraft_bedrock_server)
  • TELEGRAM_BOT_TOKEN - your Telegram BOT token, if set enables Telegram BOT (default: null)
  • TELEGRAM_BOT_ADMINS - a comma separated list of Telegram usernames that will be able to communicate with the BOT (optional, default: null)
  • ENABLE_API - enables experimental HTTP API support (optional, default: false)
  • API_TOKEN - if set the token will be checked to authenticate the request (optional, default: null)
  • API_PORT - used to change the HTTP API port (optional, default: 17394)

How To Use

Using Telegram BOT

Open Telegram and send a message to your bot, every message is passed to the Server console.

For example, to say something to all players you can text (you can send you messages with or without the / character):

  • say Hello World!

or execute any other command:

  • /give username diamond_block
  • daylock

The command response will be texted back to you by the BOT, if the command generates no output a confirmation of execution is sent back.

Using HTTP API

First you need to expose the port, to do this edit your docker-compose.yml file and add the HTTP API port:

bds_bridge:
  image: macchie/minecraft-bedrock-server-bridge
  environment:
    - TELEGRAM_BOT_TOKEN=12345
    - TELEGRAM_BOT_ADMINS=username1,username2
  # add the ports entry
  ports:
    - 17394:17394
  volume:
    - /var/run/docker.sock:/var/run/docker.sock

The HTTP API exposes a single /execute endpoint, the request is made in standard JSON format, here is an example via CURL (any HTTP client is valid):

$ curl -L -X POST 'http://<your-server-address>:17394/execute' \
    -H 'Content-Type: application/json' \
    --data-raw '{ "command": "say Hello World!" }'
$ curl -L -X POST 'http://<your-server-address>:17394/execute' \
    -H 'Content-Type: application/json' \
    --data-raw '{ "command": "/give username diamond_block" }'

The HTTP API response is also in standard JSON format and looks like this:

{
  "status":200,
  "response":"There are 0/10 players online:"
}

minegen.js example script

After enabling your HTTP API you can send commands to your server with simple HTTP requests, this allows you to script command execution. Inside the examples/ folder you will find a simple JavaScript file that creates auto-generated fill commands from a .json input source.

Here is an example of what you can achieve:

To test this structure on your server use this syntax:

# 
./minegen.js INPUT_FILE [START_X, optional] [START_Y, optional] [START_Z, optional]

# example (defaults on server 127.0.0.1:17394)
./minegen.js test.json 0 64 0

# example (defaults on server 127.0.0.1:17394)
SERVER_IP=localhost SERVER_PORT=17394 ./minegen.js test.json 0 64 0

Notes

To-Do

  • add minegen.js json format info
  • Add Web Panel ?

minecraft-bedrock-server-bridge's People

Contributors

macchie avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.