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)