diff --git a/docs/types-and-platforms/server-types/paper.md b/docs/types-and-platforms/server-types/paper.md index c36ce834..12c6311f 100644 --- a/docs/types-and-platforms/server-types/paper.md +++ b/docs/types-and-platforms/server-types/paper.md @@ -85,6 +85,23 @@ Extra variables: - `USE_FLARE_FLAGS=false` : set to true to add appropriate flags for the built-in [Flare](https://blog.airplane.gg/flare) profiler - `PURPUR_DOWNLOAD_URL=` : set URL to download Purpur from custom URL. +### Leaf + +A [Leaf server](https://www.leafmc.one/) is a Paper fork focused on performance improvements and low-level optimizations for smoother gameplay. + +To use a Leaf server, set the environment variable `TYPE` to `"LEAF"`. + + -e TYPE=LEAF + +!!! note + + The `VERSION` variable is used to select the Minecraft version to run. + To specify a particular Leaf build, use `LEAF_BUILD`. + +By default the latest build will be used; however, a specific build number can be selected by setting `LEAF_BUILD`, such as + + -e VERSION=1.21.4 -e LEAF_BUILD=441 + ### Folia A [Folia server](https://papermc.io/software/folia) can be used by setting the environment variable `TYPE` to "FOLIA". diff --git a/scripts/start-configuration b/scripts/start-configuration index 06ff9756..d05837bd 100755 --- a/scripts/start-configuration +++ b/scripts/start-configuration @@ -278,6 +278,10 @@ case "${TYPE^^}" in exec "${SCRIPTS:-/}start-deployCrucible" "$@" ;; + LEAF) + exec "${SCRIPTS:-/}start-deployLeaf" "$@" + ;; + *) logError "Invalid TYPE: '$TYPE'" logError "Must be: VANILLA, FORGE, BUKKIT, SPIGOT, PAPER, FOLIA, PURPUR, FABRIC, QUILT," @@ -286,4 +290,4 @@ case "${TYPE^^}" in exit 1 ;; -esac \ No newline at end of file +esac diff --git a/scripts/start-deployLeaf b/scripts/start-deployLeaf new file mode 100644 index 00000000..b866234e --- /dev/null +++ b/scripts/start-deployLeaf @@ -0,0 +1,51 @@ +#!/bin/bash + +# shellcheck source=start-utils +. "${SCRIPTS:-$(dirname "$0")}/start-utils" +set -o pipefail +set -e +isDebugging && set -x + +resolveVersion +: "${LEAF_BUILD:=LATEST}" + +# Docs at https://api.leafmc.one/docs/swagger-ui/index.html +leafApiUrl="https://api.leafmc.one/v2/projects/leaf" +leafDownloadsPage="https://www.leafmc.one/download" + +if ! get --exists "${leafApiUrl}/versions/${VERSION}/builds"; then + logError "Leaf builds do not exist for ${VERSION}" + logError " check ${leafDownloadsPage} for available versions" + logError " and set VERSION accordingly" + exit 1 +fi + +if [[ "${LEAF_BUILD^^}" == "LATEST" ]]; then + # Get the latest build number from the API, which will be the last object in the builds array + if ! buildNumber=$( + get --json-path '$.builds[-1].build' "${leafApiUrl}/versions/${VERSION}/builds" + ); then + logError "failed to list Leaf builds for ${VERSION}" + exit 1 + fi + LEAF_BUILD="${buildNumber}" +fi + +if ! filename=$( + get --json-path='$.downloads.primary.name' --json-value-when-missing="" "${leafApiUrl}/versions/${VERSION}/builds/${LEAF_BUILD}" +); then + logError "Failed to retrieve download filename" + exit 1 +fi + +SERVER="/data/$filename" + +if ! get --skip-existing --log-progress-each -o "${SERVER}" "${leafApiUrl}/versions/${VERSION}/builds/${LEAF_BUILD}/downloads/${filename}"; then + logError "Failed to download" + exit 1 +fi + +export FAMILY=SPIGOT +export SERVER + +exec "${SCRIPTS:-/}start-spiget" "$@" \ No newline at end of file