Python script to grab latest build (and verify hash)

DISCLAIMER
This script is intended to only grab the latest builds from PaperMC API v2. DO NOT AUTOMATE THE UPDATING PROCESS. Don’t use this script to replace your active jar file directly!

All I wanted to do is just grab the latest build to my VPS without having to find the URL for it every time.

That said, it’s always best practice to make sure the latest build runs nicely with your other plugins before deploying to production server.

This script will fetch the latest build jar file and save it as “paper_update.jar” (or any filename you like).
It will also verify the hash against the API provided hash to ensure integrity of the file. The script depends on purely python3 standard libraries, so no installations needed.

You can also switch this to waterfall by changing the commented lines in the VARIABLES section

Open the script updater.py for most up-to-date version. Run ./updater.py or python3 updater.py in your minecraft server folder.

Grab the script: run wget https://raw.githubusercontent.com/jogerj/minecraft-scripts/main/updater.py in your minecraft folder

Edit: code moved to GitHub repo to maintain easier.

Sample Output
$ ./updater.py
[INFO] Selected version: Paper 1.17.1
[INFO] Fetching latest build number... 
[INFO] Fetching latest paper.jar... 
[INFO] SUCCESS! Latest build saved as paper_update.jar
[INFO] Calculating hash...
[INFO] SHA256: eaf24377176971f3a6b0e405ac119fc9b1808ac589634a7bcb9defc9b5baa0da
[INFO] Fetching hash for paper-1.17.1-372.jar
[INFO] SHA256 verification success!

Tested with Python 3.6+