Skip to content

Commit 7ce24fa

Browse files
committed
fix(stop): always give 3s warning for shutdown
The is_anyone_online check was unstable as the text keeps changing from version to version. The check has been removed and we shutdown now always with a 3s warning to any players.
1 parent b44c51c commit 7ce24fa

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

src/minecraftctl.sh

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,6 @@ running() {
6161
return $?
6262
}
6363

64-
# Check if anyone is online
65-
is_anyone_online() {
66-
player_count=$(game_command list | sed -r 's/.*([[:digit:]]+)\/[[:digit:]]+ players online:.*/\1/')
67-
test $player_count -ne 0
68-
return $?
69-
}
70-
7164
# Start the minecraft docker container
7265
start() {
7366
if running
@@ -168,16 +161,13 @@ backup() {
168161
stop() {
169162
if running
170163
then
171-
if is_anyone_online
172-
then
173-
game_command "save-all"
174-
for i in {10..1}
175-
do
176-
game_command "say Server shutting down in ${i}s..."
177-
sleep 1
178-
done
179-
game_command "say Shutting down..."
180-
fi
164+
game_command "save-all"
165+
for i in {3..1}
166+
do
167+
game_command "say Server shutting down in ${i}s..."
168+
sleep 1
169+
done
170+
game_command "say Shutting down..."
181171
game_command "stop"
182172
# Wait for container to stop on its own now
183173
$DOCKER wait "$name"

0 commit comments

Comments
 (0)