From 1ef54d2b15cb3d13776078ba0a3a2ab79245bbb6 Mon Sep 17 00:00:00 2001 From: RS_COME_BACK Date: Wed, 21 Jan 2026 14:59:54 +0100 Subject: [PATCH] Upload files to "/" --- setup.ps1 | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 setup.ps1 diff --git a/setup.ps1 b/setup.ps1 new file mode 100644 index 0000000..735bf6f --- /dev/null +++ b/setup.ps1 @@ -0,0 +1,99 @@ +$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 + } +}