Change evens naming semantic

This commit is contained in:
Maxim Khomutov 2023-07-16 16:14:00 +03:00
parent a73b14f9b4
commit cd098571d9
3 changed files with 16 additions and 18 deletions

View File

@ -260,8 +260,8 @@ class Core:
self.run = True
self.log.info(i18n.start)
ev.call_event("server_started")
await ev.call_async_event("server_started")
ev.call_event("onServerStarted")
await ev.call_async_event("onServerStarted")
await t # Wait end.
except KeyboardInterrupt:
pass
@ -278,8 +278,8 @@ class Core:
asyncio.run(self.main())
async def stop(self):
ev.call_event("server_stopped")
await ev.call_async_event("server_stopped")
ev.call_event("onServerStopped")
await ev.call_async_event("onServerStopped")
await ev.call_async_event("_plugins_unload")
self.run = False
self.log.info(i18n.stop)

View File

@ -41,7 +41,7 @@ class TCPServer:
await client.kick("Invalid Key (too long)!")
return False, client
client._key = data.decode("utf-8")
ev.call_event("auth_sent_key", player=client)
ev.call_event("onPlayerSentKey", player=client)
try:
async with aiohttp.ClientSession() as session:
url = 'https://auth.beammp.com/pkToUser'
@ -71,7 +71,7 @@ class TCPServer:
await client.kick('Stale Client (replaced by new client)')
return False, client
ev.call_event("auth_ok", player=client)
ev.call_event("onPlayerAuthenticated", player=client)
if len(self.Core.clients_by_id) > config.Game["players"]:
# TODO: i18n

View File

@ -22,20 +22,18 @@ class EventsSystem:
self.loop = asyncio.get_event_loop()
self.as_tasks = []
self.__events = {
"server_started": [],
"auth_sent_key": [], # Only sync
"auth_ok": [], # Only sync
"player_join": [],
"chat_receive": [],
"server_stopped": [],
"onServerStarted": [],
"onPlayerSentKey": [], # Only sync
"onPlayerAuthenticated": [], # Only sync
"onPlayerJoin": [],
"onChatReceive": [],
"onServerStopped": [],
}
self.__async_events = {
"server_started": [],
"_plugins_start": [],
"_plugins_unload": [],
"player_join": [],
"chat_receive": [],
"server_stopped": []
"onServerStarted": [],
"onPlayerJoin": [],
"onChatReceive": [],
"onServerStopped": []
}
def builtins_hook(self):