Fix mcstatus version compatibility

This commit is contained in:
sqozz 2023-02-02 13:23:21 +01:00
parent 4679909010
commit b8d9f708ed

View file

@ -1,5 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
from mcstatus import MinecraftServer from mcstatus import JavaServer
from os.path import join as pathjoin from os.path import join as pathjoin
from bottle import route, run, static_file, template from bottle import route, run, static_file, template
from random import random, choice from random import random, choice
@ -153,8 +153,12 @@ def server_details():
return {"hardware": hardware, "versions": versions, "datapacks": datapacks} return {"hardware": hardware, "versions": versions, "datapacks": datapacks}
def server_status(): def server_status():
server = MinecraftServer.lookup(CONFIG["mcrcon"]["host"]) server = JavaServer.lookup(CONFIG["mcrcon"]["host"])
try:
status = server.status() status = server.status()
except ConnectionRefusedError:
status = "UNKNOWN"
return status return status