Skip to content

Commit afdc68d

Browse files
authored
Windows Start Script - v1.4.4
1 parent 0cbc7f3 commit afdc68d

File tree

1 file changed

+35
-18
lines changed

1 file changed

+35
-18
lines changed

ZStart.bat

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ title ZStart
1212

1313
::--CONSOLE--::
1414
::# Sets the console title.
15-
SET TITLE="Minecraft: Server Instance"
15+
SET TITLE="UT:Re-Birth: Build+"
1616
::# Sets the server location.
1717
SET SERVER_PATH="./"
1818
::# Loop the server, no matter how the server closes, it will restart.
@@ -34,16 +34,19 @@ SET EXIT=true
3434
::# The name of your server's JAR file.
3535
::# Side note: if you're not using Paper (http://papermc.io) or one of it's forks,
3636
::# (https://purpur.pl3x.net) then you should really switch.
37-
SET JAR_NAME="server.jar"
37+
SET JAR_NAME="purpur-1.16.5-1171.jar"
3838
::# The location of your server's JAR.
3939
SET JAR_PATH="./"
40+
::# Sets the CPU priority for the java program (Server).
41+
::# Values: REALTIME | LOW, BELOWNORMAL, NORMAL, ABOVENORMAL, HIGH
42+
SET PRIORITY=REALTIME
4043
::# Skips the need of eula.txt = true.
4144
SET EULA-SKIP=false
4245
::# Removes warnings about outdated server builds.
4346
SET ADVANCED-MODE=true
4447
::# Your server's JAR parameters.
45-
::# In order to see all of the parameters, set below --help.
46-
::# (This wont let the server start, but will show all parameters aviable)
48+
::# In order to see all the parameters, set below --help.
49+
::# (This won't let the server start, but will show all parameters available)
4750
::# More info:
4851
::# https://minecraft.fandom.com/wiki/Tutorials/Setting_up_a_server
4952
::# https://bukkit.gamepedia.com/CraftBukkit_Command_Line_Arguments
@@ -56,20 +59,20 @@ SET PARAMETERS="--nogui"
5659
::# You can use this to determine which java you want to use.
5760
::# Consider using java 11 or latest if possible, and changing to OpenJDK.
5861
::# (Change to OpenJDK here! https://adoptopenjdk.net/)
59-
SET JAVA_BINARY="java"
62+
SET JAVA_BINARY="C:\Program Files\AdoptOpenJDK\jdk-16.0.1.9-hotspot\bin\java.exe"
6063
::# Allocate the server's max&min heap-memory.
6164
::# If you want to allocate more than 4GB you will need Java 64 bits.
6265
SET MAX-MEMORY=4096
6366
SET MIN-MEMORY=1024
6467
::# Select the memory unit to be used.
6568
::# Values: KB, MB, GB.
6669
SET HEAP_UNIT=MB
67-
::# This attemps to self-calculate the nursery max&min memory based on max-heap-memory.
70+
::# This attempts to self-calculate the nursery max&min memory based on max-heap-memory.
6871
::# Java already sets this itself. OpenJ9 is needed.
6972
SET NURSERY=false
7073

7174
::--FLAGS--::
72-
::# DEFAULTS: Always enabled, independant of other group flags.
75+
::# DEFAULTS: Always enabled, independently of other group flags.
7376
::# G1GC: Aikar's G1GC flags. (https://mcflags.emc.gs)
7477
::# ZGC: Aikar based ZGC flags. (Exists from J11, decent from J14, Latest is always better.)
7578

