@echo off
rem ======================================================================
rem  Minecraft server setup launcher  (version 1.3.1)
rem
rem  What this file does:
rem   1. Downloads mc-setup.ps1 from https://minecraft.hamtoto.kr/downloads/ into your TEMP folder.
rem   2. Runs it with Windows PowerShell 5.1, bypassing the execution policy
rem      for this one run only (nothing is changed permanently).
rem  No admin rights are needed. Read mc-setup.ps1 on the website to see
rem  exactly what it changes. It backs up every file before editing it.
rem  Extra arguments are passed to mc-setup.ps1 (for example -InstancePath).
rem ======================================================================
setlocal
set "SITE=https://minecraft.hamtoto.kr"
set "PS=%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe"
if not exist "%PS%" set "PS=powershell.exe"

echo Downloading the setup script from %SITE% ...
"%PS%" -NoProfile -ExecutionPolicy Bypass -Command "$ErrorActionPreference='Stop'; [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor 3072; $ProgressPreference='SilentlyContinue'; Invoke-WebRequest -UseBasicParsing -Uri '%SITE%/downloads/mc-setup.ps1' -OutFile (Join-Path $env:TEMP 'mc-setup.ps1')"
if errorlevel 1 goto failed

"%PS%" -NoProfile -ExecutionPolicy Bypass -File "%TEMP%\mc-setup.ps1" %*
endlocal
exit /b %errorlevel%

:failed
echo.
echo Could not download the setup script.
echo Check your internet connection, or open %SITE% in a browser.
echo.
pause
endlocal
exit /b 1
