Skip to content

Commit c11d2a0

Browse files
gothickitty93itzg
andauthored
Add Leaf support (#3470)
Co-authored-by: Geoff Bourne <[email protected]>
1 parent 85648d5 commit c11d2a0

File tree

3 files changed

+73
-1
lines changed

3 files changed

+73
-1
lines changed

docs/types-and-platforms/server-types/paper.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,23 @@ Extra variables:
8585
- `USE_FLARE_FLAGS=false` : set to true to add appropriate flags for the built-in [Flare](https://blog.airplane.gg/flare) profiler
8686
- `PURPUR_DOWNLOAD_URL=<url>` : set URL to download Purpur from custom URL.
8787

88+
### Leaf
89+
90+
A [Leaf server](https://www.leafmc.one/) is a Paper fork focused on performance improvements and low-level optimizations for smoother gameplay.
91+
92+
To use a Leaf server, set the environment variable `TYPE` to `"LEAF"`.
93+
94+
-e TYPE=LEAF
95+
96+
!!! note
97+
98+
The `VERSION` variable is used to select the Minecraft version to run.
99+
To specify a particular Leaf build, use `LEAF_BUILD`.
100+
101+
By default the latest build will be used; however, a specific build number can be selected by setting `LEAF_BUILD`, such as
102+
103+
-e VERSION=1.21.4 -e LEAF_BUILD=441
104+
88105
### Folia
89106

90107
A [Folia server](https://papermc.io/software/folia) can be used by setting the environment variable `TYPE` to "FOLIA".

scripts/start-configuration

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,10 @@ case "${TYPE^^}" in
278278
exec "${SCRIPTS:-/}start-deployCrucible" "$@"
279279
;;
280280

281+
LEAF)
282+
exec "${SCRIPTS:-/}start-deployLeaf" "$@"
283+
;;
284+
281285
*)
282286
logError "Invalid TYPE: '$TYPE'"
283287
logError "Must be: VANILLA, FORGE, BUKKIT, SPIGOT, PAPER, FOLIA, PURPUR, FABRIC, QUILT,"
@@ -286,4 +290,4 @@ case "${TYPE^^}" in
286290
exit 1
287291
;;
288292

289-
esac
293+
esac

scripts/start-deployLeaf

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/bin/bash
2+
3+
# shellcheck source=start-utils
4+
. "${SCRIPTS:-$(dirname "$0")}/start-utils"
5+
set -o pipefail
6+
set -e
7+
isDebugging && set -x
8+
9+
resolveVersion
10+
: "${LEAF_BUILD:=LATEST}"
11+
12+
# Docs at https://api.leafmc.one/docs/swagger-ui/index.html
13+
leafApiUrl="https://api.leafmc.one/v2/projects/leaf"
14+
leafDownloadsPage="https://www.leafmc.one/download"
15+
16+
if ! get --exists "${leafApiUrl}/versions/${VERSION}/builds"; then
17+
logError "Leaf builds do not exist for ${VERSION}"
18+
logError " check ${leafDownloadsPage} for available versions"
19+
logError " and set VERSION accordingly"
20+
exit 1
21+
fi
22+
23+
if [[ "${LEAF_BUILD^^}" == "LATEST" ]]; then
24+
# Get the latest build number from the API, which will be the last object in the builds array
25+
if ! buildNumber=$(
26+
get --json-path '$.builds[-1].build' "${leafApiUrl}/versions/${VERSION}/builds"
27+
); then
28+
logError "failed to list Leaf builds for ${VERSION}"
29+
exit 1
30+
fi
31+
LEAF_BUILD="${buildNumber}"
32+
fi
33+
34+
if ! filename=$(
35+
get --json-path='$.downloads.primary.name' --json-value-when-missing="" "${leafApiUrl}/versions/${VERSION}/builds/${LEAF_BUILD}"
36+
); then
37+
logError "Failed to retrieve download filename"
38+
exit 1
39+
fi
40+
41+
SERVER="/data/$filename"
42+
43+
if ! get --skip-existing --log-progress-each -o "${SERVER}" "${leafApiUrl}/versions/${VERSION}/builds/${LEAF_BUILD}/downloads/${filename}"; then
44+
logError "Failed to download"
45+
exit 1
46+
fi
47+
48+
export FAMILY=SPIGOT
49+
export SERVER
50+
51+
exec "${SCRIPTS:-/}start-spiget" "$@"

0 commit comments

Comments
 (0)