From ef2aa6517352b029ff6c17c3893522e0c47bd83b Mon Sep 17 00:00:00 2001 From: Charles Le Maux Date: Sun, 11 Aug 2024 11:02:10 +0200 Subject: [PATCH] [+] Minor fixes --- server_mc_manager.py | 6 +++--- unit_test.py | 11 ++++++++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/server_mc_manager.py b/server_mc_manager.py index a815c9b..48a3107 100644 --- a/server_mc_manager.py +++ b/server_mc_manager.py @@ -64,8 +64,8 @@ class MinecraftServerManager: if server_info['port'] == port: return server_id return None - - def get_online_players(self, port)->int: + + def get_online_players(self, port) -> int: with mcipc.query.Client('127.0.0.1', port) as client: stats: mcipc.query.proto.FullStats = client.stats(full=True) stats: int = stats.num_players @@ -85,7 +85,7 @@ class MinecraftServerManager: else: del self.cooldowns[user_id] return False - + if __name__ == "__main__": pass diff --git a/unit_test.py b/unit_test.py index 0211a83..85ae074 100644 --- a/unit_test.py +++ b/unit_test.py @@ -1,4 +1,5 @@ import firebase_manager +from mcipc.query import Client def ban_user(user_id: str): @@ -9,5 +10,13 @@ def ban_user(user_id: str): print("Error banning user "+user_id, "|", str(e), type(e).__name__) +def get_online_players(port) -> int: + with Client('127.0.0.1', port) as client: + stats: mcipc.query.proto.FullStats = client.stats(full=True) + stats: int = stats.num_players + return stats + + if __name__ == '__main__': - ban_user("MpkbDMOO8PQddQgB5VgBQdTMWF53") + #ban_user("MpkbDMOO8PQddQgB5VgBQdTMWF53") + get_online_players(25565)