@echo off
setlocal
title RootPlugins Uninstaller

rem Puts RuneLite back the way it was. Plugin settings, macros and bank templates are left alone.
rem Stands on its own so it still works if this is the only file someone kept.

set "ENDPOINT=https://rootsoft.org/rootplugins"
set "RL=%LOCALAPPDATA%\RuneLite"
set "JAVA=%RL%\jre\bin\java.exe"
set "WORK=%TEMP%\rootplugins-installer"

net session >nul 2>&1
if errorlevel 1 (
	echo Asking for administrator rights, needed to tidy your hosts file...
	powershell -NoProfile -Command "Start-Process -FilePath '%~f0' -ArgumentList 'elevated' -Verb RunAs"
	exit /b
)

echo.
echo   Removing RootPlugins from RuneLite
echo.

if not exist "%JAVA%" (
	echo   [!!] RuneLite isn't installed here, so there is nothing to undo.
	echo.
	pause
	exit /b 1
)

if not exist "%WORK%" mkdir "%WORK%"
curl -fsS -o "%WORK%\rootplugins-installer.jar" "%ENDPOINT%/rootplugins-installer.jar"
if errorlevel 1 (
	echo   [!!] Couldn't reach %ENDPOINT%.
	echo.
	pause
	exit /b 1
)

"%JAVA%" -jar "%WORK%\rootplugins-installer.jar" uninstall

echo.
pause
