Fix homepage if mcrcon is not available
This commit is contained in:
parent
b8d9f708ed
commit
947c4f9d30
1 changed files with 18 additions and 13 deletions
|
@ -131,19 +131,24 @@ def paper_version():
|
||||||
return {"paper": paper_version, "minecraft": mc_version}
|
return {"paper": paper_version, "minecraft": mc_version}
|
||||||
|
|
||||||
def datapack_info():
|
def datapack_info():
|
||||||
with MCRcon(CONFIG["mcrcon"]["host"], CONFIG["mcrcon"]["password"], port=int(CONFIG["mcrcon"]["port"])) as mcr:
|
try:
|
||||||
resp = mcr.command("datapack list")
|
with MCRcon(CONFIG["mcrcon"]["host"], CONFIG["mcrcon"]["password"], port=int(CONFIG["mcrcon"]["port"])) as mcr:
|
||||||
match = re.match("There are [0-9]* data packs enabled: (\[.*\])*.*", resp)
|
resp = mcr.command("datapack list")
|
||||||
datapacks = []
|
|
||||||
datapacks_string = match.group(1)
|
match = re.match("There are [0-9]* data packs enabled: (\[.*\])*.*", resp)
|
||||||
for datapack in datapacks_string.split(","):
|
datapacks = []
|
||||||
match = re.match("\[(.*)\(.*\)\]", datapack.strip())
|
datapacks_string = match.group(1)
|
||||||
datapack_name = match.group(1)
|
for datapack in datapacks_string.split(","):
|
||||||
datapack_name = datapack_name.strip()
|
match = re.match("\[(.*)\(.*\)\]", datapack.strip())
|
||||||
datapack_name = datapack_name.replace("file/", "")
|
datapack_name = match.group(1)
|
||||||
datapack_name = datapack_name.replace(".zip", "")
|
datapack_name = datapack_name.strip()
|
||||||
if not datapack_name in ["vanilla", "bukkit"]:
|
datapack_name = datapack_name.replace("file/", "")
|
||||||
datapacks.append(datapack_name)
|
datapack_name = datapack_name.replace(".zip", "")
|
||||||
|
if not datapack_name in ["vanilla", "bukkit"]:
|
||||||
|
datapacks.append(datapack_name)
|
||||||
|
except ConnectionRefusedError:
|
||||||
|
datapacks = []
|
||||||
|
|
||||||
return datapacks
|
return datapacks
|
||||||
|
|
||||||
def server_details():
|
def server_details():
|
||||||
|
|
Loading…
Reference in a new issue