@echo off

set "source=..\..\Sponge and gRPC\minecraft-rpc"

set "jar_from=target\minecraft-rpc-0.0.7.jar"
set "jar_to=mods"
set "py_dir=clients\python"
set "py_from=%py_dir%\minecraft_pb2.py"
set "pyi_from=%py_dir%\minecraft_pb2.pyi"
set "grpc_py_from=%py_dir%\minecraft_pb2_grpc.py"
set "py_to=py_scripts"

if not exist "%source%" (
    echo Source file does not exist.
    exit /b 1
)

copy  "%source%\%jar_from%" "%jar_to%" > nul
if %errorlevel% neq 0 (
    echo Failed to copy file "%source%\%jar_from%" to "%jar_to%".
    exit /b
) else (
    echo Copied file "%source%\%jar_from%" to "%jar_to%" successfully.
)

copy  "%source%\%py_from%" "%py_to%" > nul
if %errorlevel% neq 0 (
    echo Failed to copy file "%source%\%py_from%" to "%py_to%".
    exit /b
) else (
    echo Copied file "%source%\%py_from%" to "%py_to%" successfully.
)

copy  "%source%\%pyi_from%" "%py_to%" > nul
if %errorlevel% neq 0 (
    echo Failed to copy file "%source%\%pyi_from%" to "%py_to%".
    exit /b
) else (
    echo Copied file "%source%\%pyi_from%" to "%py_to%" successfully.
)

copy  "%source%\%grpc_py_from%" "%py_to%" > nul
if %errorlevel% neq 0 (
    echo Failed to copy file "%source%\%grpc_py_from%" to "%py_to%".
    exit /b
) else (
    echo Copied file "%source%\%grpc_py_from%" to "%py_to%" successfully.
)