11@ echo off
22title Checking dependencies...
3- set scriptVersion = v1.2.2
4- set currentConfigVersion = v1.2.2
3+ set scriptVersion = v1.3.0
4+ set currentConfigVersion = v1.3.0
55
66REM Set restart counter variables
77set " restartCount = 0"
@@ -117,20 +117,37 @@ if "%autoRestart%"=="true" (
117117
118118:runRestart
119119title %Title% ^ | Restarted: %restartCount% times
120+ REM Check if webhook URL is set and send start message
121+ if not " %webhookURL% " == " " (
122+ curl -H " Content-Type: application/json" -X POST -d " {\" content\" :\" %webhookMessageStart% \" }" %webhookURL%
123+ )
124+ REM Start the server
120125java %RAM% %args% -jar %serverName% %GUI%
121126echo .
122127echo .
123128set /A restartCount += 1
124129set " restartTime = %TIME% , %DATE% "
125130echo Server has closed or crashed...restarting now...
126131echo Server has restarted %restartCount% times. Last restart: %restartTime%
132+ REM Check if webhook URL is set and send stop message
133+ if not " %webhookURL% " == " " (
134+ curl -H " Content-Type: application/json" -X POST -d " {\" content\" :\" %webhookMessageStop% \" }" %webhookURL%
135+ )
127136goto scriptUpdater
128137
129138:runNoRestart
130139title %Title%
140+ REM Check if webhook URL is set and send start message
141+ if not " %webhookURL% " == " " (
142+ curl -H " Content-Type: application/json" -X POST -d " {\" content\" :\" %webhookMessageStart% \" }" %webhookURL%
143+ )
131144java %RAM% %args% -jar %serverName% %GUI%
132145echo .
133146echo .
147+ REM Check if webhook URL is set and send stop message
148+ if not " %webhookURL% " == " " (
149+ curl -H " Content-Type: application/json" -X POST -d " {\" content\" :\" %webhookMessageStop% \" }" %webhookURL%
150+ )
134151echo Server has closed or crashed.
135152CHOICE /N /C YN /M " Do you want to restart the server? (Y/N): "
136153if %errorlevel% == 1 goto scriptUpdater
@@ -212,6 +229,15 @@ echo [1mEnable server GUI?[0m
212229CHOICE /N /T 5 /D N /C:YN /M " GUI (Y/N): "
213230if %errorlevel% == 1 set GUI = true
214231if %errorlevel% == 2 set GUI = false
232+ cls
233+ echo [1mEnable Discord webhooks?[0m
234+ echo This will post stop/start notifications.
235+ CHOICE /N /C YN /M " Proceed with Discord webhook setup? (Y/N)"
236+ if %errorlevel% == 1 (
237+ set /p " webhookURL = Enter the Discord webhook URL: "
238+ ) else (
239+ set " webhookURL = "
240+ )
215241REM Confirm user choices
216242cls
217243echo [1;32m.............................................[0m
@@ -230,7 +256,7 @@ echo # Configuration File Version > .\config\StartupScript.conf
230256echo configVersion=%currentConfigVersion% >> .\config\StartupScript.conf
231257echo # >> .\config\StartupScript.conf
232258echo # --------------------------------------------------------------------------------------------------------------------------- >> .\config\StartupScript.conf
233- echo # Change the values in the section below >> .\config\StartupScript.conf
259+ echo # General Server Options >> .\config\StartupScript.conf
234260echo # --------------------------------------------------------------------------------------------------------------------------- >> .\config\StartupScript.conf
235261echo # >> .\config\StartupScript.conf
236262echo # Define server file name here >> .\config\StartupScript.conf
@@ -251,6 +277,19 @@ echo. >> .\config\StartupScript.conf
251277echo # Set console title here >> .\config\StartupScript.conf
252278echo Title=Minecraft Server >> .\config\StartupScript.conf
253279echo . >> .\config\StartupScript.conf
280+ echo # --------------------------------------------------------------------------------------------------------------------------- >> .\config\StartupScript.conf
281+ echo # Discord Webhook Options >> .\config\StartupScript.conf
282+ echo # --------------------------------------------------------------------------------------------------------------------------- >> .\config\StartupScript.conf
283+ echo # Follow the " Making a Webhook" section here: https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks>> .\config\StartupScript.conf
284+ echo . >> .\config\StartupScript.conf
285+ echo # Set the Discord webhook URL here >> .\config\StartupScript.conf
286+ echo webhookURL=%webhookURL% >> .\config\StartupScript.conf
287+ echo . >> .\config\StartupScript.conf
288+ echo # Set the message which is sent via webhook when the server stops >> .\config\StartupScript.conf
289+ echo webhookMessageStop=```\uD83C\uDFC1 The server has stopped.```>> .\config\StartupScript.conf
290+ echo . >> .\config\StartupScript.conf
291+ echo # Set the message which is sent via webhook when the server stops >> .\config\StartupScript.conf
292+ echo webhookMessageStart=```\uD83D\uDE80 The server has started.```>> .\config\StartupScript.conf
254293echo Config variables successfully saved to StartupScript.conf
255294
256295REM Write Java Args to .\config\jvm_args.txt
0 commit comments