Improve smooth player chart, colored MOTD and complete paged player names

This commit is contained in:
itxiaohui committed 2026-10-06 14:46:30 +08:00
1 parent 1bbecbfaa1
commit bd1cf2ff4c
14 files changed
+775 -122

No files matched your search

+40 -5
View File
@@ -7,7 +7,7 @@ from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT))
from services.motd_card import render_motd_card
from services.motd_card import render_motd_cards
def main():
@@ -26,9 +26,32 @@ def main():
"address": "mc.example.com:25565",
"version": "1.21.1",
"motd": "欢迎来到栗子服务器!生存 · 建筑 · 冒险,和朋友一起探索方块世界",
"motd_raw": {
"text": "xiaohuicat",
"color": "#80EAC0",
"bold": True,
"extra": [
{"text": " 生存 · 建筑 · 冒险", "color": "gold", "bold": False},
{"text": "\n欢迎和朋友一起探索方块世界!", "color": "aqua", "bold": False},
{"text": " §d温馨社区 §a自由冒险"},
],
},
"players_online": history[-1]["players"],
"players_max": 100,
"player_list": ["itxiaohui", "Steve", "Alex", "栗子玩家"],
"player_list": [
"itxiaohui",
"Steve",
"Alex",
"栗子玩家",
"Builder_Orange",
"DreamExplorer",
"xiaohuicat",
"AdventureCat",
"RedStone_Master",
"Minecraft_Lover",
"Moonlight",
"世界探索者",
],
"latency_ms": 32.6,
"software": "Paper",
"plugins": {"names": ["Example"]},
@@ -41,11 +64,23 @@ def main():
"first": (data, history[-1:]),
"offline": ({"online": False, "address": data["address"], "source": "api"}, history),
"failed": ({"online": False, "address": data["address"], "query_failed": True}, []),
"many-players": (
dict(
data,
player_list=[f"Player_{i:03d}_LongName" for i in range(1, 101)],
players_online=100,
),
history,
),
}
for name, (status, points) in examples.items():
path = folder / f"motd-{name}.png"
path.write_bytes(render_motd_card(status, "xiaohuicat · 演示数据", points, now))
print(path)
for index, card in enumerate(
render_motd_cards(status, "xiaohuicat · 演示数据", points, now), 1
):
suffix = "" if index == 1 else f"-{index}"
path = folder / f"motd-{name}{suffix}.png"
path.write_bytes(card)
print(path)
if __name__ == "__main__":