From 7ce24fa0c311889c1dbeaf96f5abb7dbed1c5390 Mon Sep 17 00:00:00 2001 From: Nathaniel Cook Date: Tue, 16 Jun 2020 17:32:42 -0600 Subject: [PATCH] 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. --- src/minecraftctl.sh | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/src/minecraftctl.sh b/src/minecraftctl.sh index 15bcf4e..1afca45 100755 --- a/src/minecraftctl.sh +++ b/src/minecraftctl.sh @@ -61,13 +61,6 @@ running() { return $? } -# Check if anyone is online -is_anyone_online() { - player_count=$(game_command list | sed -r 's/.*([[:digit:]]+)\/[[:digit:]]+ players online:.*/\1/') - test $player_count -ne 0 - return $? -} - # Start the minecraft docker container start() { if running @@ -168,16 +161,13 @@ backup() { stop() { if running then - if is_anyone_online - then - game_command "save-all" - for i in {10..1} - do - game_command "say Server shutting down in ${i}s..." - sleep 1 - done - game_command "say Shutting down..." - fi + game_command "save-all" + for i in {3..1} + do + game_command "say Server shutting down in ${i}s..." + sleep 1 + done + game_command "say Shutting down..." game_command "stop" # Wait for container to stop on its own now $DOCKER wait "$name"