Wouldn’t it be nice to be able to install the latest server with mcsm install? Or create a new world and load it, automatically backing up your current world first, by running mcsm switch my_new_world? I thought so, which is why I wrote this script.

Requirements

Even though I designed this script for my personal use, I’m sharing it because I think it might be helpful for others, but it does make quite a few assumptions:

  • This script is run using Python 3.7+ (some slightly older versions may work)
  • This script is run on Linux (or maybe macOS)
  • This script is run from the same machine as the server
  • The JRE used is on the path as java
  • There is a single server
  • The server executable is named server.jar
  • tmux is installed and available on the path as tmux
  • The server runs in a tmux session
  • The server is located in /srv/minecraft (editable under “File locations”)

It supports managing EssentialsX warps attached to multiple worlds and promoting players using LuckPerms. I use it with Paper, but it should also work with Spigot/Bukkit and maybe even Vanilla.

Getting started

  1. Download mcsm.py (last updated 2020-06-14)
  2. Copy it to the directory of your server
  3. Configure the file locations by editing the variables at the top of the file
  4. Make it executable with chmod +x mcsm.py
  5. Run ./mcsm.py help to get the following information:
update

    Download a Paper server JAR.
    If no version is specified, the latest version is used.
    NOTE: This restarts the server. To prevent this, use -q.

start

    Start running the server.

stop

    Stop the running server.

restart

    Stop the server (if it is running) and then start it.

reload

    Reload the running server.

promote

    Promote a player to the next role in the hierarchy.

attach

    Open the server console.

clean

    Delete old files to free up space.

backup

    Create a backup of one or more worlds.
    If no world names are specified, the currently loaded world name is used.

restore

    Restore a world.
    If no world name is specified, the currently loaded world name is used.

switch

    Switch to a different world.
    Requires the name of a world and optionally a seed for new worlds.
    This stops and restarts the server. To skip, use -q.
    This backs up the currently loaded world first. To skip, use -k.

help

    View a list of commands.

Other versions

  • If you like web interfaces and opening security holes to make things work (which I welcome PRs to fix), you may be interested in a PHP interface that preceded this script.
  • If you thirst after compiled binaries and/or Rust, you may be interested in the Rust CLI iteration, which eventually led to this script so that I could iterate it faster as I identified new tasks I needed the script to handle.