fix: migrate PaperMC to v3 API, fix NeoForge beta fallback, add test suite
- Migrate Paper loader from sunset v2 API to v3 (fill.papermc.io) - Fix NeoForge: fall back to beta versions when no stable exists (set -e + grep) - Fix setEula/setperms ordering (was writing eula.txt before /data was writable) - Fix setEula/serverInfoWrite to use absolute paths (/data/server/) - Add VOLUME directive removal (was shadowing bind mounts) - Add comprehensive API test suite (110 tests across 6 suites) - Move test.sh to tests/integration.sh, switch to named volumes - Add Docker build cache to CI workflows - Add .editorconfig, expand .gitignore, improve README docs
This commit is contained in:
@@ -1,23 +1,59 @@
|
||||
getPaper() {
|
||||
SERVER_TYPE="Paper Minecraft"
|
||||
if [[ ! -f server.jar ]]; then
|
||||
if [[ -n "${PAPER_BUILD}" ]]; then
|
||||
LATEST_BUILD="${PAPER_BUILD}"
|
||||
else
|
||||
LATEST_BUILD=$(curl -s https://api.papermc.io/v2/projects/${MC_LOADER}/versions/${MC_VERSION}/builds |
|
||||
jq -r '[.builds[] | select(.channel | ascii_upcase == "STABLE")] | .[-1].build')
|
||||
|
||||
if [[ -z "${MC_VERSION}" ]]; then
|
||||
die "MC_VERSION is required for Paper loader"
|
||||
fi
|
||||
|
||||
if [[ -f server.jar ]]; then
|
||||
log "Paper server.jar already exists, skipping download."
|
||||
return
|
||||
fi
|
||||
|
||||
local PAPERMC_URL
|
||||
|
||||
if [[ -n "${PAPER_BUILD}" ]]; then
|
||||
log "Fetching Paper build ${PAPER_BUILD} for MC ${MC_VERSION}..."
|
||||
local BUILD_DATA
|
||||
BUILD_DATA=$(curl -sf --connect-timeout 10 --max-time 30 \
|
||||
-H "User-Agent: dockercraft/1.0" \
|
||||
"https://fill.papermc.io/v3/projects/paper/versions/${MC_VERSION}/builds") || true
|
||||
|
||||
if [[ -n "$BUILD_DATA" ]]; then
|
||||
PAPERMC_URL=$(echo "$BUILD_DATA" | jq -r \
|
||||
"map(select(.id == ${PAPER_BUILD})) | .[0].downloads.\"server:default\".url // empty")
|
||||
fi
|
||||
|
||||
if [ "$LATEST_BUILD" != "null" ]; then
|
||||
JAR_NAME=${MC_LOADER}-${MC_VERSION}-${LATEST_BUILD}.jar
|
||||
PAPERMC_URL="https://api.papermc.io/v2/projects/${MC_LOADER}/versions/${MC_VERSION}/builds/${LATEST_BUILD}/downloads/${JAR_NAME}"
|
||||
if [[ -z "$PAPERMC_URL" ]]; then
|
||||
die "Paper build ${PAPER_BUILD} not found for MC ${MC_VERSION}"
|
||||
fi
|
||||
else
|
||||
log "Querying PaperMC API for latest stable build of ${MC_VERSION}..."
|
||||
local BUILDS_DATA
|
||||
BUILDS_DATA=$(curl -sf --connect-timeout 10 --max-time 30 \
|
||||
-H "User-Agent: dockercraft/1.0" \
|
||||
"https://fill.papermc.io/v3/projects/paper/versions/${MC_VERSION}/builds") || true
|
||||
|
||||
curl -o server.jar "$PAPERMC_URL"
|
||||
echo "Download completed"
|
||||
echo "Minecraft Version: ${MC_VERSION}"
|
||||
echo "Paper Version: ${LATEST_BUILD}"
|
||||
else
|
||||
echo "No stable build for version $MC_VERSION found :("
|
||||
if [[ -z "$BUILDS_DATA" ]]; then
|
||||
die "Could not fetch Paper builds for MC ${MC_VERSION}"
|
||||
fi
|
||||
|
||||
# Check for API error
|
||||
if echo "$BUILDS_DATA" | jq -e '.ok == false' >/dev/null 2>&1; then
|
||||
local ERR_MSG
|
||||
ERR_MSG=$(echo "$BUILDS_DATA" | jq -r '.message // "Unknown error"')
|
||||
die "PaperMC API error: ${ERR_MSG}"
|
||||
fi
|
||||
|
||||
PAPERMC_URL=$(echo "$BUILDS_DATA" | jq -r \
|
||||
'first(.[] | select(.channel == "STABLE") | .downloads."server:default".url) // empty')
|
||||
|
||||
if [[ -z "$PAPERMC_URL" ]]; then
|
||||
die "No stable Paper build found for MC ${MC_VERSION}"
|
||||
fi
|
||||
fi
|
||||
|
||||
log "Downloading Paper for MC ${MC_VERSION}..."
|
||||
curl -fL -o server.jar "$PAPERMC_URL"
|
||||
log "Paper for MC ${MC_VERSION} downloaded."
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user