Fix parsing if no players are online

This commit is contained in:
sqozz 2021-03-31 12:09:13 +02:00
parent f1dbbcbbb1
commit 57b276d7c7
1 changed files with 5 additions and 1 deletions

View File

@ -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)