Last active
October 11, 2024 15:01
-
-
Save stijnb1234/a72cfe8667c5ee50997ef79913b6cb6b to your computer and use it in GitHub Desktop.
Auto-update PaperMc start script for testserver
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # NOTE: Requires jq to be installed (Ubuntu: sudo apt install jq -y) | |
| # Change Minecraft version and amount of RAM to use here! | |
| MC_VERSION="1.21.1" | |
| MEMORY="5G" | |
| ## DO NOT TOUCH BELOW ## | |
| # Set the title for the console | |
| echo -e "\033]0;Minecraft Server Console [Testserver]\007" | |
| clear | |
| # Variables | |
| PAPER_API="https://api.papermc.io/v2/projects/paper/versions/$MC_VERSION" | |
| LATEST_BUILD=$(curl -s "$PAPER_API" | jq -r '.builds[-1]') | |
| JAR_FILE="paper-$MC_VERSION-$LATEST_BUILD.jar" | |
| # Check if the jar file already exists | |
| if [ ! -f "$JAR_FILE" ]; then | |
| echo "Downloading the latest PaperSpigot build ($LATEST_BUILD) for Minecraft $MC_VERSION..." | |
| # Build URL for the latest jar | |
| PAPER_JAR_URL="$PAPER_API/builds/$LATEST_BUILD/downloads/paper-$MC_VERSION-$LATEST_BUILD.jar" | |
| # Download the latest build and save it with the correct name | |
| curl -o "$JAR_FILE" "$PAPER_JAR_URL" | |
| echo "Downloaded PaperSpigot build $LATEST_BUILD." | |
| else | |
| echo "You already have the latest PaperSpigot build ($LATEST_BUILD) for Minecraft $MC_VERSION." | |
| fi | |
| # Start the Spigot server using the latest jar file | |
| java -Xms128M -Xmx$MEMORY -jar "$JAR_FILE" nogui | |
| # Pause the script after server exit | |
| read -rsp $'Press any key to continue...\n' -n1 key |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment