@echo off
setlocal EnableDelayedExpansion

REM Java wrapper for Windows - strips UseCompactObjectHeaders, adds --disable-sentry
REM Uses %* string replacement instead of for-loop to preserve = signs in JVM flags
set "REAL_JAVA=%~dp0java-original.exe"
set "ARGS=%*"

REM Strip -XX:+UseCompactObjectHeaders
set "ARGS=!ARGS:-XX:+UseCompactObjectHeaders=!"

REM Check if running HytaleServer.jar and add --disable-sentry
echo !ARGS! | findstr /i "HytaleServer.jar" >nul 2>&1
if !ERRORLEVEL!==0 (
    "%REAL_JAVA%" !ARGS! --disable-sentry
) else (
    "%REAL_JAVA%" !ARGS!
)
exit /b !ERRORLEVEL!
