Fix homepage if mcrcon is not available

This commit is contained in:
sqozz 2023-02-02 13:24:05 +01:00
parent b8d9f708ed
commit 947c4f9d30

View file

@ -131,8 +131,10 @@ def paper_version():
return {"paper": paper_version, "minecraft": mc_version} return {"paper": paper_version, "minecraft": mc_version}
def datapack_info(): def datapack_info():
try:
with MCRcon(CONFIG["mcrcon"]["host"], CONFIG["mcrcon"]["password"], port=int(CONFIG["mcrcon"]["port"])) as mcr: with MCRcon(CONFIG["mcrcon"]["host"], CONFIG["mcrcon"]["password"], port=int(CONFIG["mcrcon"]["port"])) as mcr:
resp = mcr.command("datapack list") resp = mcr.command("datapack list")
match = re.match("There are [0-9]* data packs enabled: (\[.*\])*.*", resp) match = re.match("There are [0-9]* data packs enabled: (\[.*\])*.*", resp)
datapacks = [] datapacks = []
datapacks_string = match.group(1) datapacks_string = match.group(1)
@ -144,6 +146,9 @@ def datapack_info():
datapack_name = datapack_name.replace(".zip", "") datapack_name = datapack_name.replace(".zip", "")
if not datapack_name in ["vanilla", "bukkit"]: if not datapack_name in ["vanilla", "bukkit"]:
datapacks.append(datapack_name) datapacks.append(datapack_name)
except ConnectionRefusedError:
datapacks = []
return datapacks return datapacks
def server_details(): def server_details():