Files
dockercraft/scripts/lib/loaders/neoforge.sh
T
jeremy 5688b30892 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
2026-08-21 12:49:27 -04:00

56 lines
1.9 KiB
Bash

getNeoForge() {
SERVER_TYPE="NeoForge Server"
if [[ -z "${MC_VERSION}" ]]; then
die "MC_VERSION is required for NeoForge loader"
fi
local VER_MINECRAFT DL_URL
VER_MINECRAFT="${MC_VERSION}"
if [[ -n "${NEOFORGE_VERSION}" ]]; then
VER_LOADER="${NEOFORGE_VERSION}"
else
log "Auto-detecting latest NeoForge version for MC ${MC_VERSION}..."
local MC_MINOR ALL_VERSIONS
MC_MINOR="${MC_VERSION#1.}"
ALL_VERSIONS=$(curl -sf --connect-timeout 10 --max-time 30 \
"https://maven.neoforged.net/releases/net/neoforged/neoforge/maven-metadata.xml" |
xmllint --xpath "/metadata/versioning/versions/version/text()" - 2>/dev/null |
tr ' ' '\n' | grep "^${MC_MINOR}\." | sort -V || true)
# Prefer stable versions, fall back to beta/alpha if none exist
VER_LOADER=$(echo "$ALL_VERSIONS" | grep -v -- '-beta\|-alpha' | tail -1 || true)
if [[ -z "$VER_LOADER" ]]; then
VER_LOADER=$(echo "$ALL_VERSIONS" | tail -1)
if [[ -n "$VER_LOADER" ]]; then
warn "No stable NeoForge version for MC ${MC_VERSION}, using ${VER_LOADER}"
fi
fi
if [[ -z "$VER_LOADER" ]]; then
die "Could not auto-detect NeoForge version for MC ${MC_VERSION}"
fi
fi
DL_URL="https://maven.neoforged.net/releases/net/neoforged/neoforge/${VER_LOADER}/neoforge-${VER_LOADER}-installer.jar"
log "Downloading NeoForge ${VER_LOADER} installer..."
rm -f server.jar
curl -fL -o "neoforge-${VER_LOADER}-installer.jar" "${DL_URL}"
log "Running NeoForge installer..."
$JAVA -jar "neoforge-${VER_LOADER}-installer.jar" --installServer --server.jar
mv server.jar "neoforge-${VER_LOADER}.jar"
ln -sf "neoforge-${VER_LOADER}.jar" server.jar
rm -f "neoforge-${VER_LOADER}-installer.jar" \
"neoforge-${VER_LOADER}-installer.jar.log" \
README.txt \
run.bat
touch server.properties
log "NeoForge ${MC_VERSION}-${VER_LOADER} installed."
}