-
Notifications
You must be signed in to change notification settings - Fork 0
/
startserver.sh
72 lines (61 loc) · 2.32 KB
/
startserver.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/sh
set -eu
NEOFORGE_VERSION=21.0.146
# To use a specific Java runtime, set an environment variable named ATM10_JAVA to the full path of java.exe.
# To disable automatic restarts, set an environment variable named ATM10_RESTART to false.
# To install the pack without starting the server, set an environment variable named ATM10_INSTALL_ONLY to true.
INSTALLER="neoforge-$NEOFORGE_VERSION-installer.jar"
NEOFORGE_URL="https://maven.neoforged.net/releases/net/neoforged/neoforge/$NEOFORGE_VERSION/neoforge-$NEOFORGE_VERSION-installer.jar"
pause() {
printf "%s\n" "Press enter to continue..."
read ans
}
if ! command -v "${ATM10_JAVA:-java}" >/dev/null 2>&1; then
echo "Minecraft 1.21 requires Java 21 - Java not found"
pause
exit 1
fi
cd "$(dirname "$0")"
if [ ! -d libraries ]; then
echo "Neoforge not installed, installing now."
if [ ! -f "$INSTALLER" ]; then
echo "No Neoforge installer found, downloading now."
if command -v wget >/dev/null 2>&1; then
echo "DEBUG: (wget) Downloading $FORGE_URL"
wget -O "$INSTALLER" "$FORGE_URL"
else
if command -v curl >/dev/null 2>&1; then
echo "DEBUG: (curl) Downloading $FORGE_URL"
curl -o "$INSTALLER" -L "$FORGE_URL"
else
echo "Neither wget or curl were found on your system. Please install one and try again"
pause
exit 1
fi
fi
fi
echo "Running Neoforge installer."
"${ATM10_JAVA:-java}" -jar "$INSTALLER" -installServer
fi
if [ ! -e server.properties ]; then
printf "allow-flight=true\nmotd=All the Mods 10\nmax-tick-time=180000" > server.properties
fi
if [ "${ATM10_INSTALL_ONLY:-false}" = "true" ]; then
echo "INSTALL_ONLY: complete"
exit 0
fi
JAVA_VERSION=$("${ATM10_JAVA:-java}" -fullversion 2>&1 | awk -F '"' '/version/ {print $2}' | cut -d'.' -f1)
if [ ! "$JAVA_VERSION" -ge 21 ]; then
echo "Minecraft 1.21 requires Java 21 - found Java $JAVA_VERSION"
pause
exit 1
fi
while true
do
"${ATM10_JAVA:-java}" @user_jvm_args.txt @libraries/net/neoforged/neoforge/$NEOFORGE_VERSION/unix_args.txt nogui
if [ "${ATM10_RESTART:-true}" = "false" ]; then
exit 0
fi
echo "Restarting automatically in 10 seconds (press Ctrl + C to cancel)"
sleep 10
done