From 57b276d7c7b068fdfc3b1631cc7d153ccb60e94e Mon Sep 17 00:00:00 2001 From: sqozz Date: Wed, 31 Mar 2021 12:09:13 +0200 Subject: [PATCH] Fix parsing if no players are online --- homepage/main.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/homepage/main.py b/homepage/main.py index bf404c1..4cff1a6 100644 --- a/homepage/main.py +++ b/homepage/main.py @@ -59,7 +59,11 @@ def currentPlayerData(): with MCRcon(CONFIG["mcrcon"]["host"], CONFIG["mcrcon"]["password"], port=int(CONFIG["mcrcon"]["port"])) as mcr: resp = mcr.command("list uuids") resp = resp.split(":") - player_list = resp[1].strip().split(",") + player_string = resp[1].strip() + if player_string != "": + player_list = player_string.split(",") + else: + player_list = [] player_list = list(map(lambda x: x.strip(), player_list)) count_regex = re.match("There are ([0-9]+) of a max of ([0-9]+) players online", resp[0]) num_players = count_regex.group(1)