diff --git a/firebase_manager.py b/firebase_manager.py index 463e72b..a97a3c6 100644 --- a/firebase_manager.py +++ b/firebase_manager.py @@ -204,5 +204,6 @@ def close_idle_server(user_id: Union[str, None], name: Union[str, None], port: i except Exception as e: print(e, user_id, name, server_stamp) + if __name__ == "__main__": pass diff --git a/readme.md b/readme.md index def6d3a..648e9c0 100644 --- a/readme.md +++ b/readme.md @@ -65,4 +65,4 @@ We're actively seeking maintainers that will triage issues and pull requests and If you work on a project that leverages Servii and have a vested interest in keeping the code alive and well, send an email to [charles@le-maux.dev], thank you for reading. -[charles@le-maux.dev]: charles@le-maux.dev +[charles@le-maux.dev]: mailto:charles@le-maux.dev diff --git a/server_mc_manager.py b/server_mc_manager.py index 459b101..c6d5cd9 100644 --- a/server_mc_manager.py +++ b/server_mc_manager.py @@ -1,12 +1,13 @@ -import subprocess import shlex +import subprocess import time -import mcipc.query -import mcipc.query.client from typing import Union +import mcipc.query +import mcipc.query.client + +import file_manager import firebase_manager -import generic_executor class MinecraftServerManager: @@ -87,10 +88,13 @@ class MinecraftServerManager: def get_online_players(self, port) -> int: if not self.servers[port]: return 0 - 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 - return stats + try: + with mcipc.query.Client('127.0.0.1', port) as client: + stats: int = client.stats(full=False).num_players + return stats + except Exception as e: + file_manager.log_error(type(e).__name__, str(e)) + return 0 def set_cooldown(self, user_id): expiry_timestamp = time.time() + 30