Initial commit: FlexiCraft Web Portal + Discord SSO + Quartz/Iron engines
This commit is contained in:
commit
f488ff57c5
19 changed files with 3256 additions and 0 deletions
34
core/server_live.py
Normal file
34
core/server_live.py
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
import os, json
|
||||
from mcstatus import JavaServer
|
||||
|
||||
LINKS_DB = "/root/flexicraft-discord-setup/data/crossplay_links.json"
|
||||
|
||||
def get_live_status(host="151.247.192.82", port=25565):
|
||||
try:
|
||||
srv = JavaServer.lookup(f"{host}:{port}")
|
||||
st = srv.status()
|
||||
players = [p.name for p in st.players.sample] if st.players.sample else []
|
||||
return {
|
||||
"online": True,
|
||||
"players_online": st.players.online,
|
||||
"players_max": st.players.max,
|
||||
"players_list": players,
|
||||
"version": "Paper 1.21.11 (1.9 → 1.21.11+)"
|
||||
}
|
||||
except Exception:
|
||||
return {
|
||||
"online": False,
|
||||
"players_online": 0,
|
||||
"players_max": 25,
|
||||
"players_list": [],
|
||||
"version": "Paper 1.21.11"
|
||||
}
|
||||
|
||||
def get_citizens_count():
|
||||
if os.path.exists(LINKS_DB):
|
||||
try:
|
||||
with open(LINKS_DB, "r", encoding="utf-8") as f:
|
||||
return len(json.load(f))
|
||||
except Exception:
|
||||
pass
|
||||
return 0
|
||||
Loading…
Add table
Add a link
Reference in a new issue