Last active
July 6, 2024 06:00
-
-
Save nicdgonzalez/c3bb1e3a027354d5f33268d72496ef43 to your computer and use it in GitHub Desktop.
Download PaperMC's server file. Defaults to the latest version.
This file contains 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
#!/usr/bin/bash | |
if [ $1 == "--help" ] || [ $1 == "-h" ]; then | |
echo "USAGE: $(basename "$0") [minecraft_version] [paper_build]" | |
exit 0 | |
fi | |
URL="https://api.papermc.io/v2/projects/paper" | |
if [ $# -lt 1 ]; then | |
echo "Getting latest Minecraft version since \$1 was empty" | |
VERSION=$(curl -SsL ${URL} | jq --raw-output ".versions[-1]") | |
else | |
VERSION="$1" | |
fi | |
echo "- Got Minecraft version: ${VERSION}" | |
URL="${URL}/versions/${VERSION}" | |
if [ $# -lt 2 ]; then | |
echo "Getting latest build for Minecraft ${VERSION} since \$2 was empty" | |
BUILD=$(curl -SsL ${URL} | jq --raw-output ".builds[-1]") | |
else | |
BUILD="$2" | |
fi | |
echo "- Got Paper build: #${BUILD}" | |
URL="${URL}/builds/${BUILD}" | |
echo "Getting JAR name for Minecraft ${VERSION} (#${BUILD}) from '${URL}'..." | |
PAPER_JAR=$(curl -SsL ${URL} | jq --raw-output ".downloads.application.name") | |
echo "- Got file name: '${PAPER_JAR}'" | |
URL="${URL}/downloads/${PAPER_JAR}" | |
FILE="$(pwd)/${PAPER_JAR}" | |
if [ ! -f $FILE ]; then | |
echo "There is no file named '${PAPER_JAR}' in '$(pwd)'" | |
echo "Getting data for '${PAPER_JAR}' from '${URL}'..." | |
curl -SsL ${URL} --output ${FILE} | |
echo "Data successfully written to file '${FILE}'" | |
else | |
echo "File already exists '${FILE}'" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment