Advertisement
Guest User

Minecraft FTB Server Batch

a guest
Jul 11th, 2018
1,338
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 5.80 KB | None | 0 0
  1. @if NOT "%FTB_VERBOSE%"=="yes" (
  2.     @echo off
  3. )
  4. :ramamount
  5. REM Creating a Newline variable (the two blank lines are required!)
  6. set NLM=^
  7.  
  8.  
  9. set NL=^^^%NLM%%NLM%^%NLM%%NLM%
  10. title Direwolf20 Server Startup
  11. cls
  12. for /f "skip=1" %%p in ('wmic os get freephysicalmemory') do (
  13.   set m=%%p
  14.   goto :ramamountagain
  15. )
  16. :ramamountagain
  17. set /A RamAmountReal=%m%/1024
  18. color 0A
  19. echo -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  20. echo =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-Server Start Made by xTekBlue-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  21. echo -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  22. echo -
  23. echo -
  24. echo =================
  25. echo 1024 = 1GB of RAM
  26. echo 2048 = 2GB of RAM
  27. echo 3072 = 3GB of RAM
  28. echo 4096 = 4GB of RAM
  29. echo 8192 = 8GB of RAM
  30. echo =================
  31. echo -
  32. echo - Max Ram Amount: %RamAmountReal% -- Best to set way lower than this!
  33. echo -
  34. echo -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  35. echo =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-How Much Ram Do You Want to use=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  36. echo -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  37. set /p RamAmount=%NL%
  38. color 0F
  39. SET "var="&for /f "delims=0123456789" %%i in ("%RamAmount%") do set var=%%i
  40. if defined var (
  41.     cls
  42.     color 0C
  43.     echo %RamAmount% is NOT a valid number, please only use 0-9 and NO commas or "MB", try again.
  44.     timeout 5 >nul
  45.     color 0F
  46.     goto ramamount
  47. )
  48.  
  49. cls
  50. call settings.bat
  51.  
  52. if NOT EXIST %JARFILE% (
  53.     goto install
  54. )
  55. if NOT EXIST libraries\%LAUNCHWRAPPER% (
  56.     goto install
  57. )
  58. goto skipinstall
  59.  
  60. :install
  61. echo running install script!
  62. call FTBInstall.bat
  63. :skipinstall
  64.  
  65. REM Check if java in path
  66. REM TODO: use %JAVACMD%
  67. where java > NUL 2>&1
  68.  
  69. if %ERRORLEVEL% NEQ 0 (
  70.     color 0C
  71.     echo No java binary in path. Can't run server, exiting...
  72.     timeout 5 >nul
  73.     color 0F
  74.     goto :end
  75. )
  76.  
  77. REM Test JVM
  78. REM e.g. 32-bit JVM does not have server\jvm.dll library
  79. java -server -version > java-test.log 2>&1
  80.  
  81. if %ERRORLEVEL% NEQ 0 (
  82.     echo Detected following JVM error:
  83.     echo =======================================
  84.     more java-test.log
  85.     echo =======================================
  86.     echo JVM test failed. Can't run server, Exiting...
  87.     timeout 5 >nul
  88.     goto :end
  89. )
  90.  
  91. if not exist eula.txt (
  92.     color 0C
  93.     echo Missing eula.txt. Startup will fail and eula.txt will be created
  94.     echo Make sure to read eula.txt before playing!
  95.     timeout 5 >nul
  96.     goto startserver
  97. )
  98.  
  99. find "eula=false" eula.txt 1 > NUL 2>&1
  100. if %ERRORLEVEL% EQU 0 (
  101.     color 0C
  102.     cls
  103.     echo -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  104.     echo =-=-=-=-=-eula.txt found and is false, please agree to eula before starting.=-=-=-=-=-=-=
  105.     echo -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  106.     timeout 7 >nul
  107.     cls
  108.     color 0F
  109.     goto :end
  110. )
  111. if %ERRORLEVEL% EQU 1 (
  112.     color 0A
  113.     cls
  114.     echo -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  115.     echo =-=-=-=-=-=-=-=-eula.txt found and is true, starting server.=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  116.     echo -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  117.     timeout 3 >nul
  118.     color 0F
  119.     cls
  120. )
  121.  
  122. del /f /q autostart.stamp > nul 2>&1
  123.  
  124. if "%RamAmount%"=="" (
  125. set RamAmount=0
  126. )
  127.  
  128. :startserver
  129. title Determining Ram Amount...
  130. color 0C
  131. cls
  132. echo Determining Ram Amount...
  133. timeout 2 >nul
  134. cls
  135. for /f "skip=1" %%p in ('wmic os get freephysicalmemory') do (
  136.   set m=%%p
  137.   goto :ramcheck
  138. )
  139. :ramcheck
  140. set /A RamByteSize=%RamAmount%*1024
  141. if %m% LEQ %RamByteSize% (
  142.     color 0C
  143.     echo -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  144.     echo =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-RAM Size is to large, try less=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  145.     echo -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  146.     echo Rebooting.
  147.     timeout 2 >nul
  148.     cls
  149.     echo -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  150.     echo =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-RAM Size is to large, try less=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  151.     echo -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  152.     echo Rebooting..
  153.     timeout 2 >nul
  154.     cls
  155.     echo -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  156.     echo =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-RAM Size is to large, try less=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  157.     echo -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  158.     echo Rebooting...
  159.     timeout 1 >nul
  160.     goto :ramamount
  161. )
  162. color 0A
  163. echo Ram Size Allowed.
  164. timeout 3 >nul
  165. cls
  166. echo Available Memory: %RamAmountReal% MB
  167. echo Physical Memory Used by Server: %RamAmount% MB (RAM Usage)
  168. timeout 8 >nul
  169. cls
  170. color 0A
  171. echo Attempting to run Server...
  172. timeout 2 >nul
  173. cls
  174. color 0F
  175. color 0F
  176. title Server Running...
  177. java -server -Xmx%RamAmount%M -XX:PermSize=%PERMGEN_SIZE% %JAVA_PARAMETERS% -jar %FORGEJAR% nogui
  178.  
  179. echo Server Stopped!
  180. timeout 3 >nul
  181. cls
  182. title Direwolf20 Server Startup
  183. color 0A
  184. echo -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  185. echo -=-=-=-=-=-=-=-=-=-=-=-=Do you want to restart the Server? (y/n)-=-=-=-=-=-=-=-=-=-=-=-=-
  186. echo -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  187. set /p ask=%NL%
  188. if %ask%==y goto :ramamount
  189. if %ask%==Y goto :ramamount
  190. if %ask%==yes goto :ramamount
  191. if %ask%==Yes goto :ramamount
  192. if %ask%==YES goto :ramamount
  193. if %ask%==n goto :end
  194. if %ask%==no goto :end
  195. if %ask%==N goto :end
  196. if %ask%==No goto :end
  197. if %ask%==NO goto :end
  198.  
  199. :end
  200. title Exiting Console...
  201. color 0C
  202. echo Exiting...
  203. timeout 5 >nul
  204. exit /B
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement