From 01d48e8408933771fb3cef0f970d1b520cabc3b1 Mon Sep 17 00:00:00 2001 From: Clarth Date: Tue, 23 Jan 2024 14:01:05 -0500 Subject: [PATCH] Add Minecraft/Java/get_paper_url.sh --- Minecraft/Java/get_paper_url.sh | 41 +++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 Minecraft/Java/get_paper_url.sh diff --git a/Minecraft/Java/get_paper_url.sh b/Minecraft/Java/get_paper_url.sh new file mode 100644 index 0000000..940638d --- /dev/null +++ b/Minecraft/Java/get_paper_url.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +apiurl="https://papermc.io/api/v2/projects" +paperproject="paper" + +# Get remote build info. +apiurl="https://papermc.io/api/v2/projects" + +# Get list of projects. +remotebuildresponse=$(curl -s "${apiurl}") + +# Get list of Minecraft versions for project. +remotebuildresponseproject=$(curl -s "${apiurl}/${paperproject}") + +# Get latest Minecraft: Java Edition version or user-specified version. +remotebuildmcversion=$(echo "${remotebuildresponseproject}" | jq -r '.versions[-1]') + + +# Check if remotebuildmcversion is set and not empty +if [ -n "${remotebuildmcversion}" ]; then + # Get list of paper builds for specific Minecraft: Java Edition version. + remotebuildresponsemcversion=$(curl -s "${apiurl}/paper/versions/${remotebuildmcversion}") + # Get latest paper build for specific Minecraft: Java Edition version. + remotebuildpaperversion=$(echo "${remotebuildresponsemcversion}" | jq -r '.builds[-1]') + # Get various info about the paper build. + remotebuildresponseversion=$(curl -s "${apiurl}/${paperproject}/versions/${remotebuildmcversion}/builds/${remotebuildpaperversion}") + remotebuildfilename=$(echo "${remotebuildresponseversion}" | jq -r '.downloads.application.name') + remotebuildhash=$(echo "${remotebuildresponseversion}" | jq -r '.downloads.application.sha256') + remotebuildurl="${apiurl}/${paperproject}/versions/${remotebuildmcversion}/builds/${remotebuildpaperversion}/downloads/${remotebuildfilename}" + # Combines Minecraft: Java Edition version and paper build. e.g 1.16.5-456 + remotebuildversion="${remotebuildmcversion}-${remotebuildpaperversion}" + + echo "$remotebuildurl" + echo $remotebuildurl > /home/bots/MCserverURLs/paper_url.txt + +else + echo "Failed to determine the Minecraft version. Please check your input or the PaperMC API response." +fi + + +exit