@@ -129,44 +132,55 @@ SET Start_SERVICE=NONE
129132
::other
130133
set TITLE=%TITLE:~1,-1%
131134
set JAR_PATH=%JAR_PATH:~1,-1%
135+
set JAR_NAME=%JAR_NAME:~1,-1%
132136
set DEFAULTS=%DEFAULTS:~1,-1%
133137
set MODE=%HEAP_UNIT:~0,1%
134-
::console-server
138+
::setup
135139
title %TITLE%
136140
cd %SERVER_PATH%
141+
echo %DATE% - %TIME%
142+
::console-server
137143
if /I '%AUTO-EULA%'=='true' (
138144
@echo eula=true>"%JAR_PATH%eula.txt"
139145
)
140146
if /I '%1'=='-restart' GOTO restart
141147
if /I '%EULA-SKIP%'=='true' set agree=-DCom.mojang.eula.agree=true
142148
if /I '%ADVANCED-MODE%'=='true' set advanced=-DIReallyKnowWhatIAmDoingISwear=true
143149
::TASKS&SERVICES
144-
if %Start_TASK%'=='NONE' SCHTASKS /DELETE /TN %ServiceName%
145-
if %Start_SERVICE%'=='NONE' sc delete %ServiceName%
146-
if NOT '%Start_TASK%'=='NONE' if '%Start_SERVICE%'=='NONE' SCHTASKS /CREATE /TN %ServiceName% /SC %Start_TASK% /ST %TaskTime% /TR %0
147-
if NOT '%Start_SERVICE%'=='NONE' if '%Start_TASK%'=='NONE' sc create '%ServiceName%' start=%Start_SERVICE% binpath=%0
150+
schTasks /QUERY /TN %ServiceName% >NUL 2>&1
151+
if 'ERRORLEVEL'=='0' schTasks /DELETE /TN %ServiceName%
152+
153+
sc QUERY %ServiceName% >NUL 2>&1
154+
if 'ERRORLEVEL'=='0 sc delete %ServiceName%
155+
if NOT '%Start_TASK%'=='NONE' if '%Start_SERVICE%'=='NONE' (
156+
echo.
157+
schTasks /CREATE /TN %ServiceName% /SC %Start_TASK% /ST %TaskTime% /TR %0
158+
)
159+
if NOT '%Start_SERVICE%'=='NONE' if '%Start_TASK%'=='NONE' (
160+
echo.
161+
sc create '%ServiceName%' start=%Start_SERVICE% binpath=%0
162+
)
148163
::FLAGS
149164
setlocal ENABLEDELAYEDEXPANSION
150165
set "JVM_FLAGS=!%FLAGS_MODE%! %JVM_MF% %DEFAULTS% %agree% %advanced%"
151166
if /I '%MULTI_FLAGS%'=='true' set JVM_MF=!%FLAGS_MODE1%! !%FLAGS_MODE2%! !%FLAGS_MODE3%! !%FLAGS_MODE4%! !%FLAGS_MODE5%!
152-
FOR /F delims^=^"^ tokens^=* %%a in (%JVM_FLAGS%) do set JVM_FLAGS=%%a
153-
FOR /F delims^=^"^ tokens^=* %%a in (%JVM_MF%) do set JVM_MF=%%a
154167
setlocal DISABLEDELAYEDEXPANSION
155168
)
156169
:: NURSERY
157170
if '%NURSERY%'=='TRUE' (
158171
set /A NURSE_MAX=%MAX-MEMORY% * 2 / 5
159172
set /A NURSE_MIN=%MAX-MEMORY% / 4
160-
set CMD=%JAVA_BINARY% -Xmx%MAX-MEMORY%%MODE% -Xms%MIN-MEMORY%%MODE% -Xmns%NURSE_MIN%%MODE% -Xmnx%NURSE_MAX%%MODE% %JVM_FLAGS% %12flags% "%JAR_PATH%%JAR_NAME%" %PARAMETERS%
161-
) else set CMD=%JAVA_BINARY% -Xmx%MAX-MEMORY%%MODE% -Xms%MIN-MEMORY%%MODE% %JVM_FLAGS% %12flags% "%JAR_PATH%%JAR_NAME%" %PARAMETERS%
173+
set CMD=%JAVA_BINARY% -Xmx%MAX-MEMORY%%MODE% -Xms%MIN-MEMORY%%MODE% -Xmns%NURSE_MIN%%MODE% -Xmnx%NURSE_MAX%%MODE% %JVM_FLAGS% -jar "%JAR_PATH%%JAR_NAME%" %PARAMETERS%
174+
) else set CMD=%JAVA_BINARY% -Xmx%MAX-MEMORY%%MODE% -Xms%MIN-MEMORY%%MODE% %JVM_FLAGS% -jar "%JAR_PATH%%JAR_NAME%" %PARAMETERS%
162175

163176
::Start server
164-
echo %DATE% - %TIME%
165177
echo.
166178
echo Starting Server
167179
echo Loading startup parameters...
168180
echo.
169-
%CMD%
181+
start /I /B /W "%TITLE%" /%PRIORITY% %CMD%
182+
echo.
183+
echo.
170184
goto stop
171185

172186
:stop
@@ -178,6 +192,9 @@ if /I '%RESTART_LOOP%'=='true' ( goto restart
178192
goto exit
179193

180194
:exit
195+
echo.
196+
echo Exiting Server
197+
echo.
181198
if /I '%EXIT%'=='true' exit
182199

183200
:restart

0 commit comments

Comments
 (0)