From c9c542dcbc50c109d5cd3817f099759e5653aace Mon Sep 17 00:00:00 2001 From: Charles Le Maux Date: Fri, 6 Sep 2024 17:54:04 +0200 Subject: [PATCH 1/4] [+] Fixed query problem --- server_mc_manager.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/server_mc_manager.py b/server_mc_manager.py index 459b101..a3c6210 100644 --- a/server_mc_manager.py +++ b/server_mc_manager.py @@ -1,12 +1,12 @@ -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 firebase_manager -import generic_executor class MinecraftServerManager: @@ -88,8 +88,7 @@ class MinecraftServerManager: 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 + stats: int = client.stats(full=False).num_players return stats def set_cooldown(self, user_id): From 46dcb394950348dbb321428b6be8f3a09de5fe75 Mon Sep 17 00:00:00 2001 From: Charles Le Maux Date: Fri, 6 Sep 2024 17:56:56 +0200 Subject: [PATCH 2/4] [+] Added exception handling to query --- server_mc_manager.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/server_mc_manager.py b/server_mc_manager.py index a3c6210..c6d5cd9 100644 --- a/server_mc_manager.py +++ b/server_mc_manager.py @@ -6,6 +6,7 @@ from typing import Union import mcipc.query import mcipc.query.client +import file_manager import firebase_manager @@ -87,9 +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: int = client.stats(full=False).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 From 620936f1b3194ecce2743eed3c607c90d0027660 Mon Sep 17 00:00:00 2001 From: Charles Le Maux Date: Fri, 6 Sep 2024 18:00:54 +0200 Subject: [PATCH 3/4] [+] Updated mail in readme.md --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From c5c630a35c01f2d98df8c5091c855110e219ecaf Mon Sep 17 00:00:00 2001 From: Charles Le Maux Date: Fri, 6 Sep 2024 19:04:03 +0200 Subject: [PATCH 4/4] [-] Abandonning this :) --- firebase_manager.py | 1 + 1 file changed, 1 insertion(+) 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