PaperMC downloads are broken
The current endpoint used by the startup script has been deprecated:
curl https://papermc.io/api/v2/projects/paper/versions/1.21.3
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Endpoint Retired</title><style>@import url(https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&family=Open+Sans:wght@400;600&display=swap);.blurb,.logo{margin-bottom:20px}.blurb,.container{padding:20px;background:#fff;box-shadow:0 4px 6px rgba(0,0,0,.1);border-radius:8px}.blurb,body{text-align:center}.blurb p,p{line-height:1.6}body{font-family:Roboto,sans-serif;display:flex;justify-content:center;align-items:center;height:100vh;margin:0;background-color:#f9f9f9;color:#333}.blurb h2,h1{font-family:'Open Sans',sans-serif;margin-bottom:10px;font-weight:600}.container{max-width:600px}h1{font-size:24px}p{font-family:Roboto,sans-serif;font-size:16px;font-weight:400}.support-link{margin-top:20px;font-size:16px}.blurb a,.support-link a{color:#007bff;text-decoration:none}.blurb a:hover,.support-link a:hover{text-decoration:underline}.blurbs{margin-top:30px}.blurb h2{font-size:20px}.blurb p{font-size:16px;margin:0 0 10px}</style></head><body><div class="container"><div class="logo"><img src="https://papermc.io/assets/logo/256x.png" width="128"></div><h1>Endpoint Retired</h1><p>The endpoint you are trying to reach has been retired and is no longer available.</p><div class="support-link"><p>If you require assistance, please join our <a href="https://discord.gg/papermc" target="_blank">Discord</a>.</p></div><div class="blurbs"><div class="blurb"><h2>Downloads API</h2><p>Documentation is available <a href="https://docs.papermc.io/misc/downloads-api" target="_blank">here</a>.</p></div><div class="blurb"><h2>Maven Repository</h2><p>Documentation is available <a href="https://docs.papermc.io/paper/dev/project-setup#adding-paper-as-a-dependency" target="_blank">here</a>.</p></div></div></div></body></html>
Their API docs have instructions on using their currently supported downloads API: https://docs.papermc.io/misc/downloads-api
This bug results in the PaperMC server version failing to download during script startup.
I'll circle back and propose a fix soon if no one else gets to it. For now I'm going to manually download the release I want so I can get my servers up and running.
Of note, the docs recommend using jq to parse the API responses to get build/version numbers, but jq is currently not present in the image, so that should really get added.
Example of pulling build number for a server version:
root@mc-1-0:/minecraft# curl -s https://api.papermc.io/v2/projects/paper/versions/1.21.3/builds | jq '.builds | map(select(.channel == "default") | .build) | .[-1]'
82
Unfortunately, this would need some error handling around choosing versions for which there are no stable builds yet/builds in the default channel:
root@mc-1-0:/minecraft# curl -s https://api.papermc.io/v2/projects/paper/versions/1.21.4/builds | jq '.builds | map(select(.channel == "default") | .build) | .[-1]'
null
For those builds, you'd need to change the channel to experimental:
root@mc-1-0:/minecraft# curl -s https://api.papermc.io/v2/projects/paper/versions/1.21.4/builds | jq '.builds | map(select(.channel == "experimental") | .build) | .[-1]'
69
You could steal code from their docs to check for it being null, and instead of doing nothing, change the channel to experimental and get the latest build for that: https://docs.papermc.io/misc/downloads-api#downloading-the-latest-stable-build
This seems to work for the actual download:
root@mc-1-0:/minecraft# curl -o paperclip.jar https://api.papermc.io/v2/projects/paper/versions/1.21.4/builds/69/downloads/paper-1.21.4-69.jar
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 48.9M 100 48.9M 0 0 33.3M 0 0:00:01 0:00:01 --:--:-- 33.3M
For anyone else blocked by this, you can manually run a command like this (inside your container) to download the Paper server version you want, as well as the 3 plugins below, then restart your container.
Paper Server
Version 1.21.3 Example
curl -o paperclip.jar https://api.papermc.io/v2/projects/paper/versions/1.21.3/builds/56/downloads/paper-1.21.3-56.jar
Also, since the failed Paper download causes the script to skip the Geyser, Floodgate, and ViaVersion downloads, you'll want to also manually run these to get the latest of those (directly from the script).
Floodgate Plugin
curl -H "Accept-Encoding: identity" -H "Accept-Language: en" -L -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4.212 Safari/537.36" -o /minecraft/plugins/Floodgate-Spigot.jar "https://download.geysermc.org/v2/projects/floodgate/versions/latest/builds/latest/downloads/spigot"
Geyser Plugin
curl -H "Accept-Encoding: identity" -H "Accept-Language: en" -L -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4.212 Safari/537.36" -o /minecraft/plugins/Geyser-Spigot.jar "https://download.geysermc.org/v2/projects/geyser/versions/latest/builds/latest/downloads/spigot"
ViaVersion Plugin
For ViaVersion, you'll need to determine the version to download, which the script does for you. Here's that command
ViaVersion Version Check
curl -k -L -H "Accept-Encoding: identity" -H "Accept-Language: en" -L -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4.212 Safari/537.36" https://ci.viaversion.com/job/ViaVersion/lastBuild/artifact/build/libs/ | grep -P '(?<=href=")ViaVersion[^"]+' -o --max-count=1 | head -n1
ViaVersion Plugin Download
Use that version you get from the previous command to replace the variable at the end of the command below and download the latest ViaVersion (I have put the latest build as of this post in there). Replace with latest version if needed
curl -H "Accept-Encoding: identity" -H "Accept-Language: en" -L -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4.212 Safari/537.36" -o /minecraft/plugins/ViaVersion.jar "https://ci.viaversion.com/job/ViaVersion/lastBuild/artifact/build/libs/ViaVersion-5.2.1-SNAPSHOT.jar"
Again, after downloading all of these into your container, you'll need to restart it to load the new server/plugins.
I too was bamboozled by the API change .. for me all I had to do was change the URL in my php script that outputs the latest paper release
<?php
$version = $argv['1'];
// OLD API URL
//$url = "https://papermc.io/api/v2/projects/paper/versions/".$version."/builds";
$url = "https://api.papermc.io/v2/projects/paper/versions/".$version."/builds";
$counter = 0;
$decode = (json_decode(file_get_contents($url),True)['builds']);
foreach ($decode as $key => $val){
$counter++;
};
$counter--;
$latestName = (json_decode(file_get_contents($url),True)['builds'][$counter]['downloads']['application']['name']);
$latestBuild = (json_decode(file_get_contents($url),True)['builds'][$counter]['build']);
$download = $url."/".$latestBuild."/downloads/".$latestName;
echo ($download);
?>
Edit: The reason for the counter as iirc the change from V1 to V2 reversed the releases sort, and it was always the second last entry (hence the need to count up for each 'builds' section of the API Json output, then down count down 1 to get a valid build)
Could this be why my server crashes about every 5 minutes or so? Never really had this problem before. It just started relatively recently.
Could this be why my server crashes about every 5 minutes or so? Never really had this problem before. It just started relatively recently.
I wouldn’t think so. This bug only should affect downloading new Paper jar files during startup. If your server is crashing after startup, that is something else. You should check the container logs for insight.
I too was bamboozled by the API change .. for me all I had to do was change the URL in my php script that outputs the latest paper release
<?php $version = $argv['1']; // OLD API URL //$url = "https://papermc.io/api/v2/projects/paper/versions/".$version."/builds"; $url = "https://api.papermc.io/v2/projects/paper/versions/".$version."/builds"; $counter = 0; $decode = (json_decode(file_get_contents($url),True)['builds']); foreach ($decode as $key => $val){ $counter++; }; $counter--; $latestName = (json_decode(file_get_contents($url),True)['builds'][$counter]['downloads']['application']['name']); $latestBuild = (json_decode(file_get_contents($url),True)['builds'][$counter]['build']); $download = $url."/".$latestBuild."/downloads/".$latestName; echo ($download); ?>Edit: The reason for the counter as iirc the change from V1 to V2 reversed the releases sort, and it was always the second last entry (hence the need to count up for each 'builds' section of the API Json output, then down count down 1 to get a valid build)
Using a counter is an interesting choice. Their API returns all build numbers for a given server version, so you can just parse the JSON directly to get the newest build, which is what this PR does.
Technically just updating the endpoint would work, but I wanted to also improve the logic used in the script to determine the latest build, which also is the suggested way to do it in Paper’s API docs.
I too was bamboozled by the API change .. for me all I had to do was change the URL in my php script that outputs the latest paper release
<?php $version = $argv['1']; // OLD API URL //$url = "https://papermc.io/api/v2/projects/paper/versions/".$version."/builds"; $url = "https://api.papermc.io/v2/projects/paper/versions/".$version."/builds"; $counter = 0; $decode = (json_decode(file_get_contents($url),True)['builds']); foreach ($decode as $key => $val){ $counter++; }; $counter--; $latestName = (json_decode(file_get_contents($url),True)['builds'][$counter]['downloads']['application']['name']); $latestBuild = (json_decode(file_get_contents($url),True)['builds'][$counter]['build']); $download = $url."/".$latestBuild."/downloads/".$latestName; echo ($download); ?>Edit: The reason for the counter as iirc the change from V1 to V2 reversed the releases sort, and it was always the second last entry (hence the need to count up for each 'builds' section of the API Json output, then down count down 1 to get a valid build)
Using a counter is an interesting choice. Their API returns all build numbers for a given server version, so you can just parse the JSON directly to get the newest build, which is what this PR does.
Technically just updating the endpoint would work, but I wanted to also improve the logic used in the script to determine the latest build, which also is the suggested way to do it in Paper’s API docs.
I'm one for unusual methods haha.
This script I mentioned I literally don't need to know anything except the download URL, probably not the greatest practice as you pointed out and in their Docs .. It is a script only I use though, I get a bit out of my scripts having a bit of a quirky 'personality' to it. If it was something used in a github repo then ofc I'd definitely try and work on best practices since it isn't intended for just me to use
I too was bamboozled by the API change .. for me all I had to do was change the URL in my php script that outputs the latest paper release
<?php $version = $argv['1']; // OLD API URL //$url = "https://papermc.io/api/v2/projects/paper/versions/".$version."/builds"; $url = "https://api.papermc.io/v2/projects/paper/versions/".$version."/builds"; $counter = 0; $decode = (json_decode(file_get_contents($url),True)['builds']); foreach ($decode as $key => $val){ $counter++; }; $counter--; $latestName = (json_decode(file_get_contents($url),True)['builds'][$counter]['downloads']['application']['name']); $latestBuild = (json_decode(file_get_contents($url),True)['builds'][$counter]['build']); $download = $url."/".$latestBuild."/downloads/".$latestName; echo ($download); ?>Edit: The reason for the counter as iirc the change from V1 to V2 reversed the releases sort, and it was always the second last entry (hence the need to count up for each 'builds' section of the API Json output, then down count down 1 to get a valid build)
Using a counter is an interesting choice. Their API returns all build numbers for a given server version, so you can just parse the JSON directly to get the newest build, which is what this PR does. Technically just updating the endpoint would work, but I wanted to also improve the logic used in the script to determine the latest build, which also is the suggested way to do it in Paper’s API docs.
I'm one for unusual methods haha. This script I mentioned I literally don't need to know anything except the download URL, probably not the greatest practice as you pointed out and in their Docs .. It is a script only I use though, I get a bit out of my scripts having a bit of a quirky 'personality' to it. If it was something used in a github repo then ofc I'd definitely try and work on best practices since it isn't intended for just me to use
Makes total sense. Really I just wanted to clarify a bit for folks who stumble upon this later.
Can we expect a solution for this issue to be released soon?
Can we expect a solution for this issue to be released soon?
I’ve got a PR submitted (linked to this issue), but it hasn’t been looked at yet.
I'll go comment to see if it pings the owners of the repo
@TheRemote - Can we get some love on this repo? or maybe give @cyberops7 some access to get these changes merged? Much appreciation for anything you can do.
Encountered this issue as well, thank you for the fixes and hope the PR is merged soon