forked from p2r3/bareiron
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextract_registries.sh
More file actions
executable file
·73 lines (62 loc) · 1.61 KB
/
extract_registries.sh
File metadata and controls
executable file
·73 lines (62 loc) · 1.61 KB
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
73
#!/usr/bin/env bash
set -euo pipefail
REQUIRED_MAJOR=21
SERVER_JAR="${SERVER_JAR:-server.jar}"
NOTCHIAN_DIR="notchian"
JS_RUNTIME=""
get_java_version() {
java -version 2>&1 | awk -F[\".] '/version/ {print $2}'
}
check_java() {
if ! command -v java >/dev/null 2>&1; then
echo "Java not found in PATH."
exit 1
fi
local major
major="$(get_java_version)"
if (( major < REQUIRED_MAJOR )); then
echo "Java $REQUIRED_MAJOR or newer required, but found Java $major."
exit 1
fi
}
prepare_notchian_dir() {
if [[ ! -d "$NOTCHIAN_DIR" ]]; then
echo "Creating $NOTCHIAN_DIR directory..."
mkdir -p "$NOTCHIAN_DIR"
fi
cd "$NOTCHIAN_DIR"
}
dump_registries() {
if [[ ! -f "$SERVER_JAR" ]]; then
echo "No server.jar found (looked for $SERVER_JAR)."
echo "Please download the 1.21.8 server.jar (e.g. from https://mcversions.net/download/1.21.8)"
echo "and place it in the \"notchian\" directory."
exit 1
fi
java -DbundlerMainClass="net.minecraft.data.Main" -jar "$SERVER_JAR" --all
}
detect_js_runtime() {
if command -v node >/dev/null 2>&1; then
JS_RUNTIME="node"
elif command -v bun >/dev/null 2>&1; then
JS_RUNTIME="bun"
elif command -v deno >/dev/null 2>&1; then
JS_RUNTIME="deno run"
else
echo "No JavaScript runtime found (Node.js, Bun, or Deno)."
exit 1
fi
}
run_js_script() {
local script="$1"
if [[ -z "$JS_RUNTIME" ]]; then
detect_js_runtime
fi
echo "Running $script with $JS_RUNTIME..."
$JS_RUNTIME "$script"
}
check_java
prepare_notchian_dir
dump_registries
run_js_script "../build_registries.js"
echo "Registry dump and processing complete."