Executable
+124
@@ -0,0 +1,124 @@
|
||||
#!/usr/bin/env bash
|
||||
# Compile le plugin, configure le serveur de dev, puis lance Hytale.
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
cd "$ROOT"
|
||||
|
||||
JAVA_HOME="/usr/lib/jvm/java-25-openjdk"
|
||||
export JAVA_HOME
|
||||
export PATH="$JAVA_HOME/bin:$PATH"
|
||||
|
||||
GRADLE_PROPS="$ROOT/gradle.properties"
|
||||
HYTALE_PROPS="$ROOT/hytale.properties"
|
||||
GRADLE_ARGS=()
|
||||
|
||||
read_property() {
|
||||
local file="$1"
|
||||
local key="$2"
|
||||
if [[ -f "$file" ]]; then
|
||||
grep -E "^${key}=" "$file" 2>/dev/null | tail -1 | cut -d= -f2- | tr -d '\r' || true
|
||||
fi
|
||||
}
|
||||
|
||||
find_assets_zip() {
|
||||
local home="$1"
|
||||
[[ -z "$home" || ! -d "$home" ]] && return 1
|
||||
|
||||
local candidates=(
|
||||
"$home/install/release/package/game/latest/Assets.zip"
|
||||
"$home/Assets.zip"
|
||||
)
|
||||
local path
|
||||
for path in "${candidates[@]}"; do
|
||||
if [[ -f "$path" && -s "$path" ]]; then
|
||||
echo "$path"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
find "$home" -name "Assets.zip" -size +1M 2>/dev/null | head -1
|
||||
}
|
||||
|
||||
detect_hytale_home() {
|
||||
local candidates=(
|
||||
"${HYTALE_HOME:-}"
|
||||
"$(read_property "$HYTALE_PROPS" "hytale.home_path")"
|
||||
"$(read_property "$GRADLE_PROPS" "hytale.home_path")"
|
||||
"$HOME/.var/app/com.hypixel.HytaleLauncher/data/Hytale"
|
||||
"$HOME/.local/share/Hytale"
|
||||
"$HOME/AppData/Roaming/Hytale"
|
||||
)
|
||||
local candidate assets
|
||||
for candidate in "${candidates[@]}"; do
|
||||
[[ -z "$candidate" ]] && continue
|
||||
assets="$(find_assets_zip "$candidate" || true)"
|
||||
if [[ -n "$assets" ]]; then
|
||||
echo "$candidate"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
ensure_hytale_home_path() {
|
||||
local home
|
||||
home="$(detect_hytale_home || true)"
|
||||
|
||||
if [[ -z "$home" ]]; then
|
||||
echo "Erreur: Assets.zip introuvable (fichier vide ou installation absente)." >&2
|
||||
echo "" >&2
|
||||
echo "Le serveur a besoin des assets du jeu Hytale. Configurez le chemin :" >&2
|
||||
echo "" >&2
|
||||
echo " cp hytale.properties.example hytale.properties" >&2
|
||||
echo " # puis éditez hytale.home_path=/chemin/vers/Hytale" >&2
|
||||
echo "" >&2
|
||||
echo " Ou : export HYTALE_HOME=/chemin/vers/Hytale" >&2
|
||||
echo " Ou : ajoutez hytale.home_path=... dans gradle.properties" >&2
|
||||
echo "" >&2
|
||||
echo "Le dossier doit contenir install/.../Assets.zip (via le launcher Hytale)." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
local assets
|
||||
assets="$(find_assets_zip "$home")"
|
||||
echo "Hytale: $home"
|
||||
echo "Assets: $assets"
|
||||
|
||||
GRADLE_ARGS+=("-Phytale.home_path=$home")
|
||||
|
||||
if [[ ! -f "$HYTALE_PROPS" ]] || [[ "$(read_property "$HYTALE_PROPS" "hytale.home_path")" != "$home" ]]; then
|
||||
echo "hytale.home_path=$home" > "$HYTALE_PROPS"
|
||||
echo "Enregistré dans hytale.properties"
|
||||
fi
|
||||
}
|
||||
|
||||
reset_devserver_if_needed() {
|
||||
if [[ "${HYTALE_RESET_DEVSERVER:-}" == "1" && -d "$ROOT/devserver" ]]; then
|
||||
echo "HYTALE_RESET_DEVSERVER=1 : suppression de devserver/"
|
||||
rm -rf "$ROOT/devserver"
|
||||
fi
|
||||
}
|
||||
|
||||
run_gradle() {
|
||||
"$ROOT/gradlew" --stop 2>/dev/null || true
|
||||
"$ROOT/gradlew" "${GRADLE_ARGS[@]}" "$@"
|
||||
}
|
||||
|
||||
if [[ ! -d "$JAVA_HOME" ]]; then
|
||||
echo "Erreur: JDK introuvable: $JAVA_HOME" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "JAVA_HOME=$JAVA_HOME ($("$JAVA_HOME/bin/java" -version 2>&1 | head -1))"
|
||||
ensure_hytale_home_path
|
||||
reset_devserver_if_needed
|
||||
|
||||
echo "Configuration du serveur de dev..."
|
||||
run_gradle setupServer
|
||||
|
||||
echo "Compilation..."
|
||||
run_gradle build
|
||||
|
||||
echo "Démarrage du serveur (logs: devserver/logs/)..."
|
||||
exec "$ROOT/gradlew" "${GRADLE_ARGS[@]}" runServer
|
||||
Reference in New Issue
Block a user