mirror of
https://github.com/kuitoi/kuitoi-Server.git
synced 2026-02-16 02:20:52 +00:00
[!] Fix events
[~] Minor updates
This commit is contained in:
@@ -133,10 +133,9 @@ class Client:
|
||||
await self._send(f"C:{message}", to_all=to_all)
|
||||
|
||||
async def send_event(self, event_name, event_data, to_all=True):
|
||||
self.log.debug(f"send_event: {event_name}:{event_data}; {to_all=}")
|
||||
if isinstance(event_data, (list, tuple, dict)):
|
||||
event_data = json.dumps(event_data, separators=(',', ':'))
|
||||
else:
|
||||
event_data = f"{event_data!r}"
|
||||
if len(event_data) > 104857599:
|
||||
self.log.error("Client data too big! >=104857599")
|
||||
return
|
||||
|
||||
@@ -10,7 +10,7 @@ __title__ = 'KuiToi-Server'
|
||||
__description__ = 'BeamingDrive Multiplayer server compatible with BeamMP clients.'
|
||||
__url__ = 'https://github.com/kuitoi/kuitoi-Server'
|
||||
__version__ = '0.4.8 (pre)'
|
||||
__build__ = 2474 # Я это считаю лог файлами
|
||||
__build__ = 2483 # Я это считаю лог файлами
|
||||
__author__ = 'SantaSpeen'
|
||||
__author_email__ = 'admin@kuitoi.su'
|
||||
__license__ = "FPA"
|
||||
@@ -91,7 +91,7 @@ if not config.Auth['private'] and not config.Auth['key']:
|
||||
text=i18n.GUI_enter_key_message,
|
||||
ok_text=i18n.GUI_ok,
|
||||
cancel_text=i18n.GUI_cancel).run()
|
||||
config_provider.save()
|
||||
config_provider.save()
|
||||
if not config.Auth['private'] and not config.Auth['key']:
|
||||
log.error(i18n.auth_empty_key)
|
||||
log.info(i18n.stop)
|
||||
|
||||
@@ -315,7 +315,7 @@ class Core:
|
||||
await ev.call_async_event("onServerStopped")
|
||||
await self.__gracefully_kick()
|
||||
if config.Options['use_lua']:
|
||||
ev.call_event("_lua_plugins_unload")
|
||||
await ev.call_async_event("_lua_plugins_unload")
|
||||
await ev.call_async_event("_plugins_unload")
|
||||
self.run = False
|
||||
total_time = time.monotonic() - self.start_time
|
||||
|
||||
@@ -23,13 +23,12 @@ class KuiToi:
|
||||
_plugins_dir = ""
|
||||
|
||||
def __init__(self, name):
|
||||
if name is None:
|
||||
if not name:
|
||||
raise AttributeError("KuiToi: Name is required")
|
||||
self.__log = get_logger(f"Plugin | {name}")
|
||||
self.__name = name
|
||||
self.__dir = Path(self._plugins_dir) / self.__name
|
||||
if not self.__dir.exists():
|
||||
os.mkdir(self.__dir)
|
||||
os.makedirs(self.__dir, exist_ok=True)
|
||||
|
||||
@property
|
||||
def log(self):
|
||||
|
||||
@@ -608,14 +608,6 @@ class LuaPluginsLoader:
|
||||
"ImScaredOfUpdates": False,
|
||||
"SendErrorsShowMessage": False,
|
||||
"SendErrors": False
|
||||
},
|
||||
"HTTP": {
|
||||
"HTTPServerIP": config.WebAPI['server_ip'],
|
||||
"HTTPServerPort": config.WebAPI['server_port'],
|
||||
"SSLKeyPath": None,
|
||||
"SSLCertPath": None,
|
||||
"UseSSL": False,
|
||||
"HTTPServerEnabled": config.WebAPI['enabled'],
|
||||
}
|
||||
}
|
||||
with open("ServerConfig.toml", "w") as f:
|
||||
@@ -671,10 +663,15 @@ class LuaPluginsLoader:
|
||||
self.log.error(f"Exception onInit from `{name}`: {e}")
|
||||
self.log.exception(e)
|
||||
|
||||
def unload(self, _):
|
||||
async def unload(self, _):
|
||||
self.log.debug("Unloading lua plugins")
|
||||
for name, data in self.lua_plugins.items():
|
||||
if data['ok']:
|
||||
self.log.info(i18n.plugins_lua_unload.format(name))
|
||||
for _, timer in data['lua'].globals().MP._event_timers.items():
|
||||
MP = data['lua'].globals().MP
|
||||
self.log.debug("gather")
|
||||
await asyncio.gather(*MP.tasks)
|
||||
self.log.debug("timers")
|
||||
for _, timer in MP._event_timers.items():
|
||||
timer.stop()
|
||||
self.log.debug("unloaded")
|
||||
|
||||
Reference in New Issue
Block a user