$ErrorActionPreference = "Stop" $SCRIPT_DIR = Split-Path -Parent $MyInvocation.MyCommand.Path $BIN_DIR = "$SCRIPT_DIR/.bin" $SERVER_DIR = "$SCRIPT_DIR/server" $SRC_REF_DIR = "$SCRIPT_DIR/src-ref" function detect-os { "windows-amd64.exe" } $OS_SUFFIX = detect-os function download { New-Item -ItemType Directory -Force -Path $BIN_DIR | Out-Null Write-Output "Téléchargement de hytale-downloader..." Invoke-WebRequest -Uri "https://downloader.hytale.com/hytale-downloader.zip" -OutFile "$BIN_DIR/hytale-downloader.zip" Expand-Archive -Path "$BIN_DIR/hytale-downloader.zip" -DestinationPath $BIN_DIR -Force Remove-Item "$BIN_DIR/hytale-downloader.zip" -Force Write-Output "Téléchargement de CFR..." Invoke-WebRequest -Uri "https://www.benf.org/other/cfr/cfr-0.152.jar" -OutFile "$BIN_DIR/cfr-0.152.jar" Write-Output "Téléchargement terminé." } function setup { $DOWNLOADER = "$BIN_DIR/hytale-downloader-$OS_SUFFIX" if (-not (Test-Path $DOWNLOADER)) { Write-Error "Erreur: $DOWNLOADER non trouvé.`nExécutez d'abord: .\setup.ps1 --download" exit 1 } Write-Output "Téléchargement du serveur Hytale..." if (-not (Test-Path $SERVER_DIR)) { New-Item -ItemType Directory -Path $SERVER_DIR | Out-Null } if (-not (Test-Path "$SERVER_DIR/server.zip")) { & $DOWNLOADER --download-path "$SERVER_DIR/server.zip" } Write-Output "Décompression de l'archive du serveur Hytale" Expand-Archive -Path "$SERVER_DIR/server.zip" -DestinationPath $SERVER_DIR -Force Write-Output "Téléchargement terminée." } function update_safe { Write-Output "Are you sure ?" Write-Output "It will delete the old server/Assets.zip server/server.zip server/Server/* " Write-Output "Use ./setup.ps1 --update-sure" } function update { $DOWNLOADER = "$BIN_DIR/hytale-downloader-$OS_SUFFIX" Write-Output "Téléchargement du serveur Hytale..." if (-not (Test-Path $SERVER_DIR)) { New-Item -ItemType Directory -Path $SERVER_DIR | Out-Null } if (Test-Path "$SERVER_DIR/server.zip") { Remove-Item "$SERVER_DIR/server.zip" -Force } if (Test-Path "$SERVER_DIR/Assets.zip") { Remove-Item "$SERVER_DIR/Assets.zip" -Force } if (Test-Path "$SERVER_DIR/Server") { Remove-Item "$SERVER_DIR/Server" -Recurse -Force } if (-not (Test-Path "$SERVER_DIR/server.zip")) { & $DOWNLOADER --download-path "$SERVER_DIR/server.zip" } Write-Output "Décompression de l'archive du serveur Hytale" Expand-Archive -Path "$SERVER_DIR/server.zip" -DestinationPath $SERVER_DIR -Force Write-Output "Téléchargement terminée." } function decompile { Write-Output "Décompilation avec CFR..." & java -jar "$BIN_DIR/cfr-0.152.jar" "$SERVER_DIR/Server/HytaleServer.jar" --outputdir "$SRC_REF_DIR" Write-Output "Décompilation terminée." } $Action = $args[0] switch ($Action) { "--download" { download } "--setup" { setup } "--decompile" { decompile } "--update" { update_safe } "--update-sure" { update } default { Write-Output "Usage: .\setup.ps1 [--download|--setup|--decompile|--update]" Write-Output "" Write-Output "Options:" Write-Output " --download Télécharge les outils (hytale-downloader, CFR)" Write-Output " --setup Configure l'environnement (télécharge le serveur)" Write-Output " --decompile Décompile le serveur" exit 1 } }