Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- rem *********************************************
- rem *********************************************
- rem **
- rem ** Minecraft Instance Manager
- rem **
- rem ** Version 1.44
- rem ** By Strahan, 2018
- rem **
- rem *********************************************
- rem *********************************************
- setlocal enabledelayedexpansion
- if /i "%1"=="/np" goto :config
- if /i "%1"=="-np" goto :config
- if /i "%1"=="new" goto :config
- if not exist *.mcscfg goto :config
- set /a profileCount=0
- for /f "tokens=* delims=" %%a in ('dir *.mcscfg /b') do (
- set /a profileCount=!profileCount!+1
- set profiles[!profileCount!]=%%a
- )
- if "%profileCount%"=="1" set activeConfig=1
- if %profileCount% gtr 1 (
- cls
- echo Which configuration would you like to launch?
- echo.
- for /l %%s in (1,1,%profileCount%) do echo [%%s] !profiles[%%s]:~0,-7!
- echo.
- set /p activeConfig=": "
- if "!activeConfig!"=="" cls &echo Cancelling launch! &goto :eof
- if "!profiles[!activeConfig!]!"=="" cls &echo Invalid profile!! &goto :eof
- )
- cls
- echo Launching server(s) using profile !profiles[%activeConfig%]:~0,-7!
- for /f "tokens=*" %%s in ('type "!profiles[%activeConfig%]!"') do (
- set tmpval=%%s
- set varname=!tmpval:~0,24!
- set varvalue=!tmpval:~25,100!
- for /l %%a in (1,1,25) do if "!varname:~-1!"==" " set varname=!varname:~0,-1!
- for /l %%a in (1,1,500) do if "!varvalue:~-1!"==" " set varvalue=!varvalue:~0,-1!
- set !varname!=!varvalue!
- )
- if /i "%configType%"=="s" goto :single_instance
- if /i "%configType%"=="b" goto :bungeecord
- echo Invalid config type specified in profile! (%configType%)
- echo.
- goto :eof
- :single_instance
- call :prep "%srvPath%" "%srvName%" "%srvParams%" "%srvJar%" %restartLimit% %restartDelay% %consoleColors%
- start /d "%srvPath%" launch.bat
- goto :eof
- :bungeecord
- call :prep "%bcPath%" "%bcName%" "%bcParams%" "%bcJAR%" %bcRestartLimit% %bcRestartDelay% %bcColors%
- start /d "%bcPath%" launch.bat
- for /l %%s in (0,1,50) do (
- if "!bcSrvPath[%%s]!" neq "" (
- call :prep "!bcSrvPath[%%s]!" "!bcSrvName[%%s]!" "!bcSrvParams[%%s]!" "!bcSrvJAR[%%s]!" !bcSrvRestartLimit[%%s]! !bcSrvRestartDelay[%%s]! !bcSrvColors[%%s]!
- start /d "!bcSrvPath[%%s]!" launch.bat
- )
- )
- goto :eof
- :failure
- echo Error level: %1
- goto :eof
- :prep
- set "prepPath=%~1"
- set "prepName=%~2"
- set "prepParm=%~3"
- set "prepFile=%~4"
- set prepRL=%5
- set prepRD=%6
- set prepCC=%7
- echo @echo off >"%prepPath%\launch.bat"
- echo cls>>"%prepPath%\launch.bat"
- if "%prepRL%" neq "0" if "%prepRL%" neq "*" echo set /a restartCount=0 >>"%prepPath%\launch.bat"
- echo :start>>"%prepPath%\launch.bat"
- echo title %prepName% - Running>>"%prepPath%\launch.bat"
- echo color %prepCC% >>"%prepPath%\launch.bat"
- echo java %prepParm% -jar %prepFile%>>"%prepPath%\launch.bat"
- if "%prepRL%" == "0" goto :eof
- if "%prepRL%" neq "*" echo set /a restartCount=%%restartCount%%+1 >>"%prepPath%\launch.bat"
- if "%prepRL%" neq "*" echo if %%restartCount%% leq %prepRL% goto :restartcheck>>"%prepPath%\launch.bat"
- if "%prepRL%" neq "*" echo goto :eof>>"%prepPath%\launch.bat"
- if "%prepRL%" neq "*" echo :restartcheck>>"%prepPath%\launch.bat"
- echo echo.>>"%prepPath%\launch.bat"
- echo choice /n /t %prepRD% /d Y /m "Do you wish to restart the server? ">>"%prepPath%\launch.bat"
- echo if "%%errorlevel%%"=="1" goto :start>>"%prepPath%\launch.bat"
- goto :eof
- :config
- cls
- if not exist *.mcscfg echo I see this is your first time using this. Lets do some configuration. &echo.
- echo We need to answer a bunch of questions to setup a configuration profile. The config
- echo profile tells this launcher what server(s) to launch and how to do so.
- echo.
- echo Are you running a [S]ingle Minecraft server or are you using [B]ungeeCord?
- echo.
- choice /c SBC /n
- if "%errorlevel%"=="1" goto :config_single
- if "%errorlevel%"=="2" goto :config_bc
- goto :config_cancel
- :config_bc
- :cb_1
- cls
- set bcPath=
- if "%1"=="err1" echo * You need to tell me the path! *&echo.
- if "%1"=="err2" echo * That path is not valid! *&echo.
- echo Please enter the path to where the BungeeCord files are (i.e. where is the JAR file)
- echo.
- set /p bcPath="Path: "
- if "%bcPath%"=="" call :cb_1 err1
- if not exist "%bcPath%" call :cb_1 err2
- :cb_2
- cls
- set /a curBCSC=1
- if exist "%bcPath%\config.yml" call :cb_yml
- if "%bcTotalServers%" neq 0 goto :cb_2c
- :cb_2a
- for /l %%s in (1,1,%bcTotalServers%) do set bcSrvName[%%s]=
- set bcTotalServers=
- :cb_2b
- if "%1"=="err1" echo * That is not a valid selection! *&echo.
- echo How many servers are there?
- echo.
- set /p bcTotalServers=": "
- if "%bcTotalServers%"=="0" goto :config_cancel
- set tmpvalid=0
- for /l %%s in (1,1,50) do if "%bcTotalServers%"=="%%s" set tmpvalid=1
- if "%tmpvalid%"=="0" call :cb_2b err1
- goto :cb_3
- :cb_2c
- echo I read the BungeeCord config and I think I found %bcTotalServers% servers:
- echo.
- for /l %%s in (1,1,%bcTotalServers%) do (
- echo Server %%s: !bcSrvName[%%s]!
- )
- echo.
- echo Is this correct?
- echo.
- choice /n
- if "%errorlevel%"=="1" goto :cbm_1
- if "%errorlevel%"=="2" goto :cb_2a
- goto :eof
- :cbm_1
- cls
- set bcName=
- echo Configuring BungeeCord Instance
- echo.
- echo This configures the console that runs the BungeeCord.jar, not the servers.
- echo.
- if "%1"=="err1" echo * You must give me a name! *&echo.
- echo What is the instance name?
- echo.
- set /p tmpsn=": "
- if "%tmpsn%"=="" call :cbm_1 err1
- set bcName=%tmpsn%
- goto :cbm_2
- :cbm_2
- cls
- echo Configuring BungeeCord Instance
- echo.
- set bcJAR=
- set /a tmpcounter=0
- set tmpjar=
- echo Which JAR file will the server be using?
- echo.
- for /f "tokens=*" %%s in ('dir "%bcPath%\*.jar" /b') do (
- set /a tmpcounter=!tmpcounter!+1
- echo [!tmpcounter!] - %%s
- )
- echo.
- echo [J]ar is not listed!
- echo.
- set /p tmpjar="Selection: "
- if /i "%tmpjar%"=="j" goto :cbm_setcustomjar
- if /i "%tmpjar%" neq "c" if /i "%tmpjar%" neq "j" (
- set /a tmpcounter=0
- for /f "tokens=*" %%s in ('dir "%bcPath%\*.jar" /b') do (
- set /a tmpcounter=!tmpcounter!+1
- if "!tmpcounter!"=="%tmpjar%" set bcJAR=%%s
- )
- )
- goto :cbm_3
- :cbm_setcustomjar
- set bcJAR=
- echo.
- echo Please type the JAR complete filename {e.g. BungeeCord.jar}
- echo.
- set /p bcJAR=": "
- if not exist "%bcPath%\%bcJAR%" (
- echo.
- echo I'm going to use the file you entered, but I did not find it in the server path.
- echo If the server doesn't start, check the filename and be sure you have it right.
- echo.
- pause
- )
- goto :cbm_3
- :cbm_3
- cls
- set bcParams=
- echo Configuring BungeeCord Instance
- echo.
- echo Please enter any Java parameters you want to use.
- echo.
- echo (e.g. -Xms1G -Xmx4G to set a 1 GB initial heap and 4 GB max heap or any others)
- echo.
- set /p bcParams=": "
- goto :cbm_4
- :cbm_4
- set bcRestartLimit=
- cls
- echo Configuring BungeeCord Instance
- echo.
- if "%1"=="err1" echo * That is not a valid selection! *&echo.
- echo When this server stops, it can automatically be restarted. You can optionally
- echo limit the number of restarts if you wish.
- echo.
- echo Enter the number of restarts allowed before it just stops. You can enter 0
- echo to disable restarting entirely (i.e. don't ever try to restart) or you can
- echo enter * to not limit the number of restarts.
- echo.
- set /p bcRestartLimit=": "
- if "%bcRestartLimit%"=="*" goto :cbm_5
- set tmpvalid=0
- for /l %%s in (0,1,100) do if "%bcRestartLimit%"=="%%s" set tmpvalid=1
- if "%tmpvalid%"=="0" call :cbm_4 err1
- goto :cbm_5
- :cbm_5
- if "%bcRestartLimit%"=="0" set bcRestartDelay=3&goto :cbm_6
- set bcRestartDelay=
- cls
- echo Configuring BungeeCord Instance
- echo.
- if "%1"=="err1" echo * That is not a valid selection! *&echo.
- echo When the server stops, it will prompt to ask if you wish to stop the
- echo restart process. It will wait a certain number of seconds, then
- echo it will assume yes and restart itself.
- echo.
- echo How many seconds should it wait? (1-30)
- set /p bcRestartDelay=": "
- set tmpvalid=0
- for /l %%s in (1,1,30) do if "%bcRestartDelay%"=="%%s" set tmpvalid=1
- if "%tmpvalid%"=="0" call :cbm_5 err1
- set tmpcolor=
- goto :cbm_6
- :cbm_6
- set bcColors=
- if "%tmpcolor%"=="" set tmpcolor=07
- cls
- echo Configuring BungeeCord Instance
- echo.
- color %tmpcolor%
- echo You can set what color scheme to use for the console.
- echo.
- echo 1 - Dark Blue 9 - Blue
- echo 2 - Dark Green A - Green
- echo 3 - Dark Cyan B - Cyan
- echo 4 - Dark Red C - Red
- echo 5 - Dark Purple D - Purple
- echo 6 - Dark Yellow E - Yellow
- echo 7 - Grey F - White
- echo 8 - Dark Grey 0 - Black
- echo.
- echo If, when the screen sets color to preview, you cannot read the menu
- echo just hit enter on the color selection and it will reset itself.
- echo.
- echo If you like what you have, enter S for background color to save.
- echo.
- echo Background color:
- set /p tmpcolora=": "
- if "%tmpcolora%"=="" set tmpcolor=07&goto :cbm_6
- if /i "%tmpcolora%"=="s" set bcColors=%tmpcolor%&goto :cbm_7
- echo Foreground (i.e. text) color:
- set /p tmpcolorb=": "
- set tmpcolor=%tmpcolora%%tmpcolorb%
- goto :cbm_6
- :cbm_7
- color 07
- cls
- echo Now that we've configured the main BungeeCord instance, we need
- echo to configure all the servers it will be handling.
- echo.
- pause
- goto :cb_3
- :cb_3
- cls
- set tmpsn=
- echo Configuring BungeeCord server %curBCSC%
- echo.
- if "%1"=="err1" echo * You must give me a name! *&echo.
- echo What is the server name?
- echo.
- if "!bcSrvName[%curBCSC%]!" neq "" echo Press enter to use !bcSrvName[%curBCSC%]!&echo.
- set /p tmpsn=": "
- if "%tmpsn%"=="" (
- if "!bcSrvName[%curBCSC%]!" == "" call :cb_3 err1
- goto :cb_4
- )
- set bcSrvName[%curBCSC%]=%tmpsn%
- goto :cb_4
- :cb_4
- cls
- set tmpsn=
- set bcSrvPath[%curBCSC%]=
- echo Configuring BungeeCord server %curBCSC% - !bcSrvName[%curBCSC%]!
- echo.
- if "%1"=="err1" echo * That path is invalid! *&echo.
- echo What is the path to server files? (where the JAR file is)
- echo.
- set /p tmpsn=": "
- if "%tmpsn%"=="" call :cb_4 err1
- if not exist "%tmpsn%" call :cb_4 err1
- set bcSrvPath[%curBCSC%]=%tmpsn%
- goto :cb_5
- :cb_5
- cls
- echo Configuring BungeeCord server %curBCSC% - !bcSrvName[%curBCSC%]!
- echo.
- set bcSrvJAR[%curBCSC%]=
- set /a tmpcounter=0
- set tmpjar=
- echo Which JAR file will the server be using?
- echo.
- for /f "tokens=*" %%s in ('dir "!bcSrvPath[%curBCSC%]!\*.jar" /b') do (
- set /a tmpcounter=!tmpcounter!+1
- echo [!tmpcounter!] - %%s
- )
- echo.
- echo [J]ar is not listed!
- echo.
- set /p tmpjar="Selection: "
- if /i "%tmpjar%"=="j" goto :cb_setcustomjar
- if /i "%tmpjar%" neq "c" if /i "%tmpjar%" neq "j" (
- set /a tmpcounter=0
- for /f "tokens=*" %%s in ('dir "!bcSrvPath[%curBCSC%]!\*.jar" /b') do (
- set /a tmpcounter=!tmpcounter!+1
- if "!tmpcounter!"=="%tmpjar%" set bcSrvJAR[%curBCSC%]=%%s
- )
- )
- goto :cb_6
- :cb_setcustomjar
- set bcSrvJAR[%curBCSC%]=
- echo.
- echo Please type the JAR complete filename {e.g. spigot-1.12.2.jar}
- echo.
- set /p bcSrvJAR[%curBCSC%]=": "
- if not exist "!bcSrvPath[%curBCSC%]!\!bcSrvJAR[%curBCSC%]!" (
- echo.
- echo I'm going to use the file you entered, but I did not find it in the server path.
- echo If the server doesn't start, check the filename and be sure you have it right.
- echo.
- pause
- )
- goto :cb_6
- :cb_6
- cls
- set bcSrvParams[%curBCSC%]=
- echo Configuring BungeeCord server %curBCSC% - !bcSrvName[%curBCSC%]!
- echo.
- echo Please enter any Java parameters you want to use.
- echo.
- echo (e.g. -Xms1G -Xmx4G to set a 1 GB initial heap and 4 GB max heap or any others)
- echo.
- set /p bcSrvParams[%curBCSC%]=": "
- goto :cb_7
- :cb_7
- set bcSrvRestartLimit[%curBCSC%]=
- cls
- echo Configuring BungeeCord server %curBCSC% - !bcSrvName[%curBCSC%]!
- echo.
- if "%1"=="err1" echo * That is not a valid selection! *&echo.
- echo When this server stops, it can automatically be restarted. You can optionally
- echo limit the number of restarts if you wish.
- echo.
- echo Enter the number of restarts allowed before it just stops. You can enter 0
- echo to disable restarting entirely (i.e. don't ever try to restart) or you can
- echo enter * to not limit the number of restarts.
- echo.
- set /p bcSrvRestartLimit[%curBCSC%]=": "
- if "!bcSrvRestartLimit[%curBCSC%]!"=="*" goto :cb_8
- set tmpvalid=0
- for /l %%s in (0,1,100) do if "!bcSrvRestartLimit[%curBCSC%]!"=="%%s" set tmpvalid=1
- if "%tmpvalid%"=="0" call :cb_7 err1
- goto :cb_8
- :cb_8
- if "!bcSrvRestartLimit[%curBCSC%]!"=="0" set !bcSrvRestartDelay[%curBCSC%]!=3&goto :cb_9
- set bcSrvRestartDelay[%curBCSC%]=
- cls
- echo Configuring BungeeCord server %curBCSC% - !bcSrvName[%curBCSC%]!
- echo.
- if "%1"=="err1" echo * That is not a valid selection! *&echo.
- echo When the server stops, it will prompt to ask if you wish to stop the
- echo restart process. It will wait a certain number of seconds, then
- echo it will assume yes and restart itself.
- echo.
- echo How many seconds should it wait? (1-30)
- set /p bcSrvRestartDelay[%curBCSC%]=": "
- set tmpvalid=0
- for /l %%s in (1,1,30) do if "!bcSrvRestartDelay[%curBCSC%]!"=="%%s" set tmpvalid=1
- if "%tmpvalid%"=="0" call :cb_8 err1
- set tmpcolor=
- goto :cb_9
- :cb_9
- set bcSrvColors[%curBCSC%]=
- if "%tmpcolor%"=="" set tmpcolor=07
- cls
- echo Configuring BungeeCord server %curBCSC% - !bcSrvName[%curBCSC%]!
- echo.
- color %tmpcolor%
- echo You can set what color scheme to use for the console.
- echo.
- echo 1 - Dark Blue 9 - Blue
- echo 2 - Dark Green A - Green
- echo 3 - Dark Cyan B - Cyan
- echo 4 - Dark Red C - Red
- echo 5 - Dark Purple D - Purple
- echo 6 - Dark Yellow E - Yellow
- echo 7 - Grey F - White
- echo 8 - Dark Grey 0 - Black
- echo.
- echo If, when the screen sets color to preview, you cannot read the menu
- echo just hit enter on the color selection and it will reset itself.
- echo.
- echo If you like what you have, enter S for background color to save.
- echo.
- echo Background color:
- set /p tmpcolora=": "
- if "%tmpcolora%"=="" set tmpcolor=07&goto :cb_10
- if /i "%tmpcolora%"=="s" set bcSrvColors[%curBCSC%]=%tmpcolor%&goto :cb_10
- echo Foreground (i.e. text) color:
- set /p tmpcolorb=": "
- set tmpcolor=%tmpcolora%%tmpcolorb%
- goto :cb_9
- :cb_10
- color 07
- set /a curBCSC=%curBCSC%+1
- echo curBCSC = %curBCSC% [!curBCSC!]
- echo bcTotalServers = %bcTotalServers% [!bcTotalServers!]
- if %curBCSC% leq %bcTotalServers% goto :cb_3
- cls
- echo All done - now lets verify the information:
- echo.
- echo ----------------------------------------------------
- echo BungeeCord Instance - %bcName%
- echo Path : %bcPath%
- echo JAR : %bcJAR%
- echo Params : %bcParams%
- echo Restart Count: %bcRestartLimit%
- echo Restart Delay: %bcRestartDelay%
- echo Colors : %bcColors%
- for /l %%s in (1,1,%bcTotalServers%) do (
- echo ----------------------------------------------------
- echo Server %%s - !bcSrvName[%%s]!
- echo Path : !bcSrvPath[%%s]!
- echo JAR : !bcSrvJAR[%%s]!
- echo Params : !bcSrvParams[%%s]!
- echo Restart Count: !bcSrvRestartLimit[%%s]!
- echo Restart Delay: !bcSrvRestartDelay[%%s]!
- echo Colors : !bcSrvColors[%%s]!
- )
- echo ----------------------------------------------------
- echo.
- echo Is this correct?
- echo.
- choice /n
- if "%errorlevel%"=="1" goto :cb_11
- if "%errorlevel%"=="2" set curBCSC=1&goto :cb_3
- goto :eof
- :cb_11
- cls
- echo Saving configuration profile. Please give the profile a name:
- echo.
- set /p configProfile=": "
- if "%configProfile%"=="" set configProfile=launcher
- if exist %configProfile%.mcscfg (
- for /f "tokens=1,6" %%s in ('echo.^|date') do if "%%s"=="The" set datecode=%%t
- for /f "tokens=1,5" %%s in ('echo.^|time') do if "%%s"=="The" set timecode=%%t
- set tmpnewfile=%configProfile%.mcscfg_%datecode:~0,2%%datecode:~3,2%%datecode:~6,4%-%timecode:~0,2%%timecode:~3,2%%timecode:~6,2%
- ren %configProfile%.mcscfg %tmpnewfile%
- echo An existing configuration was present, renamed it to %tmpnewfile%
- echo.
- )
- echo configType b>%configProfile%.mcscfg
- echo bcName %bcName% >>%configProfile%.mcscfg
- echo bcPath %bcPath% >>%configProfile%.mcscfg
- echo bcJAR %bcJAR% >>%configProfile%.mcscfg
- echo bcParams %bcParams% >>%configProfile%.mcscfg
- echo bcRestartLimit %bcRestartLimit% >>%configProfile%.mcscfg
- echo bcRestartDelay %bcRestartDelay% >>%configProfile%.mcscfg
- echo bcColors %bcColors% >>%configProfile%.mcscfg
- echo bcTotalServers %bcTotalServers% >>%configProfile%.mcscfg
- for /l %%s in (1,1,9) do (
- if %%s leq %bcTotalServers% (
- echo bcSrvPath[%%s] !bcSrvPath[%%s]! >>%configProfile%.mcscfg
- echo bcSrvJAR[%%s] !bcSrvJAR[%%s]! >>%configProfile%.mcscfg
- echo bcSrvParams[%%s] !bcSrvParams[%%s]! >>%configProfile%.mcscfg
- echo bcSrvRestartLimit[%%s] !bcSrvRestartLimit[%%s]! >>%configProfile%.mcscfg
- echo bcSrvRestartDelay[%%s] !bcSrvRestartDelay[%%s]! >>%configProfile%.mcscfg
- echo bcSrvColors[%%s] !bcSrvColors[%%s]! >>%configProfile%.mcscfg
- )
- )
- for /l %%s in (10,1,50) do (
- if %%s leq %bcTotalServers% (
- echo bcSrvPath[%%s] !bcSrvPath[%%s]! >>%configProfile%.mcscfg
- echo bcSrvJAR[%%s] !bcSrvJAR[%%s]! >>%configProfile%.mcscfg
- echo bcSrvParams[%%s] !bcSrvParams[%%s]! >>%configProfile%.mcscfg
- echo bcSrvRestartLimit[%%s] !bcSrvRestartLimit[%%s]! >>%configProfile%.mcscfg
- echo bcSrvRestartDelay[%%s] !bcSrvRestartDelay[%%s]! >>%configProfile%.mcscfg
- echo bcSrvColors[%%s] !bcSrvColors[%%s]! >>%configProfile%.mcscfg
- )
- )
- echo Config profile saved!
- echo.
- goto :eof
- :config_single
- :cs_1
- cls
- set srvPath=
- if "%1"=="err1" echo * You need to tell me the path! *&echo.
- if "%1"=="err2" echo * That path is not valid! *&echo.
- echo Please enter the path to where the server files are (i.e. where is the JAR file)
- echo.
- set /p srvPath="Path: "
- if "%srvPath%"=="" call :cs_1 err1
- if not exist "%srvPath%" call :cs_1 err2
- :cs_2
- set srvJAR=
- set /a tmpcounter=0
- cls
- echo Which JAR file will the server be using?
- echo.
- for /f "tokens=*" %%s in ('dir "%srvPath%\*.jar" /b') do (
- set /a tmpcounter=!tmpcounter!+1
- echo [!tmpcounter!] - %%s
- )
- echo.
- echo [J]ar is not listed!
- echo.
- set /p tmpjar="Selection: "
- if /i "%tmpjar%"=="j" goto :cs_setcustomjar
- if /i "%tmpjar%" neq "c" if /i "%tmpjar%" neq "j" (
- set /a tmpcounter=0
- for /f "tokens=*" %%s in ('dir "%srvPath%\*.jar" /b') do (
- set /a tmpcounter=!tmpcounter!+1
- if "!tmpcounter!"=="%tmpjar%" set srvJAR=%%s
- )
- )
- goto :cs_3
- :cs_setcustomjar
- echo.
- echo Please type the JAR complete filename {e.g. spigot-1.12.2.jar}
- echo.
- set /p srvJAR=": "
- if not exist "%srvPath%\%srvJAR%" (
- echo.
- echo I'm going to use the file you entered, but I did not find it in the server path.
- echo If the server doesn't start, check the filename and be sure you have it right.
- echo.
- pause
- )
- goto :cs_3
- :cs_3
- set srvParams=
- cls
- echo Please enter any Java parameters you want to use.
- echo.
- echo (e.g. -Xms1G -Xmx4G to set a 1 GB initial heap and 4 GB max heap or any others)
- echo.
- set /p srvParams=": "
- :cs_4
- set srvName=
- cls
- echo What is the name of the server?
- echo.
- set /p srvName=": "
- if "%srvName%"=="" set srvName=Minecraft Server
- :cs_5
- set restartLimit=
- cls
- if "%1"=="err1" echo * That is not a valid selection! *&echo.
- echo When the server stops, it can automatically be restarted. You can optionally
- echo limit the number of restarts if you wish.
- echo.
- echo Enter the number of restarts allowed before it just stops. You can enter 0
- echo to disable restarting entirely (i.e. don't ever try to restart) or you can
- echo enter * to not limit the number of restarts.
- echo.
- set /p restartLimit=": "
- if "%restartLimit%"=="*" goto :cs_6
- set tmpvalid=0
- for /l %%s in (0,1,100) do if "%restartLimit%"=="%%s" set tmpvalid=1
- if "%tmpvalid%"=="0" call :cs_5 err1
- :cs_6
- if "%restartLimit%"=="0" set restartDelay=3&goto :cs_7
- set restartDelay=
- cls
- if "%1"=="err1" echo * That is not a valid selection! *&echo.
- echo When the server stops, it will prompt to ask if you wish to stop the
- echo restart process. It will wait a certain number of seconds, then
- echo it will assume yes and restart itself.
- echo.
- echo How many seconds should it wait? (1-30)
- set /p restartDelay=": "
- set tmpvalid=0
- for /l %%s in (1,1,30) do if "%restartDelay%"=="%%s" set tmpvalid=1
- if "%tmpvalid%"=="0" call :cs_6 err1
- set tmpcolor=
- goto :cs_7
- :cs_7
- set consoleColors=
- if "%tmpcolor%"=="" set tmpcolor=07
- cls
- color %tmpcolor%
- echo You can set what color scheme to use for the console.
- echo.
- echo 1 - Dark Blue 9 - Blue
- echo 2 - Dark Green A - Green
- echo 3 - Dark Cyan B - Cyan
- echo 4 - Dark Red C - Red
- echo 5 - Dark Purple D - Purple
- echo 6 - Dark Yellow E - Yellow
- echo 7 - Grey F - White
- echo 8 - Dark Grey 0 - Black
- echo.
- echo If, when the screen sets color to preview, you cannot read the menu
- echo just hit enter on the color selection and it will reset itself.
- echo.
- echo If you like what you have, enter S for background color to save.
- echo.
- echo Background color:
- set /p tmpcolora=": "
- if "%tmpcolora%"=="" set tmpcolor=07&goto :cs_7
- if /i "%tmpcolora%"=="s" set consoleColors=%tmpcolor%&goto :cs_8
- echo Foreground (i.e. text) color:
- set /p tmpcolorb=": "
- set tmpcolor=%tmpcolora%%tmpcolorb%
- goto :cs_7
- :cs_8
- color 07
- cls
- echo OK, please verify this is correct:
- echo.
- echo Server Name : %srvName%
- echo Path to Server: %srvPath%
- echo JAR Filename : %srvJAR%
- echo Parameters : %srvParams%
- echo Restarts : %restartLimit%
- if "%restartLimit%" neq "0" echo Restart Delay : %restartDelay%
- echo Color Scheme : %consoleColors%
- echo.
- echo (Y)es, it is right
- echo (N)o, start over
- echo.
- choice /c YNC /n
- if "%errorlevel%"=="1" goto :cs_save
- if "%errorlevel%"=="2" goto :cs_1
- goto :cs_8
- :cs_save
- cls
- echo Saving configuration profile. Please give the profile a name:
- echo.
- set /p configProfile=": "
- if "%configProfile%"=="" set configProfile=launcher
- if exist "%configProfile%.mcscfg" (
- for /f "tokens=1,6" %%s in ('echo.^|date') do if "%%s"=="The" set datecode=%%t
- for /f "tokens=1,5" %%s in ('echo.^|time') do if "%%s"=="The" set timecode=%%t
- set tmpnewfile=%configProfile%.mcscfg_%datecode:~0,2%%datecode:~3,2%%datecode:~6,4%-%timecode:~0,2%%timecode:~3,2%%timecode:~6,2%
- ren "%configProfile%.mcscfg" "%tmpnewfile%"
- echo An existing configuration was present, renamed it to %tmpnewfile%
- echo.
- )
- echo configType s>"%configProfile%.mcscfg"
- echo srvName %srvName% >>"%configProfile%.mcscfg"
- echo srvPath %srvPath% >>"%configProfile%.mcscfg"
- echo srvJAR %srvJAR% >>"%configProfile%.mcscfg"
- echo srvParams %srvParams% >>"%configProfile%.mcscfg"
- echo restartLimit %restartLimit% >>"%configProfile%.mcscfg"
- echo consoleColors %consoleColors% >>"%configProfile%.mcscfg"
- echo restartDelay %restartDelay% >>"%configProfile%.mcscfg"
- echo.
- echo The profile has been saved!
- echo.
- goto :eof
- :cb_yml
- set /a bcTotalServers=0
- set serverCollecting=0
- for /f "tokens=1" %%s in (%bcpath%\config.yml) do call :procline "%%s"
- goto :eof
- :procline
- set "line=%~1"
- if /i "%line:~0,8%"=="timeout:" set serverCollecting=0
- if "!serverCollecting!"=="1" (
- set tmpdata=%line:~0,-1%
- if /i "%tmpdata%" neq "motd" if /i "%tmpdata%" neq "address" if /i "%tmpdata%" neq "restricted" if /i "%tmpdata%" neq "timeout" if "%tmpdata%" neq "" (
- set /a bcTotalServers=!bcTotalServers!+1
- set bcSrvName[!bcTotalServers!]=%tmpdata%
- )
- )
- if /i "%line:~0,8%"=="servers:" set serverCollecting=1
- goto :eof
- :config_cancel
- cls
- echo Configuration cancelled!
- goto :eof
Add Comment
Please, Sign In to add comment