Strahan

Untitled

May 25th, 2018 (edited)
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 23.46 KB | None | 0 0
  1. @echo off
  2. rem *********************************************
  3. rem *********************************************
  4. rem **
  5. rem **  Minecraft Instance Manager
  6. rem **
  7. rem **  Version 1.44
  8. rem **  By Strahan, 2018
  9. rem **
  10. rem *********************************************
  11. rem *********************************************
  12.  
  13. setlocal enabledelayedexpansion
  14.  
  15. if /i "%1"=="/np" goto :config
  16. if /i "%1"=="-np" goto :config
  17. if /i "%1"=="new" goto :config
  18.  
  19. if not exist *.mcscfg goto :config
  20.  
  21. set /a profileCount=0
  22. for /f "tokens=* delims=" %%a in ('dir *.mcscfg /b') do (
  23.   set /a profileCount=!profileCount!+1
  24.   set profiles[!profileCount!]=%%a
  25. )
  26. if "%profileCount%"=="1" set activeConfig=1
  27. if %profileCount% gtr 1 (
  28.   cls
  29.   echo Which configuration would you like to launch?
  30.   echo.
  31.   for /l %%s in (1,1,%profileCount%) do echo [%%s] !profiles[%%s]:~0,-7!
  32.   echo.
  33.   set /p activeConfig=": "
  34.   if "!activeConfig!"=="" cls &echo Cancelling launch! &goto :eof
  35.   if "!profiles[!activeConfig!]!"=="" cls &echo Invalid profile!! &goto :eof
  36. )
  37. cls
  38. echo Launching server(s) using profile !profiles[%activeConfig%]:~0,-7!
  39.  
  40. for /f "tokens=*" %%s in ('type "!profiles[%activeConfig%]!"') do (
  41.   set tmpval=%%s
  42.   set varname=!tmpval:~0,24!
  43.   set varvalue=!tmpval:~25,100!
  44.   for /l %%a in (1,1,25) do if "!varname:~-1!"==" " set varname=!varname:~0,-1!
  45.   for /l %%a in (1,1,500) do if "!varvalue:~-1!"==" " set varvalue=!varvalue:~0,-1!
  46.   set !varname!=!varvalue!
  47. )
  48.  
  49. if /i "%configType%"=="s" goto :single_instance
  50. if /i "%configType%"=="b" goto :bungeecord
  51. echo Invalid config type specified in profile!  (%configType%)
  52. echo.
  53. goto :eof
  54.  
  55. :single_instance
  56. call :prep "%srvPath%" "%srvName%" "%srvParams%" "%srvJar%" %restartLimit% %restartDelay% %consoleColors%
  57. start /d "%srvPath%" launch.bat
  58. goto :eof
  59.  
  60. :bungeecord
  61. call :prep "%bcPath%" "%bcName%" "%bcParams%" "%bcJAR%" %bcRestartLimit% %bcRestartDelay% %bcColors%
  62. start /d "%bcPath%" launch.bat
  63.  
  64. for /l %%s in (0,1,50) do (
  65.   if "!bcSrvPath[%%s]!" neq "" (
  66.     call :prep "!bcSrvPath[%%s]!" "!bcSrvName[%%s]!" "!bcSrvParams[%%s]!" "!bcSrvJAR[%%s]!" !bcSrvRestartLimit[%%s]! !bcSrvRestartDelay[%%s]! !bcSrvColors[%%s]!
  67.     start /d "!bcSrvPath[%%s]!" launch.bat
  68.   )
  69. )
  70. goto :eof
  71.  
  72. :failure
  73. echo Error level: %1
  74. goto :eof
  75.  
  76. :prep
  77. set "prepPath=%~1"
  78. set "prepName=%~2"
  79. set "prepParm=%~3"
  80. set "prepFile=%~4"
  81. set prepRL=%5
  82. set prepRD=%6
  83. set prepCC=%7
  84. echo @echo off >"%prepPath%\launch.bat"
  85. echo cls>>"%prepPath%\launch.bat"
  86. if "%prepRL%" neq "0" if "%prepRL%" neq "*" echo set /a restartCount=0 >>"%prepPath%\launch.bat"
  87. echo :start>>"%prepPath%\launch.bat"
  88. echo title %prepName% - Running>>"%prepPath%\launch.bat"
  89. echo color %prepCC% >>"%prepPath%\launch.bat"
  90. echo java %prepParm% -jar %prepFile%>>"%prepPath%\launch.bat"
  91. if "%prepRL%" == "0" goto :eof
  92. if "%prepRL%" neq "*" echo set /a restartCount=%%restartCount%%+1 >>"%prepPath%\launch.bat"
  93. if "%prepRL%" neq "*" echo if %%restartCount%% leq %prepRL% goto :restartcheck>>"%prepPath%\launch.bat"
  94. if "%prepRL%" neq "*" echo goto :eof>>"%prepPath%\launch.bat"
  95. if "%prepRL%" neq "*" echo :restartcheck>>"%prepPath%\launch.bat"
  96. echo echo.>>"%prepPath%\launch.bat"
  97. echo choice /n /t %prepRD% /d Y /m "Do you wish to restart the server? ">>"%prepPath%\launch.bat"
  98. echo if "%%errorlevel%%"=="1" goto :start>>"%prepPath%\launch.bat"
  99. goto :eof
  100.  
  101. :config
  102. cls
  103. if not exist *.mcscfg echo I see this is your first time using this.  Lets do some configuration. &echo.
  104. echo We need to answer a bunch of questions to setup a configuration profile.  The config
  105. echo profile tells this launcher what server(s) to launch and how to do so.
  106. echo.
  107. echo Are you running a [S]ingle Minecraft server or are you using [B]ungeeCord?
  108. echo.
  109. choice /c SBC /n
  110. if "%errorlevel%"=="1" goto :config_single
  111. if "%errorlevel%"=="2" goto :config_bc
  112. goto :config_cancel
  113.  
  114. :config_bc
  115. :cb_1
  116. cls
  117. set bcPath=
  118. if "%1"=="err1" echo * You need to tell me the path! *&echo.
  119. if "%1"=="err2" echo * That path is not valid! *&echo.
  120. echo Please enter the path to where the BungeeCord files are (i.e. where is the JAR file)
  121. echo.
  122. set /p bcPath="Path: "
  123. if "%bcPath%"=="" call :cb_1 err1
  124. if not exist "%bcPath%" call :cb_1 err2
  125.  
  126. :cb_2
  127. cls
  128. set /a curBCSC=1
  129. if exist "%bcPath%\config.yml" call :cb_yml
  130. if "%bcTotalServers%" neq 0 goto :cb_2c
  131. :cb_2a
  132. for /l %%s in (1,1,%bcTotalServers%) do set bcSrvName[%%s]=
  133. set bcTotalServers=
  134. :cb_2b
  135. if "%1"=="err1" echo * That is not a valid selection! *&echo.
  136. echo How many servers are there?
  137. echo.
  138. set /p bcTotalServers=": "
  139. if "%bcTotalServers%"=="0" goto :config_cancel
  140. set tmpvalid=0
  141. for /l %%s in (1,1,50) do if "%bcTotalServers%"=="%%s" set tmpvalid=1
  142. if "%tmpvalid%"=="0" call :cb_2b err1
  143. goto :cb_3
  144.  
  145. :cb_2c
  146. echo I read the BungeeCord config and I think I found %bcTotalServers% servers:
  147. echo.
  148. for /l %%s in (1,1,%bcTotalServers%) do (
  149.   echo Server %%s: !bcSrvName[%%s]!
  150. )
  151. echo.
  152. echo Is this correct?
  153. echo.
  154. choice /n
  155. if "%errorlevel%"=="1" goto :cbm_1
  156. if "%errorlevel%"=="2" goto :cb_2a
  157. goto :eof
  158.  
  159. :cbm_1
  160. cls
  161. set bcName=
  162. echo Configuring BungeeCord Instance
  163. echo.
  164. echo This configures the console that runs the BungeeCord.jar, not the servers.
  165. echo.
  166. if "%1"=="err1" echo * You must give me a name! *&echo.
  167. echo What is the instance name?
  168. echo.
  169. set /p tmpsn=": "
  170. if "%tmpsn%"=="" call :cbm_1 err1
  171. set bcName=%tmpsn%
  172. goto :cbm_2
  173.  
  174. :cbm_2
  175. cls
  176. echo Configuring BungeeCord Instance
  177. echo.
  178. set bcJAR=
  179. set /a tmpcounter=0
  180. set tmpjar=
  181. echo Which JAR file will the server be using?
  182. echo.
  183. for /f "tokens=*" %%s in ('dir "%bcPath%\*.jar" /b') do (
  184.   set /a tmpcounter=!tmpcounter!+1
  185.   echo [!tmpcounter!] - %%s
  186. )
  187. echo.
  188. echo [J]ar is not listed!
  189. echo.
  190. set /p tmpjar="Selection: "
  191. if /i "%tmpjar%"=="j" goto :cbm_setcustomjar
  192. if /i "%tmpjar%" neq "c" if /i "%tmpjar%" neq "j" (
  193.   set /a tmpcounter=0
  194.   for /f "tokens=*" %%s in ('dir "%bcPath%\*.jar" /b') do (
  195.     set /a tmpcounter=!tmpcounter!+1
  196.     if "!tmpcounter!"=="%tmpjar%" set bcJAR=%%s
  197.   )
  198. )
  199. goto :cbm_3
  200.  
  201. :cbm_setcustomjar
  202. set bcJAR=
  203. echo.
  204. echo Please type the JAR complete filename {e.g. BungeeCord.jar}
  205. echo.
  206. set /p bcJAR=": "
  207. if not exist "%bcPath%\%bcJAR%" (
  208.   echo.
  209.   echo I'm going to use the file you entered, but I did not find it in the server path.
  210.   echo If the server doesn't start, check the filename and be sure you have it right.
  211.   echo.
  212.   pause
  213. )
  214. goto :cbm_3
  215.  
  216. :cbm_3
  217. cls
  218. set bcParams=
  219. echo Configuring BungeeCord Instance
  220. echo.
  221. echo Please enter any Java parameters you want to use.
  222. echo.
  223. echo (e.g. -Xms1G -Xmx4G to set a 1 GB initial heap and 4 GB max heap or any others)
  224. echo.
  225. set /p bcParams=": "
  226. goto :cbm_4
  227.  
  228. :cbm_4
  229. set bcRestartLimit=
  230. cls
  231. echo Configuring BungeeCord Instance
  232. echo.
  233. if "%1"=="err1" echo * That is not a valid selection! *&echo.
  234. echo When this server stops, it can automatically be restarted.  You can optionally
  235. echo limit the number of restarts if you wish.
  236. echo.
  237. echo Enter the number of restarts allowed before it just stops.  You can enter 0
  238. echo to disable restarting entirely (i.e. don't ever try to restart) or you can
  239. echo enter * to not limit the number of restarts.
  240. echo.
  241. set /p bcRestartLimit=": "
  242. if "%bcRestartLimit%"=="*" goto :cbm_5
  243. set tmpvalid=0
  244. for /l %%s in (0,1,100) do if "%bcRestartLimit%"=="%%s" set tmpvalid=1
  245. if "%tmpvalid%"=="0" call :cbm_4 err1
  246. goto :cbm_5
  247.  
  248. :cbm_5
  249. if "%bcRestartLimit%"=="0" set bcRestartDelay=3&goto :cbm_6
  250. set bcRestartDelay=
  251. cls
  252. echo Configuring BungeeCord Instance
  253. echo.
  254. if "%1"=="err1" echo * That is not a valid selection! *&echo.
  255. echo When the server stops, it will prompt to ask if you wish to stop the
  256. echo restart process.  It will wait a certain number of seconds, then
  257. echo it will assume yes and restart itself.
  258. echo.
  259. echo How many seconds should it wait?  (1-30)
  260. set /p bcRestartDelay=": "
  261. set tmpvalid=0
  262. for /l %%s in (1,1,30) do if "%bcRestartDelay%"=="%%s" set tmpvalid=1
  263. if "%tmpvalid%"=="0" call :cbm_5 err1
  264. set tmpcolor=
  265. goto :cbm_6
  266.  
  267. :cbm_6
  268. set bcColors=
  269. if "%tmpcolor%"=="" set tmpcolor=07
  270. cls
  271. echo Configuring BungeeCord Instance
  272. echo.
  273. color %tmpcolor%
  274. echo You can set what color scheme to use for the console.
  275. echo.
  276. echo 1 - Dark Blue       9 - Blue
  277. echo 2 - Dark Green      A - Green
  278. echo 3 - Dark Cyan       B - Cyan
  279. echo 4 - Dark Red        C - Red
  280. echo 5 - Dark Purple     D - Purple
  281. echo 6 - Dark Yellow     E - Yellow
  282. echo 7 - Grey            F - White
  283. echo 8 - Dark Grey       0 - Black
  284. echo.
  285. echo If, when the screen sets color to preview, you cannot read the menu
  286. echo just hit enter on the color selection and it will reset itself.
  287. echo.
  288. echo If you like what you have, enter S for background color to save.
  289. echo.
  290. echo Background color:
  291. set /p tmpcolora=": "
  292. if "%tmpcolora%"=="" set tmpcolor=07&goto :cbm_6
  293. if /i "%tmpcolora%"=="s" set bcColors=%tmpcolor%&goto :cbm_7
  294. echo Foreground (i.e. text) color:
  295. set /p tmpcolorb=": "
  296. set tmpcolor=%tmpcolora%%tmpcolorb%
  297. goto :cbm_6
  298.  
  299. :cbm_7
  300. color 07
  301. cls
  302. echo Now that we've configured the main BungeeCord instance, we need
  303. echo to configure all the servers it will be handling.
  304. echo.
  305. pause
  306. goto :cb_3
  307.  
  308. :cb_3
  309. cls
  310. set tmpsn=
  311. echo Configuring BungeeCord server %curBCSC%
  312. echo.
  313. if "%1"=="err1" echo * You must give me a name! *&echo.
  314. echo What is the server name?
  315. echo.
  316. if "!bcSrvName[%curBCSC%]!" neq "" echo Press enter to use !bcSrvName[%curBCSC%]!&echo.
  317. set /p tmpsn=": "
  318. if "%tmpsn%"=="" (
  319.   if "!bcSrvName[%curBCSC%]!" == "" call :cb_3 err1
  320.   goto :cb_4
  321. )
  322. set bcSrvName[%curBCSC%]=%tmpsn%
  323. goto :cb_4
  324.  
  325. :cb_4
  326. cls
  327. set tmpsn=
  328. set bcSrvPath[%curBCSC%]=
  329. echo Configuring BungeeCord server %curBCSC% - !bcSrvName[%curBCSC%]!
  330. echo.
  331. if "%1"=="err1" echo * That path is invalid! *&echo.
  332. echo What is the path to server files? (where the JAR file is)
  333. echo.
  334. set /p tmpsn=": "
  335. if "%tmpsn%"=="" call :cb_4 err1
  336. if not exist "%tmpsn%" call :cb_4 err1
  337. set bcSrvPath[%curBCSC%]=%tmpsn%
  338. goto :cb_5
  339.  
  340. :cb_5
  341. cls
  342. echo Configuring BungeeCord server %curBCSC% - !bcSrvName[%curBCSC%]!
  343. echo.
  344. set bcSrvJAR[%curBCSC%]=
  345. set /a tmpcounter=0
  346. set tmpjar=
  347. echo Which JAR file will the server be using?
  348. echo.
  349. for /f "tokens=*" %%s in ('dir "!bcSrvPath[%curBCSC%]!\*.jar" /b') do (
  350.   set /a tmpcounter=!tmpcounter!+1
  351.   echo [!tmpcounter!] - %%s
  352. )
  353. echo.
  354. echo [J]ar is not listed!
  355. echo.
  356. set /p tmpjar="Selection: "
  357. if /i "%tmpjar%"=="j" goto :cb_setcustomjar
  358. if /i "%tmpjar%" neq "c" if /i "%tmpjar%" neq "j" (
  359.   set /a tmpcounter=0
  360.   for /f "tokens=*" %%s in ('dir "!bcSrvPath[%curBCSC%]!\*.jar" /b') do (
  361.     set /a tmpcounter=!tmpcounter!+1
  362.     if "!tmpcounter!"=="%tmpjar%" set bcSrvJAR[%curBCSC%]=%%s
  363.   )
  364. )
  365. goto :cb_6
  366.  
  367. :cb_setcustomjar
  368. set bcSrvJAR[%curBCSC%]=
  369. echo.
  370. echo Please type the JAR complete filename {e.g. spigot-1.12.2.jar}
  371. echo.
  372. set /p bcSrvJAR[%curBCSC%]=": "
  373. if not exist "!bcSrvPath[%curBCSC%]!\!bcSrvJAR[%curBCSC%]!" (
  374.   echo.
  375.   echo I'm going to use the file you entered, but I did not find it in the server path.
  376.   echo If the server doesn't start, check the filename and be sure you have it right.
  377.   echo.
  378.   pause
  379. )
  380. goto :cb_6
  381.  
  382. :cb_6
  383. cls
  384. set bcSrvParams[%curBCSC%]=
  385. echo Configuring BungeeCord server %curBCSC% - !bcSrvName[%curBCSC%]!
  386. echo.
  387. echo Please enter any Java parameters you want to use.
  388. echo.
  389. echo (e.g. -Xms1G -Xmx4G to set a 1 GB initial heap and 4 GB max heap or any others)
  390. echo.
  391. set /p bcSrvParams[%curBCSC%]=": "
  392. goto :cb_7
  393.  
  394. :cb_7
  395. set bcSrvRestartLimit[%curBCSC%]=
  396. cls
  397. echo Configuring BungeeCord server %curBCSC% - !bcSrvName[%curBCSC%]!
  398. echo.
  399. if "%1"=="err1" echo * That is not a valid selection! *&echo.
  400. echo When this server stops, it can automatically be restarted.  You can optionally
  401. echo limit the number of restarts if you wish.
  402. echo.
  403. echo Enter the number of restarts allowed before it just stops.  You can enter 0
  404. echo to disable restarting entirely (i.e. don't ever try to restart) or you can
  405. echo enter * to not limit the number of restarts.
  406. echo.
  407. set /p bcSrvRestartLimit[%curBCSC%]=": "
  408. if "!bcSrvRestartLimit[%curBCSC%]!"=="*" goto :cb_8
  409. set tmpvalid=0
  410. for /l %%s in (0,1,100) do if "!bcSrvRestartLimit[%curBCSC%]!"=="%%s" set tmpvalid=1
  411. if "%tmpvalid%"=="0" call :cb_7 err1
  412. goto :cb_8
  413.  
  414. :cb_8
  415. if "!bcSrvRestartLimit[%curBCSC%]!"=="0" set !bcSrvRestartDelay[%curBCSC%]!=3&goto :cb_9
  416. set bcSrvRestartDelay[%curBCSC%]=
  417. cls
  418. echo Configuring BungeeCord server %curBCSC% - !bcSrvName[%curBCSC%]!
  419. echo.
  420. if "%1"=="err1" echo * That is not a valid selection! *&echo.
  421. echo When the server stops, it will prompt to ask if you wish to stop the
  422. echo restart process.  It will wait a certain number of seconds, then
  423. echo it will assume yes and restart itself.
  424. echo.
  425. echo How many seconds should it wait?  (1-30)
  426. set /p bcSrvRestartDelay[%curBCSC%]=": "
  427. set tmpvalid=0
  428. for /l %%s in (1,1,30) do if "!bcSrvRestartDelay[%curBCSC%]!"=="%%s" set tmpvalid=1
  429. if "%tmpvalid%"=="0" call :cb_8 err1
  430. set tmpcolor=
  431. goto :cb_9
  432.  
  433. :cb_9
  434. set bcSrvColors[%curBCSC%]=
  435. if "%tmpcolor%"=="" set tmpcolor=07
  436. cls
  437. echo Configuring BungeeCord server %curBCSC% - !bcSrvName[%curBCSC%]!
  438. echo.
  439. color %tmpcolor%
  440. echo You can set what color scheme to use for the console.
  441. echo.
  442. echo 1 - Dark Blue       9 - Blue
  443. echo 2 - Dark Green      A - Green
  444. echo 3 - Dark Cyan       B - Cyan
  445. echo 4 - Dark Red        C - Red
  446. echo 5 - Dark Purple     D - Purple
  447. echo 6 - Dark Yellow     E - Yellow
  448. echo 7 - Grey            F - White
  449. echo 8 - Dark Grey       0 - Black
  450. echo.
  451. echo If, when the screen sets color to preview, you cannot read the menu
  452. echo just hit enter on the color selection and it will reset itself.
  453. echo.
  454. echo If you like what you have, enter S for background color to save.
  455. echo.
  456. echo Background color:
  457. set /p tmpcolora=": "
  458. if "%tmpcolora%"=="" set tmpcolor=07&goto :cb_10
  459. if /i "%tmpcolora%"=="s" set bcSrvColors[%curBCSC%]=%tmpcolor%&goto :cb_10
  460. echo Foreground (i.e. text) color:
  461. set /p tmpcolorb=": "
  462. set tmpcolor=%tmpcolora%%tmpcolorb%
  463. goto :cb_9
  464.  
  465. :cb_10
  466. color 07
  467. set /a curBCSC=%curBCSC%+1
  468. echo curBCSC = %curBCSC% [!curBCSC!]
  469. echo bcTotalServers = %bcTotalServers% [!bcTotalServers!]
  470. if %curBCSC% leq %bcTotalServers% goto :cb_3
  471. cls
  472. echo All done - now lets verify the information:
  473. echo.
  474. echo ----------------------------------------------------
  475. echo BungeeCord Instance - %bcName%
  476. echo   Path         : %bcPath%
  477. echo   JAR          : %bcJAR%
  478. echo   Params       : %bcParams%
  479. echo   Restart Count: %bcRestartLimit%
  480. echo   Restart Delay: %bcRestartDelay%
  481. echo   Colors       : %bcColors%
  482.  
  483. for /l %%s in (1,1,%bcTotalServers%) do (
  484.   echo ----------------------------------------------------
  485.   echo Server %%s - !bcSrvName[%%s]!
  486.   echo   Path         : !bcSrvPath[%%s]!
  487.   echo   JAR          : !bcSrvJAR[%%s]!
  488.   echo   Params       : !bcSrvParams[%%s]!
  489.   echo   Restart Count: !bcSrvRestartLimit[%%s]!
  490.   echo   Restart Delay: !bcSrvRestartDelay[%%s]!
  491.   echo   Colors       : !bcSrvColors[%%s]!
  492. )
  493. echo ----------------------------------------------------
  494. echo.
  495. echo Is this correct?
  496. echo.
  497. choice /n
  498. if "%errorlevel%"=="1" goto :cb_11
  499. if "%errorlevel%"=="2" set curBCSC=1&goto :cb_3
  500. goto :eof
  501.  
  502. :cb_11
  503. cls
  504. echo Saving configuration profile.  Please give the profile a name:
  505. echo.
  506. set /p configProfile=": "
  507. if "%configProfile%"=="" set configProfile=launcher
  508. if exist %configProfile%.mcscfg (
  509.   for /f "tokens=1,6" %%s in ('echo.^|date') do if "%%s"=="The" set datecode=%%t
  510.   for /f "tokens=1,5" %%s in ('echo.^|time') do if "%%s"=="The" set timecode=%%t
  511.   set tmpnewfile=%configProfile%.mcscfg_%datecode:~0,2%%datecode:~3,2%%datecode:~6,4%-%timecode:~0,2%%timecode:~3,2%%timecode:~6,2%
  512.   ren %configProfile%.mcscfg %tmpnewfile%
  513.   echo An existing configuration was present, renamed it to %tmpnewfile%
  514.   echo.
  515. )
  516. echo configType               b>%configProfile%.mcscfg
  517. echo bcName                   %bcName% >>%configProfile%.mcscfg
  518. echo bcPath                   %bcPath% >>%configProfile%.mcscfg
  519. echo bcJAR                    %bcJAR% >>%configProfile%.mcscfg
  520. echo bcParams                 %bcParams% >>%configProfile%.mcscfg
  521. echo bcRestartLimit           %bcRestartLimit% >>%configProfile%.mcscfg
  522. echo bcRestartDelay           %bcRestartDelay% >>%configProfile%.mcscfg
  523. echo bcColors                 %bcColors% >>%configProfile%.mcscfg
  524. echo bcTotalServers           %bcTotalServers% >>%configProfile%.mcscfg
  525. for /l %%s in (1,1,9) do (
  526.   if %%s leq %bcTotalServers% (
  527.     echo bcSrvPath[%%s]             !bcSrvPath[%%s]! >>%configProfile%.mcscfg
  528.     echo bcSrvJAR[%%s]              !bcSrvJAR[%%s]! >>%configProfile%.mcscfg
  529.     echo bcSrvParams[%%s]           !bcSrvParams[%%s]! >>%configProfile%.mcscfg
  530.     echo bcSrvRestartLimit[%%s]     !bcSrvRestartLimit[%%s]! >>%configProfile%.mcscfg
  531.     echo bcSrvRestartDelay[%%s]     !bcSrvRestartDelay[%%s]! >>%configProfile%.mcscfg
  532.     echo bcSrvColors[%%s]           !bcSrvColors[%%s]! >>%configProfile%.mcscfg
  533.   )
  534. )
  535. for /l %%s in (10,1,50) do (
  536.   if %%s leq %bcTotalServers% (
  537.     echo bcSrvPath[%%s]            !bcSrvPath[%%s]! >>%configProfile%.mcscfg
  538.     echo bcSrvJAR[%%s]             !bcSrvJAR[%%s]! >>%configProfile%.mcscfg
  539.     echo bcSrvParams[%%s]          !bcSrvParams[%%s]! >>%configProfile%.mcscfg
  540.     echo bcSrvRestartLimit[%%s]    !bcSrvRestartLimit[%%s]! >>%configProfile%.mcscfg
  541.     echo bcSrvRestartDelay[%%s]    !bcSrvRestartDelay[%%s]! >>%configProfile%.mcscfg
  542.     echo bcSrvColors[%%s]          !bcSrvColors[%%s]! >>%configProfile%.mcscfg
  543.   )
  544. )
  545. echo Config profile saved!
  546. echo.
  547. goto :eof
  548.  
  549. :config_single
  550. :cs_1
  551. cls
  552. set srvPath=
  553. if "%1"=="err1" echo * You need to tell me the path! *&echo.
  554. if "%1"=="err2" echo * That path is not valid! *&echo.
  555. echo Please enter the path to where the server files are (i.e. where is the JAR file)
  556. echo.
  557. set /p srvPath="Path: "
  558. if "%srvPath%"=="" call :cs_1 err1
  559. if not exist "%srvPath%" call :cs_1 err2
  560.  
  561. :cs_2
  562. set srvJAR=
  563. set /a tmpcounter=0
  564. cls
  565. echo Which JAR file will the server be using?
  566. echo.
  567. for /f "tokens=*" %%s in ('dir "%srvPath%\*.jar" /b') do (
  568.   set /a tmpcounter=!tmpcounter!+1
  569.   echo [!tmpcounter!] - %%s
  570. )
  571. echo.
  572. echo [J]ar is not listed!
  573. echo.
  574. set /p tmpjar="Selection: "
  575. if /i "%tmpjar%"=="j" goto :cs_setcustomjar
  576. if /i "%tmpjar%" neq "c" if /i "%tmpjar%" neq "j" (
  577.   set /a tmpcounter=0
  578.   for /f "tokens=*" %%s in ('dir "%srvPath%\*.jar" /b') do (
  579.     set /a tmpcounter=!tmpcounter!+1
  580.     if "!tmpcounter!"=="%tmpjar%" set srvJAR=%%s
  581.   )
  582. )
  583. goto :cs_3
  584.  
  585. :cs_setcustomjar
  586. echo.
  587. echo Please type the JAR complete filename {e.g. spigot-1.12.2.jar}
  588. echo.
  589. set /p srvJAR=": "
  590. if not exist "%srvPath%\%srvJAR%" (
  591.   echo.
  592.   echo I'm going to use the file you entered, but I did not find it in the server path.
  593.   echo If the server doesn't start, check the filename and be sure you have it right.
  594.   echo.
  595.   pause
  596. )
  597. goto :cs_3
  598.  
  599. :cs_3
  600. set srvParams=
  601. cls
  602. echo Please enter any Java parameters you want to use.
  603. echo.
  604. echo (e.g. -Xms1G -Xmx4G to set a 1 GB initial heap and 4 GB max heap or any others)
  605. echo.
  606. set /p srvParams=": "
  607.  
  608. :cs_4
  609. set srvName=
  610. cls
  611. echo What is the name of the server?
  612. echo.
  613. set /p srvName=": "
  614. if "%srvName%"=="" set srvName=Minecraft Server
  615.  
  616. :cs_5
  617. set restartLimit=
  618. cls
  619. if "%1"=="err1" echo * That is not a valid selection! *&echo.
  620. echo When the server stops, it can automatically be restarted.  You can optionally
  621. echo limit the number of restarts if you wish.
  622. echo.
  623. echo Enter the number of restarts allowed before it just stops.  You can enter 0
  624. echo to disable restarting entirely (i.e. don't ever try to restart) or you can
  625. echo enter * to not limit the number of restarts.
  626. echo.
  627. set /p restartLimit=": "
  628. if "%restartLimit%"=="*" goto :cs_6
  629. set tmpvalid=0
  630. for /l %%s in (0,1,100) do if "%restartLimit%"=="%%s" set tmpvalid=1
  631. if "%tmpvalid%"=="0" call :cs_5 err1
  632.  
  633. :cs_6
  634. if "%restartLimit%"=="0" set restartDelay=3&goto :cs_7
  635. set restartDelay=
  636. cls
  637. if "%1"=="err1" echo * That is not a valid selection! *&echo.
  638. echo When the server stops, it will prompt to ask if you wish to stop the
  639. echo restart process.  It will wait a certain number of seconds, then
  640. echo it will assume yes and restart itself.
  641. echo.
  642. echo How many seconds should it wait?  (1-30)
  643. set /p restartDelay=": "
  644. set tmpvalid=0
  645. for /l %%s in (1,1,30) do if "%restartDelay%"=="%%s" set tmpvalid=1
  646. if "%tmpvalid%"=="0" call :cs_6 err1
  647. set tmpcolor=
  648. goto :cs_7
  649.  
  650. :cs_7
  651. set consoleColors=
  652. if "%tmpcolor%"=="" set tmpcolor=07
  653. cls
  654. color %tmpcolor%
  655. echo You can set what color scheme to use for the console.
  656. echo.
  657. echo 1 - Dark Blue       9 - Blue
  658. echo 2 - Dark Green      A - Green
  659. echo 3 - Dark Cyan       B - Cyan
  660. echo 4 - Dark Red        C - Red
  661. echo 5 - Dark Purple     D - Purple
  662. echo 6 - Dark Yellow     E - Yellow
  663. echo 7 - Grey            F - White
  664. echo 8 - Dark Grey       0 - Black
  665. echo.
  666. echo If, when the screen sets color to preview, you cannot read the menu
  667. echo just hit enter on the color selection and it will reset itself.
  668. echo.
  669. echo If you like what you have, enter S for background color to save.
  670. echo.
  671. echo Background color:
  672. set /p tmpcolora=": "
  673. if "%tmpcolora%"=="" set tmpcolor=07&goto :cs_7
  674. if /i "%tmpcolora%"=="s" set consoleColors=%tmpcolor%&goto :cs_8
  675. echo Foreground (i.e. text) color:
  676. set /p tmpcolorb=": "
  677. set tmpcolor=%tmpcolora%%tmpcolorb%
  678. goto :cs_7
  679.  
  680. :cs_8
  681. color 07
  682. cls
  683. echo OK, please verify this is correct:
  684. echo.
  685. echo Server Name   : %srvName%
  686. echo Path to Server: %srvPath%
  687. echo JAR Filename  : %srvJAR%
  688. echo Parameters    : %srvParams%
  689. echo Restarts      : %restartLimit%
  690. if "%restartLimit%" neq "0" echo Restart Delay : %restartDelay%
  691. echo Color Scheme  : %consoleColors%
  692. echo.
  693. echo (Y)es, it is right
  694. echo (N)o, start over
  695. echo.
  696. choice /c YNC /n
  697. if "%errorlevel%"=="1" goto :cs_save
  698. if "%errorlevel%"=="2" goto :cs_1
  699. goto :cs_8
  700.  
  701. :cs_save
  702. cls
  703. echo Saving configuration profile.  Please give the profile a name:
  704. echo.
  705. set /p configProfile=": "
  706. if "%configProfile%"=="" set configProfile=launcher
  707. if exist "%configProfile%.mcscfg" (
  708.   for /f "tokens=1,6" %%s in ('echo.^|date') do if "%%s"=="The" set datecode=%%t
  709.   for /f "tokens=1,5" %%s in ('echo.^|time') do if "%%s"=="The" set timecode=%%t
  710.   set tmpnewfile=%configProfile%.mcscfg_%datecode:~0,2%%datecode:~3,2%%datecode:~6,4%-%timecode:~0,2%%timecode:~3,2%%timecode:~6,2%
  711.   ren "%configProfile%.mcscfg" "%tmpnewfile%"
  712.   echo An existing configuration was present, renamed it to %tmpnewfile%
  713.   echo.
  714. )
  715. echo configType               s>"%configProfile%.mcscfg"
  716. echo srvName                  %srvName% >>"%configProfile%.mcscfg"
  717. echo srvPath                  %srvPath% >>"%configProfile%.mcscfg"
  718. echo srvJAR                   %srvJAR% >>"%configProfile%.mcscfg"
  719. echo srvParams                %srvParams% >>"%configProfile%.mcscfg"
  720. echo restartLimit             %restartLimit% >>"%configProfile%.mcscfg"
  721. echo consoleColors            %consoleColors% >>"%configProfile%.mcscfg"
  722. echo restartDelay             %restartDelay% >>"%configProfile%.mcscfg"
  723. echo.
  724. echo The profile has been saved!
  725. echo.
  726. goto :eof
  727.  
  728. :cb_yml
  729. set /a bcTotalServers=0
  730. set serverCollecting=0
  731. for /f "tokens=1" %%s in (%bcpath%\config.yml) do call :procline "%%s"
  732. goto :eof
  733. :procline
  734. set "line=%~1"
  735. if /i "%line:~0,8%"=="timeout:" set serverCollecting=0
  736. if "!serverCollecting!"=="1" (
  737.   set tmpdata=%line:~0,-1%
  738.   if /i "%tmpdata%" neq "motd" if /i "%tmpdata%" neq "address" if /i "%tmpdata%" neq "restricted" if /i "%tmpdata%" neq "timeout" if "%tmpdata%" neq "" (
  739.     set /a bcTotalServers=!bcTotalServers!+1
  740.     set bcSrvName[!bcTotalServers!]=%tmpdata%
  741.   )
  742. )
  743. if /i "%line:~0,8%"=="servers:" set serverCollecting=1
  744. goto :eof
  745.  
  746. :config_cancel
  747. cls
  748. echo Configuration cancelled!
  749. goto :eof
Add Comment
Please, Sign In to add comment