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,19 +131,24 @@ def paper_version():
return {"paper": paper_version, "minecraft": mc_version}
def datapack_info():
with MCRcon(CONFIG["mcrcon"]["host"], CONFIG["mcrcon"]["password"], port=int(CONFIG["mcrcon"]["port"])) as mcr:
resp = mcr.command("datapack list")
match = re.match("There are [0-9]* data packs enabled: (\[.*\])*.*", resp)
datapacks = []
datapacks_string = match.group(1)
for datapack in datapacks_string.split(","):
match = re.match("\[(.*)\(.*\)\]", datapack.strip())
datapack_name = match.group(1)
datapack_name = datapack_name.strip()
datapack_name = datapack_name.replace("file/", "")
datapack_name = datapack_name.replace(".zip", "")
if not datapack_name in ["vanilla", "bukkit"]:
datapacks.append(datapack_name)
try:
with MCRcon(CONFIG["mcrcon"]["host"], CONFIG["mcrcon"]["password"], port=int(CONFIG["mcrcon"]["port"])) as mcr:
resp = mcr.command("datapack list")
match = re.match("There are [0-9]* data packs enabled: (\[.*\])*.*", resp)
datapacks = []
datapacks_string = match.group(1)
for datapack in datapacks_string.split(","):
match = re.match("\[(.*)\(.*\)\]", datapack.strip())
datapack_name = match.group(1)
datapack_name = datapack_name.strip()
datapack_name = datapack_name.replace("file/", "")
datapack_name = datapack_name.replace(".zip", "")
if not datapack_name in ["vanilla", "bukkit"]:
datapacks.append(datapack_name)
except ConnectionRefusedError:
datapacks = []
return datapacks
def server_details():