@echo off

setlocal EnableDelayedExpansion

set forge=instMods/*forge*.zip

set jar=minecraft_server.jar

set RootClient=D:/Games/Multi MC/instances/[1.5.2] Feed the Beast/minecraft

set RootServer=D:/Data/Dropbox/Computer/Spiele/Minecraft/Server

set ConfigClient=%RootClient%/config

set ConfigServer=%RootServer%/config

set CoreClient=%RootClient%/coremods

set CoreServer=%RootServer%/coremods

set ModClient=%RootClient%/mods

set ModServer=%RootServer%/mods

REM ========================================================================

REM Forge

REM ========================================================================

:forge

@echo.

@echo Processing Forge

@echo ================

@echo.

REM create temp folder if not there

if not exist temp (

<nul set /p random=Creating Temp Folder:

mkdir temp

@echo done.

)

REM extract a *forge* zip file in instMods Folder

<nul set /p random=Extracting Forge into Temp:

winrar x "%forge%" temp

@echo done.

REM add temp to server jar

pushd temp

<nul set /p random=Insert into Server JAR:

winrar a -r %RootServer%/%jar% *

@echo done.

popd

REM if temp folder exists remove temp with all subfolders and without asking

if exist temp (

<nul set /p random=Removing Temp Folder:

rd /s /q temp

@echo done.

)

@echo.

@echo Patch Forge successfull!

@echo.

:endforge

REM ========================================================================

REM CoreMods

REM ========================================================================

:coremods

@echo.

@echo Processing CoreMods

@echo ===================

@echo.

REM go through all server cores

pushd "%CoreServer%"

for %%a in (*.*) do (

REM extract name and version of server cores

for /f "tokens=1,2" %%b in ("%%a") do (

set sName=%%b

set sVersion=%%~nc

)

<nul set /p looking=!sName!:

REM look up for equivalent cores on client side

pushd "%CoreClient%"

for %%d in (!sName!*.*) do (

REM found newer core

if %%d GTR %%a (

REM extract name and version of client core

for /f "tokens=1,2" %%e in ("%%d") do (

set cName=%%e

set cVersion=%%~nf

)

@echo !sVersion! to !cVersion!

REM delete server core

popd

del "%%a"

pushd "%CoreClient%"

REM copy newer client over to server mod folder

copy "%%d" "%CoreServer%/" >nul

) else (

@echo none

)

)

popd

)

popd

:endcoremods

REM ========================================================================

REM Mods

REM ========================================================================

:mods

@echo.

@echo Processing Mods

@echo ===============

@echo.

REM go through all server mods

pushd "%ModServer%"

for %%a in (*.*) do (

REM extract name and version of server mods

for /f "tokens=1,2" %%b in ("%%a") do (

set sName=%%b

set sVersion=%%~nc

)

<nul set /p looking=!sName!:

REM look up for equivalent mods on client side

pushd "%ModClient%"

for %%d in (!sName!*.*) do (

REM found newer mod

if %%d GTR %%a (

REM extract name and version of client mod

for /f "tokens=1,2" %%e in ("%%d") do (

set cName=%%e

set cVersion=%%~nf

)

@echo !sVersion! to !cVersion!

REM delete server mod

popd

del "%%a"

pushd "%ModClient%"

REM copy newer client over to server mod folder

copy "%%d" "%ModServer%/" >nul

) else (

@echo none

)

)

popd

)

popd

:endmods

REM ========================================================================

REM Configs

REM ========================================================================

:config

@echo.

@echo Processing Configs

@echo ==================

@echo.

REM just copy over all configs

xcopy "%ConfigClient%" "%ConfigServer%" /D /S /Y

:endconfig

:end

@echo.

@echo Patch done! Press any Key to close the Window