Skip to content

Commit

Permalink
fix(stop): always give 3s warning for shutdown
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nathanielc committed Jun 16, 2020
1 parent b44c51c commit 7ce24fa
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions src/minecraftctl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 7ce24fa

Please sign in to comment.