From 4ae6965e39a3986093086ed11d193ed4af87770d Mon Sep 17 00:00:00 2001 From: "Jason M. Wood" Date: Sat, 4 Jan 2014 21:45:48 -0700 Subject: [PATCH] List online players when worldStatus is called --- minecraft_server | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/minecraft_server b/minecraft_server index ffcc2ed..de8d4cb 100755 --- a/minecraft_server +++ b/minecraft_server @@ -1375,11 +1375,22 @@ queryDetailedStatus() { # @param 1 The world server of interest. # --------------------------------------------------------------------------- worldStatus() { - local STATUS + local STATUS NUM MAX PLAYERS COUNTER if [ $(serverRunning $1) -eq 1 ]; then - STATUS=$(queryStatus $1) + STATUS=$(queryDetailedStatus $1) if [ -n "$STATUS" ]; then - printf "running (%d of %d users online).\n" $(echo "$STATUS" | cut -f6) $(echo "$STATUS" | cut -f7) + NUM=$(echo "$STATUS" | cut -f 19) + MAX=$(echo "$STATUS" | cut -f 21) + printf "running (%d of %d users online).\n" $NUM $MAX + if [ $NUM -gt 0 ]; then + PLAYERS=$(echo "$STATUS" | cut -f $((30))) + COUNTER=1 + while [ $COUNTER -lt $NUM ]; do + PLAYERS=$(printf "%s, %s" "$PLAYERS" $(echo "$STATUS" | cut -f $((30+$COUNTER)))) + COUNTER=$(($COUNTER+1)) + done + printf " Players: %s.\n" "$PLAYERS" + fi else printf "running (query server offline).\n" fi