#!/usr/bin/env python3 import pickle import sys import urllib.request from shutil import move import requests """ A python script to download the latest Paper MC build if it hasn't been downloaded yet. You'll need requests installed: pip install requests """ VERSION = '1.15.2' remote_build = int(requests.get(f"https://papermc.io/api/v1/paper/{VERSION}/latest").json()["build"]) try: with open('latest', 'rb') as latest: old_latest = pickle.load(latest) except (FileNotFoundError, EOFError): old_latest = 0 if old_latest >= remote_build: print(f"Already up-to-date, build #{remote_build}") sys.exit(0) try: move('server.jar', 'server_old.jar') except FileNotFoundError: pass download_url = f"https://papermc.io/api/v1/paper/{VERSION}/{remote_build}/download/" print(f"Downloading {download_url}...") r = requests.get(download_url) with open('server.jar', 'wb+') as outfile: outfile.write(r.content) with open('latest', 'wb+') as latest: pickle.dump(remote_build, latest) print(f"Updated to build #{remote_build}")