Skip to main content

Minestrapper is a bootstrapper for Minecraft servers that lets you easily add custom features to your server without needing a full mod/plugin loader.

Project description

Minestrapper

A bootstrapper for Minecraft Java Edition Servers

About

Rather than building full Java plugins or mods, this project lets you tap into the server’s state and other lifecycle events, and add custom functionality directly in Python.

That means small features can be added without the overhead of a mod loader (e.g. Fabric, Forge) or plugin loader (e.g. Paper, Spigot), while keeping the server in its vanilla form.

[!NOTE] Feel free to still use your favorite mods or plugins alongside it if you want! Minestrapper mainly serves for smaller, simpler features.

Current Features

  • Config Handling
    • Contains a class for managing configuration files of both Minestrapper and Minecraft.
    • Minestrapper config uses a file named Config.json in a /minestrapper directory relative to the root of the Minecraft Server.
    • Allows for direct editing of server.properties.
  • State Handling
    • Contains a class for getting the current state of the server based on the server output.
    • Tracks the following states: STARTING, RUNNING, PAUSED, STOPPING, STOPPED.
  • Periodic Callbacks
    • A lifecycle function that runs every 20ms.
    • Used for things that need to happen constantly.
    • Mainly isn't used in preference of lifecycle events.
  • New Line Callbacks
    • A lifecycle function that runs everytime a new line is sent from the Minecraft Server process
  • Logger
    • Prints out stuff both from forwarding logs from the Minecraft process and also custom logs from Minestrapper.
    • Keeps Minestrapper specific logs visually consistent with Minecraft Server logs (e.g. "[19:48:06] [Minestrapper/INFO]: Initialized Minestrapper Logger successfully.")
    • Logs to a file named latest-minestrapper.log and then replaces the vanilla latest.log with it when the server stops.
    • Provides transformers to modify each logged line to the output as needed.
  • Built-in features:
    • "State Styles"
      • Updates the terminal title and text color based on the server's current state.
      • Makes it easier to see whether the server is starting, running, paused, stopping, or stopped.
    • "Server Resource Pack"
      • Includes a lightweight HTTP server for serving a server resource pack.
      • Removes the need for an external hosting site for the pack.
      • Keeps resource pack delivery self-contained within the server setup.

Potential Future Features

  • Backups: Let the owner integrate save backups everytime the server closes locally. It can either be done locally only, with cloud services, or even both.
  • Remote Panels: Allow the owner along with anyone else authorized to remotely turn on and off the server. Only the owner will be able to view logs and run commands however.
  • Custom Commands: Add your own admin commands that can trigger multiple Minecraft commands or even run Python code.

Installation Guide

  1. Install Python at https://www.python.org/ (>=3.1).
  2. Go to your Minecraft Server directory.
  3. Make a directory exactly named minestrapper and change directory to it.
mkdir minestrapper && cd minestrapper
  1. Make a new Python environment.

Windows:

python -m venv .venv

MacOS / Linux:

python3 -m venv .venv
  1. Activate the environment.

Windows:

.\.venv\Scripts\activate

MacOS / Linux:

source .venv/bin/activate
  1. Install the minestrapper package.
pip install minestrapper
  1. Create a file exactly named Config.json and edit to your liking.
{
  "$schema": "https://faizaan-j.github.io/mine-strapper/schemas/Config.schema.json"
}

[!NOTE] The schema will help you fill out the file so it's recommended to use some kind of app that can read JSON schemas to edit the file easier. There are numerous required fields that you must fill out.

  1. Make an entry point file inside the minestrapper directory.

Example:

from pathlib import Path

from minestrapper import Server

if __name__ == "__main__":
    server = Server(path=Path.cwd().parent)
    server.start_server()

    server.wait_loop()

Important Notes

  • You still need to do any necessary port forwarding yourself.

License

MineStrapper is released under the MIT License.
Feel free to use, modify, and share.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

minestrapper-0.3.2.tar.gz (14.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

minestrapper-0.3.2-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

Details for the file minestrapper-0.3.2.tar.gz.

File metadata

  • Download URL: minestrapper-0.3.2.tar.gz
  • Upload date:
  • Size: 14.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.8

File hashes

Hashes for minestrapper-0.3.2.tar.gz
Algorithm Hash digest
SHA256 0b2e232ec511c879338913e2223a5fa0ca4b9a51a0b8d936be2e87f901d9dec5
MD5 3251d8ff4e34694951594e4d57c4dc48
BLAKE2b-256 26b198683d360fccbbf2f8668630309e8e9db57bf0e00dab56a4d39a8b8ec4d8

See more details on using hashes here.

File details

Details for the file minestrapper-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: minestrapper-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 16.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.8

File hashes

Hashes for minestrapper-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8e5745db87e8b64f6bbabecb92241bfb3fa27b3a8af847f107f883df061d67af
MD5 3cc483813bc069aeb442e82513eaca9a
BLAKE2b-256 57583b32a9bd26ca62d66f757b025bff40e0d383012056f340ffa4dad99f822c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page