Merge branch 'dev' into 'master'

Bug Fixes 20220612

See merge request crafty-controller/crafty-4!320
This commit is contained in:
Andrew 2022-06-12 21:23:21 +00:00
commit c389e755ad
3 changed files with 19 additions and 10 deletions

View File

@ -93,7 +93,12 @@ class ServersController(metaclass=Singleton):
@staticmethod @staticmethod
def update_server(server_obj): def update_server(server_obj):
return HelperServers.update_server(server_obj) ret = HelperServers.update_server(server_obj)
server_instance: ServerInstance = ServersController().get_server_instance_by_id(
server_obj.server_id
)
server_instance.update_server_instance()
return ret
@staticmethod @staticmethod
def set_download(server_id): def set_download(server_id):
@ -267,14 +272,14 @@ class ServersController(metaclass=Singleton):
server_data = [] server_data = []
try: try:
for server in self.servers_list: 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") server.get("server_id")
) )
latest = srv.stats_helper.get_latest_server_stats() latest = srv.stats_helper.get_latest_server_stats()
server_data.append( server_data.append(
{ {
"server_data": ServersController.get_server_data_by_id( "server_data": DatabaseShortcuts.get_data_obj(
server.get("server_id") srv.server_object
), ),
"stats": latest, "stats": latest,
"user_command_permission": True, "user_command_permission": True,
@ -330,9 +335,7 @@ class ServersController(metaclass=Singleton):
user_command_permission = False user_command_permission = False
server_data.append( server_data.append(
{ {
"server_data": ServersController.get_server_data_by_id( "server_data": DatabaseShortcuts.get_data_obj(srv.server_object),
server.server_id
),
"stats": latest, "stats": latest,
"user_command_permission": user_command_permission, "user_command_permission": user_command_permission,
} }

View File

@ -139,6 +139,13 @@ class ServerInstance:
# ********************************************************************************** # **********************************************************************************
# Minecraft Server Management # 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): def reload_server_settings(self):
server_data = HelperServers.get_server_data_by_id(self.server_id) server_data = HelperServers.get_server_data_by_id(self.server_id)
self.settings = server_data self.settings = server_data

View File

@ -17,7 +17,6 @@ from tornado import iostream
from tzlocal import get_localzone from tzlocal import get_localzone
from croniter import croniter from croniter import croniter
from app.classes.controllers.roles_controller import RolesController from app.classes.controllers.roles_controller import RolesController
from app.classes.controllers.servers_controller import ServersController
from app.classes.models.servers import Servers from app.classes.models.servers import Servers
from app.classes.models.server_permissions import EnumPermissionsServer from app.classes.models.server_permissions import EnumPermissionsServer
@ -259,7 +258,7 @@ class PanelHandler(BaseHandler):
for server in defined_servers[:]: for server in defined_servers[:]:
if str(server.server_id) == str(server_id): if str(server.server_id) == str(server_id):
page_servers.append( page_servers.append(
ServersController.get_server_data_by_id(server.server_id) DatabaseShortcuts.get_data_obj(server.server_object)
) )
user_order.remove(server_id) user_order.remove(server_id)
defined_servers.remove(server) defined_servers.remove(server)
@ -268,7 +267,7 @@ class PanelHandler(BaseHandler):
server_ids.append(str(server.server_id)) server_ids.append(str(server.server_id))
if server not in page_servers: if server not in page_servers:
page_servers.append( 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[:]: for server_id in user_order[:]: