Fix version rendering if minecraft version is not found in minecraft-data

This commit is contained in:
sqozz 2021-11-18 18:57:24 +01:00
parent e87c1b7203
commit 4679909010

View file

@ -123,7 +123,11 @@ def paper_version():
status = server_status()
paper_version = status.version.name
protocol_version = status.version.protocol
mc_version = list(filter(lambda x: x.get("version", 0) == protocol_version, minecraft_data.common().protocolVersions))[0].get("minecraftVersion", "Unknown")
possible_versions = list(filter(lambda x: x.get("version", 0) == protocol_version, minecraft_data.common().protocolVersions))
try:
mc_version = possible_versions[0].get("minecraftVersion", "Unknown")
except:
mc_version = "Unknown"
return {"paper": paper_version, "minecraft": mc_version}
def datapack_info():