aboutsummarylogtreecommitdiffstats
path: root/minecraftd.sh
diff options
context:
space:
mode:
authorGordian Edenhofer2019-03-28 11:37:08 +0100
committerGordian Edenhofer2019-03-28 11:51:00 +0100
commit53426af2a7035028b40649b1a62ff9e148400a20 (patch)
treee590020942817b69a68d8cdacd8209c5c967aad3 /minecraftd.sh
parentfc300f4fd62ac40f8c0f869fa27ebc8777822394 (diff)
downloadaur-53426af2a7035028b40649b1a62ff9e148400a20.tar.gz
upgpkg: minecraft-server 1.13.2-3
Adapt the `is_player_online` function to be a little more generic. This fixes detecting players on cuberite even with the most recent version. upgpkg: cuberite 1.12b1014-1 upgpkg: spigot 1.13.2+b93-1
Diffstat (limited to 'minecraftd.sh')
-rwxr-xr-xminecraftd.sh6
1 files changed, 4 insertions, 2 deletions
diff --git a/minecraftd.sh b/minecraftd.sh
index cd64a693f526..3563ce7f944a 100755
--- a/minecraftd.sh
+++ b/minecraftd.sh
@@ -82,14 +82,16 @@ game_command() {
# Check whether there are player on the server through list
is_player_online() {
response="$(sleep_time=0.6 return_stdout=true game_command list)"
+ # Delete leading line and free response string from fancy characters
+ response="$(echo "${response}" | sed -r -e '$!d' -e 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})*)?[JKmsuG]//g')"
# The list command prints a line containing the usernames after the last occurrence of ": "
# and since playernames may not contain this string the clean player-list can easily be retrieved.
# Otherwiese check the first digit after the last occurrence of "There are". If it is 0 then there
# are no players on the server. Should this test fail as well. Assume that a player is online.
- if [[ $(echo "${response}" | grep ":" | sed -r -e '$!d' -e 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})*)?[JKmsuG]//g' -e 's/.*\: //' | tr -d '\n' | wc -c) -le 1 ]]; then
+ if [[ $(echo "${response}" | grep ":" | sed -e 's/.*\: //' | tr -d '\n' | wc -c) -le 1 ]]; then
# No player is online
return 0
- elif [[ $(echo "${response}" | grep "There are" | sed -r -e '$!d' -e 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})*)?[JKmsuG]//g' -e 's/.*\: //' -e 's/^([^.]+).*$/\1/; s/^[^0-9]*([0-9]+).*$/\1/' | tr -d '\n') -eq 0 ]]; then
+ elif [[ "x$(echo "${response}" | grep "There are" | sed -r -e 's/.*\: //' -e 's/^([^.]+).*$/\1/; s/^[^0-9]*([0-9]+).*$/\1/' | tr -d '\n')" == "x0" ]]; then
# No player is online
return 0
else