diff --git a/app/classes/controllers/servers_controller.py b/app/classes/controllers/servers_controller.py index b4ddbb29..73a1cc99 100644 --- a/app/classes/controllers/servers_controller.py +++ b/app/classes/controllers/servers_controller.py @@ -94,7 +94,10 @@ class ServersController(metaclass=Singleton): @staticmethod def update_server(server_obj): ret = HelperServers.update_server(server_obj) - ServersController().refresh_server_settings(server_obj.server_id) + server_instance: ServerInstance = ServersController().get_server_instance_by_id( + server_obj.server_id + ) + server_instance.update_server_instance() return ret @staticmethod @@ -236,7 +239,7 @@ class ServersController(metaclass=Singleton): @staticmethod def get_authorized_servers(user_id): - server_data: t.List[t.Dict[str, t.Any]] = [] + server_data: ServerInstance.List[ServerInstance.Dict[str, t.Any]] = [] user_roles = HelperUsers.user_role_query(user_id) for user in user_roles: role_servers = PermissionsServers.get_role_servers_from_role_id( @@ -269,14 +272,14 @@ class ServersController(metaclass=Singleton): server_data = [] try: for server in self.servers_list: - srv = ServersController().get_server_instance_by_id( + srv: ServerInstance = ServersController().get_server_instance_by_id( server.get("server_id") ) latest = srv.stats_helper.get_latest_server_stats() server_data.append( { - "server_data": ServersController.get_server_data_by_id( - server.get("server_id") + "server_data": DatabaseShortcuts.get_data_obj( + srv.server_object ), "stats": latest, "user_command_permission": True, @@ -332,9 +335,7 @@ class ServersController(metaclass=Singleton): user_command_permission = False server_data.append( { - "server_data": ServersController.get_server_data_by_id( - server.server_id - ), + "server_data": DatabaseShortcuts.get_data_obj(srv.server_object), "stats": latest, "user_command_permission": user_command_permission, } diff --git a/app/classes/shared/server.py b/app/classes/shared/server.py index 24daaceb..6cb5f645 100644 --- a/app/classes/shared/server.py +++ b/app/classes/shared/server.py @@ -1,4 +1,5 @@ from contextlib import redirect_stderr +from http import server import os import re import shutil @@ -139,6 +140,13 @@ class ServerInstance: # ********************************************************************************** # Minecraft Server Management # ********************************************************************************** + def update_server_instance(self): + server_data: Servers = HelperServers.get_server_obj(self.server_id) + self.server_path = server_data.path + self.jar_update_url = server_data.executable_update_url + self.name = server_data.server_name + self.server_object = server_data + def reload_server_settings(self): server_data = HelperServers.get_server_data_by_id(self.server_id) self.settings = server_data diff --git a/app/classes/web/panel_handler.py b/app/classes/web/panel_handler.py index af28b564..de633421 100644 --- a/app/classes/web/panel_handler.py +++ b/app/classes/web/panel_handler.py @@ -259,7 +259,7 @@ class PanelHandler(BaseHandler): for server in defined_servers[:]: if str(server.server_id) == str(server_id): page_servers.append( - ServersController.get_server_data_by_id(server.server_id) + DatabaseShortcuts.get_data_obj(server.server_object) ) user_order.remove(server_id) defined_servers.remove(server) @@ -268,7 +268,7 @@ class PanelHandler(BaseHandler): server_ids.append(str(server.server_id)) if server not in page_servers: page_servers.append( - ServersController.get_server_data_by_id(server.server_id) + DatabaseShortcuts.get_data_obj(server.server_object) ) for server_id in user_order[:]: