2024-01-31 15:43:03 +03:00
|
|
|
delete_server() {
|
|
|
|
shopt -s nullglob
|
|
|
|
|
|
|
|
if [ -f "server.jar" ]; then
|
|
|
|
rm "server.jar"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2024-01-31 19:29:11 +03:00
|
|
|
get_paper_server() {
|
|
|
|
if [[ -z "$MC_VERSION" ]]; then
|
2024-08-31 17:34:46 +03:00
|
|
|
MC_VERSION="1.20"
|
2024-01-31 19:29:11 +03:00
|
|
|
fi
|
2024-08-31 15:21:46 +03:00
|
|
|
|
2024-01-31 19:29:11 +03:00
|
|
|
majorVersion=$MC_VERSION
|
2024-02-15 17:14:36 +03:00
|
|
|
PAPER_BUILD_JSON=$(curl -X GET -s "https://api.papermc.io/v2/projects/paper/versions/${MC_VERSION}/builds")
|
2024-01-31 19:29:11 +03:00
|
|
|
PAPER_BUILD_FILENAME=$(jq -n "$PAPER_BUILD_JSON" | jq -jc '.builds[-1].downloads.application.name')
|
|
|
|
PAPER_BUILD_NUMBER=$(jq -n "$PAPER_BUILD_JSON" | jq '.builds[-1].build')
|
|
|
|
PAPER_BUILD_DOWNLOAD_URL="https://api.papermc.io/v2/projects/paper/versions/${MC_VERSION}/builds/${PAPER_BUILD_NUMBER}/downloads/${PAPER_BUILD_FILENAME}"
|
|
|
|
|
|
|
|
delete_server
|
|
|
|
|
|
|
|
wget --quiet -O server.jar -T 60 $PAPER_BUILD_DOWNLOAD_URL
|
|
|
|
}
|
|
|
|
|
2024-01-30 20:39:50 +03:00
|
|
|
get_pufferfish_server() {
|
2024-01-31 13:28:24 +03:00
|
|
|
if [[ -z "$MC_VERSION" ]]; then
|
2024-08-31 17:16:26 +03:00
|
|
|
MC_VERSION="1.20"
|
2024-01-30 20:39:50 +03:00
|
|
|
fi
|
2024-08-31 15:21:46 +03:00
|
|
|
|
2024-01-30 20:39:50 +03:00
|
|
|
majorVersion=$MC_VERSION
|
|
|
|
PUFFERFISH_BUILD_JSON=$(curl -X GET -s "https://ci.pufferfish.host/job/Pufferfish-${majorVersion}/lastSuccessfulBuild/api/json")
|
|
|
|
PUFFERFISH_BUILD_URL=$(jq -n "$PUFFERFISH_BUILD_JSON" | jq -jc '.url // empty' )
|
|
|
|
PUFFERFISH_BUILD_FILENAME=$(jq -n "$PUFFERFISH_BUILD_JSON" | jq -jc '.artifacts[].fileName // empty' )
|
|
|
|
PUFFERFISH_BUILD_DOWNLOAD_URL="${PUFFERFISH_BUILD_URL}artifact/build/libs/${PUFFERFISH_BUILD_FILENAME}"
|
|
|
|
|
2024-01-31 15:43:03 +03:00
|
|
|
delete_server
|
2024-01-30 20:39:50 +03:00
|
|
|
|
2024-01-31 13:28:24 +03:00
|
|
|
wget --quiet -O server.jar -T 60 $PUFFERFISH_BUILD_DOWNLOAD_URL
|
|
|
|
}
|
|
|
|
|
2024-01-31 15:43:03 +03:00
|
|
|
get_purpur_server() {
|
|
|
|
if [[ -z "$MC_VERSION" ]]; then
|
2024-08-31 17:34:46 +03:00
|
|
|
MC_VERSION="1.20"
|
2024-01-31 13:28:24 +03:00
|
|
|
fi
|
|
|
|
|
2024-01-31 15:43:03 +03:00
|
|
|
PURPUR_BUILD_DOWNLOAD_URL="https://api.purpurmc.org/v2/purpur/${MC_VERSION}/latest/download"
|
|
|
|
|
|
|
|
delete_server
|
|
|
|
|
|
|
|
wget --quiet -O server.jar -T 60 $PURPUR_BUILD_DOWNLOAD_URL
|
2024-01-31 13:28:24 +03:00
|
|
|
}
|
|
|
|
|
2024-08-31 15:21:46 +03:00
|
|
|
get_custom_server() {
|
|
|
|
if [[ -z "$CUSTOM_BUILD_URL" ]]; then
|
|
|
|
get_paper_server
|
|
|
|
else
|
2024-08-31 15:22:17 +03:00
|
|
|
delete_server
|
2024-08-31 15:21:46 +03:00
|
|
|
wget --quiet -O server.jar -T 60 $CUSTOM_BUILD_URL
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2024-01-31 13:28:24 +03:00
|
|
|
get_server() {
|
|
|
|
if [[ -z "$MC_SERVER" ]]; then
|
2024-08-31 15:21:46 +03:00
|
|
|
MC_SERVER="paper"
|
2024-01-31 13:28:24 +03:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ "$MC_SERVER" = "pufferfish" ]]; then
|
|
|
|
get_pufferfish_server
|
|
|
|
fi
|
2024-01-31 15:43:03 +03:00
|
|
|
if [[ "$MC_SERVER" = "purpur" ]]; then
|
|
|
|
get_purpur_server
|
|
|
|
fi
|
2024-01-31 19:29:11 +03:00
|
|
|
if [[ "$MC_SERVER" = "paper" ]]; then
|
|
|
|
get_paper_server
|
|
|
|
fi
|
2024-08-31 15:21:46 +03:00
|
|
|
if [[ "$MC_SERVER" = "custom" ]]; then
|
|
|
|
get_custom_server
|
|
|
|
fi
|
2024-01-30 20:39:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if [[ ! -e "/localcache/conf-saved.txt" ]]; then
|
|
|
|
cp -R /mcfiles /usr/src/
|
|
|
|
touch /localcache/conf-saved.txt
|
|
|
|
fi
|
|
|
|
|
|
|
|
cd /usr/src/mcfiles/ || exit
|
|
|
|
|
2024-01-31 13:28:24 +03:00
|
|
|
if [[ ! -e "server.jar" ]]; then
|
|
|
|
get_server
|
2024-01-30 20:39:50 +03:00
|
|
|
else
|
|
|
|
if [[ "$FORCE_REINSTALL" -eq 1 ]]; then
|
2024-01-31 13:28:24 +03:00
|
|
|
get_server
|
2024-01-30 20:39:50 +03:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -z "$RAM" ]]; then
|
|
|
|
RAM="1G"
|
|
|
|
fi
|
|
|
|
|
2024-02-01 10:59:03 +03:00
|
|
|
mkdir -p plugins
|
|
|
|
|
|
|
|
if [[ "$SUPPORT_BEDROCK" -eq 1 ]]; then
|
|
|
|
if [[ ! -e "plugins/geyser.jar" ]]; then
|
|
|
|
GEYSER_BUILD_DOWNLOAD_URL="https://download.geysermc.org/v2/projects/geyser/versions/latest/builds/latest/downloads/spigot"
|
|
|
|
|
|
|
|
wget --quiet -O plugins/geyser.jar -T 60 $GEYSER_BUILD_DOWNLOAD_URL
|
|
|
|
fi
|
|
|
|
if [[ ! -e "plugins/floodgate.jar" ]]; then
|
|
|
|
FLOODGATE_BUILD_DOWNLOAD_URL="https://download.geysermc.org/v2/projects/floodgate/versions/latest/builds/latest/downloads/spigot"
|
|
|
|
|
|
|
|
wget --quiet -O plugins/floodgate.jar -T 60 $FLOODGATE_BUILD_DOWNLOAD_URL
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2024-01-31 13:28:24 +03:00
|
|
|
java -Xms$RAM -Xmx$RAM -XX:+AlwaysPreTouch -XX:+DisableExplicitGC -XX:+ParallelRefProcEnabled -XX:+PerfDisableSharedMem -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:G1HeapRegionSize=8M -XX:G1HeapWastePercent=5 -XX:G1MaxNewSizePercent=40 -XX:G1MixedGCCountTarget=4 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1NewSizePercent=30 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:G1ReservePercent=20 -XX:InitiatingHeapOccupancyPercent=15 -XX:MaxGCPauseMillis=200 -XX:MaxTenuringThreshold=1 -XX:SurvivorRatio=32 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true -jar server.jar nogui
|
2024-01-30 20:39:50 +03:00
|
|
|
|
2024-02-15 17:14:36 +03:00
|
|
|
sleep 10
|