1- #! /usr/bin/env bash
2- # TODO: migrate to sh
1+ #! /usr/bin/env sh
32
4- set -Eeuo pipefail
3+ set -eu
54
6- SCRIPT_DIR=$( cd " $( dirname " ${BASH_SOURCE[0]} " ) " & > /dev/null && pwd -P)
5+ SCRIPT_DIR=$( cd " $( dirname " $0 " ) " > /dev/null 2>&1 && pwd -P)
76
87# # Directories
98CONFIG_DIR=" ${SCRIPT_DIR} /config"
@@ -16,10 +15,9 @@ WORLD_DIR="${SCRIPT_DIR}/worlds"
1615# Paper config: https://docs.papermc.io/paper/reference/global-configuration
1716# Aïkar's flags: https://docs.papermc.io/paper/aikars-flags
1817# Paper system properties: https://docs.papermc.io/paper/reference/system-properties
19- HEAP_SIZE=4
20- AIKAR_FLAGS=(
21- -Xms" ${HEAP_SIZE} " G
22- -Xmx" ${HEAP_SIZE} " G
18+ AIKAR_FLAGS="
19+ -Xms4G
20+ -Xmx4G
2321 -XX:+AlwaysPreTouch
2422 -XX:+DisableExplicitGC
2523 -XX:+ParallelRefProcEnabled
@@ -40,32 +38,36 @@ AIKAR_FLAGS=(
4038 -XX:SurvivorRatio=32
4139 -Dusing.aikars.flags=https://mcflags.emc.gs
4240 -Daikars.new.flags=true
43- )
44- PAPER_FLAGS=(
41+ "
42+ PAPER_FLAGS='
4543 -Dnet.kyori.adventure.text.warnWhenLegacyFormattingDetected
4644 -Dpaper.ticklist-warn-on-excessive-delay
4745 -Dpaper.strict-thread-checks
4846 -DPaper.skipServerPropertiesComments
4947 -Dpaper.alwaysPrintWarningState
50- )
51- JVM_ARGUMENTS=(" ${AIKAR_FLAGS[@]} " " ${SPIGOT_FLAGS[@]} " " ${PAPER_FLAGS[@]} " )
48+ '
49+
50+ # Combine all JVM arguments into a single string
51+ JVM_ARGUMENTS=" ${AIKAR_FLAGS} ${PAPER_FLAGS} "
5252
5353# # Server arguments
5454# Spigot start-up parameters: https://www.spigotmc.org/wiki/start-up-parameters/
55- SERVER_ARGS=(
56- --spigot-settings " ${CONFIG_DIR} /spigot.yml"
57- --commands-settings " ${CONFIG_DIR} /commands.yml"
58- --world-dir " ${WORLD_DIR} "
55+ SERVER_ARGS="
56+ --spigot-settings ${CONFIG_DIR} /spigot.yml
57+ --commands-settings ${CONFIG_DIR} /commands.yml
58+ --world-dir ${WORLD_DIR}
5959 --log-strip-color
6060 --nogui
61- )
61+ "
6262
6363cd " ${SCRIPT_DIR} "
6464
6565echo ' Preparing PaperMC server configuration files...'
6666
67- TMP=" $( envsubst ' $EULA' < eula.txt) " && echo " ${TMP} " > eula.txt && echo ' File eula.txt processed'
67+ TMP=" $( envsubst ' $EULA' < eula.txt) "
68+ echo " ${TMP} " > eula.txt
69+ echo ' File eula.txt processed'
6870
6971echo ' PaperMC server ready to start!'
7072
71- java " ${ JVM_ARGUMENTS[@]} " -jar " ${SCRIPT_DIR} " /papermc-server-* .jar " ${ SERVER_ARGS[@]} "
73+ java $ JVM_ARGUMENTS -jar " ${SCRIPT_DIR} " /papermc-server-* .jar $ SERVER_ARGS
0 commit comments