@echo off
setlocal

set "ZIP_URL=https://files.kakgonbri.party/kakgonbri/mods.zip"

set "ZIP_FILE=mods.zip"

set "SCRIPT_DIR=%~dp0"

curl -L "%ZIP_URL%" -o "%SCRIPT_DIR%%ZIP_FILE%"

if errorlevel 1 (
    echo Failed to download file.
    exit /b 1
)

rd /s /q "mods"
rd /s /q "datapacks"
rd /s /q "resourcepacks"

echo Extracting
powershell -Command "Expand-Archive -Path '%SCRIPT_DIR%%ZIP_FILE%' -DestinationPath '%SCRIPT_DIR%' -Force"

if errorlevel 1 (
    echo Failed to extract ZIP file.
    exit /b 1
)

del mods.zip

echo Done.