mirror of
https://github.com/kuitoi/kuitoi-Server.git
synced 2025-08-17 08:15:42 +00:00
Compare commits
3 Commits
719e705bab
...
7e0c50a04e
Author | SHA1 | Date | |
---|---|---|---|
7e0c50a04e | |||
f1ab07d49a | |||
cdeacc16bf |
@ -55,7 +55,7 @@ I didn't like writing plugins in Lua after using Python; it was very inconvenien
|
||||
- [x] Async support
|
||||
- [x] Add all events
|
||||
- [x] MultiLanguage: (i18n support)
|
||||
- [ ] Core
|
||||
- [x] Core
|
||||
- [x] Console
|
||||
- [x] WebAPI
|
||||
- [x] Plugins supports:
|
||||
@ -77,7 +77,7 @@ I didn't like writing plugins in Lua after using Python; it was very inconvenien
|
||||
- [ ] RCON System:
|
||||
- [ ] Serving
|
||||
- [ ] Client
|
||||
- [ ] SSL encryption
|
||||
- [x] AES encryption
|
||||
- [ ] KuiToi System
|
||||
- [ ] Servers counter
|
||||
- [ ] Players counter
|
||||
|
@ -303,10 +303,10 @@ class Core:
|
||||
ev.call_event("onServerStopped")
|
||||
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("_plugins_unload")
|
||||
ev.call_event("_lua_plugins_unload")
|
||||
self.run = False
|
||||
self.log.info(i18n.stop)
|
||||
if config.WebAPI["enabled"]:
|
||||
asyncio.run(self.web_stop())
|
||||
# exit(0)
|
||||
|
@ -66,8 +66,6 @@ class TCPServer:
|
||||
if _client.nick == client.nick and _client.guest == client.guest:
|
||||
await _client.kick(i18n.core_player_kick_stale)
|
||||
|
||||
client.log.info(i18n.core_player_set_id.format(client.pid))
|
||||
|
||||
allow = True
|
||||
reason = i18n.core_player_kick_no_allowed_default_reason
|
||||
|
||||
@ -90,6 +88,7 @@ class TCPServer:
|
||||
else:
|
||||
self.log.info(i18n.core_identifying_okay)
|
||||
await self.Core.insert_client(client)
|
||||
client.log.info(i18n.core_player_set_id.format(client.pid))
|
||||
|
||||
return True, client
|
||||
|
||||
|
@ -56,12 +56,12 @@ class EventsSystem:
|
||||
"onInit": [], # onServerStarted
|
||||
"onShutdown": [], # onServerStopped
|
||||
"onPlayerAuth": [], # onPlayerAuthenticated
|
||||
"onPlayerConnecting": [], # TODO lua onPlayerConnecting
|
||||
"onPlayerJoining": [], # TODO lua onPlayerJoining
|
||||
"onPlayerConnecting": [], # No
|
||||
"onPlayerJoining": [], # No
|
||||
"onPlayerJoin": [], # onPlayerJoin
|
||||
"onPlayerDisconnect": [], # TODO lua onPlayerDisconnect
|
||||
"onPlayerDisconnect": [], # onPlayerDisconnect
|
||||
"onChatMessage": [], # onChatReceive
|
||||
"onVehicleSpawn": [], # "onCarSpawn
|
||||
"onVehicleSpawn": [], # onCarSpawn
|
||||
"onVehicleEdited": [], # onCarEdited
|
||||
"onVehicleDeleted": [], # onCarDelete
|
||||
"onVehicleReset": [], # onCarReset
|
||||
@ -85,9 +85,7 @@ class EventsSystem:
|
||||
return
|
||||
|
||||
if not callable(event_func):
|
||||
# TODO: i18n
|
||||
self.log.error(f"Cannot add event '{event_name}'. "
|
||||
f"Use `KuiToi.add_event({event_name}', function)` instead. Skipping it...")
|
||||
self.log.error(i18n.events_not_callable.format(event_name, f"kt.add_event(\"{event_name}\", function)"))
|
||||
return
|
||||
if async_event or inspect.iscoroutinefunction(event_func):
|
||||
if event_name not in self.__async_events:
|
||||
@ -112,12 +110,10 @@ class EventsSystem:
|
||||
data = await func(event_data)
|
||||
funcs_data.append(data)
|
||||
except Exception as e:
|
||||
# TODO: i18n
|
||||
self.log.error(f'Error while calling "{event_name}"; In function: "{func.__name__}"')
|
||||
self.log.error(i18n.events_calling_error.format(event_name, func.__name__))
|
||||
self.log.exception(e)
|
||||
else:
|
||||
# TODO: i18n
|
||||
self.log.warning(f"Event {event_name} does not exist, maybe ev.call_event()?. Just skipping it...")
|
||||
self.log.warning(i18n.events_not_found.format(event_name, "kt.call_event()"))
|
||||
|
||||
return funcs_data
|
||||
|
||||
@ -132,12 +128,10 @@ class EventsSystem:
|
||||
event_data = {"event_name": event_name, "args": args, "kwargs": kwargs}
|
||||
funcs_data.append(func(event_data))
|
||||
except Exception as e:
|
||||
# TODO: i18n
|
||||
self.log.error(f'Error while calling "{event_name}"; In function: "{func.__name__}"')
|
||||
self.log.error(i18n.events_calling_error.format(event_name, func.__name__))
|
||||
self.log.exception(e)
|
||||
else:
|
||||
# TODO: i18n
|
||||
self.log.warning(f"Event {event_name} does not exist, maybe ev.call_async_event()?. Just skipping it...")
|
||||
self.log.warning(i18n.events_not_found.format(event_name, "kt.call_async_event()"))
|
||||
|
||||
return funcs_data
|
||||
|
||||
@ -151,21 +145,13 @@ class EventsSystem:
|
||||
try:
|
||||
func = lua.globals()[func_name]
|
||||
if not func:
|
||||
self.log.warning(f"Cannot trigger local event: '{func_name}' not found!")
|
||||
self.log.warning(i18n.events_lua_function_not_found.format("", func_name))
|
||||
continue
|
||||
fd = func(*args)
|
||||
funcs_data.append(fd)
|
||||
except Exception as e:
|
||||
# TODO: i18n
|
||||
self.log.error(f'Error: "{e}" - while calling lua event "{event_name}" with arguments: {args} - '
|
||||
f'in function: "{func_name}"')
|
||||
# self.log.exception(e)
|
||||
self.log.error(i18n.events_lua_calling_error.format(f"{e}", event_name, func_name, f"{args}"))
|
||||
else:
|
||||
# TODO: i18n
|
||||
self.log.warning(f"Event {event_name} does not exist, maybe ev.call_lua_event() or MP.Trigger<>Event()?. "
|
||||
f"Just skipping it...")
|
||||
self.log.warning(i18n.events_not_found.format(event_name, "ev.call_lua_event(), MP.Trigger<>Event()"))
|
||||
|
||||
return funcs_data
|
||||
|
||||
|
||||
|
||||
|
@ -43,7 +43,7 @@ class EventTimer:
|
||||
self.mp.TriggerLocalEvent(self.event_name)
|
||||
|
||||
|
||||
# noinspection PyPep8Naming
|
||||
# noinspection PyPep8Naming,PyProtectedMember
|
||||
class MP:
|
||||
|
||||
def __init__(self, name: str, lua: LuaRuntime):
|
||||
@ -117,19 +117,15 @@ class MP:
|
||||
try:
|
||||
func = self._lua.globals()[func_name]
|
||||
if not func:
|
||||
self.log.warning(f"Cannot trigger local event: '{func_name}' not found!")
|
||||
self.log.warning(i18n.events_lua_function_not_found.format(i18n.events_lua_local, func_name))
|
||||
continue
|
||||
fd = func(*args)
|
||||
funcs_data.append(fd)
|
||||
except Exception as e:
|
||||
# TODO: i18n
|
||||
self.log.error(f'Error: "{e}" - while calling lua event "{event_name}" with arguments: {args} - '
|
||||
f'in function: "{func_name}"')
|
||||
# self.log.exception(e)
|
||||
self.log.error(i18n.events_lua_calling_error.format(f"{e}", event_name, func_name, f"{args}"))
|
||||
|
||||
else:
|
||||
# TODO: i18n
|
||||
self.log.warning(f"Event {event_name} does not exist, maybe ev.call_lua_event() or MP.Trigger<>Event()?. "
|
||||
f"Just skipping it...")
|
||||
self.log.warning(i18n.events_not_found.format(event_name, "ev.call_lua_event(), MP.Trigger<>Event()"))
|
||||
|
||||
return self._lua.table_from(funcs_data)
|
||||
|
||||
@ -563,6 +559,7 @@ class FS:
|
||||
return os.path.join(*args)
|
||||
|
||||
|
||||
# noinspection PyProtectedMember
|
||||
class LuaPluginsLoader:
|
||||
|
||||
def __init__(self, plugins_dir):
|
||||
|
@ -57,7 +57,14 @@
|
||||
"client_event_invalid_data": "从事件返回的数据无效:{}",
|
||||
"client_player_disconnected": "离开服务器。游戏时间:{}分钟。",
|
||||
|
||||
"": "Events system",
|
||||
"": "事件系统",
|
||||
|
||||
"events_not_callable": "无法添加事件\"{}\"。请改用\"{}\"。跳过...",
|
||||
"events_not_found": "事件\"{}\"未注册。也许{}?跳过...",
|
||||
"events_calling_error": "调用函数\"{}\"时出错。",
|
||||
"events_lua_function_not_found": "无法调用{}lua事件 - 未找到\"{}\"。",
|
||||
"events_lua_local": "本地 ",
|
||||
"events_lua_calling_error": "错误:\"{}\" - 调用lua事件\"{}\"时出错,函数:\"{}\",参数:{}",
|
||||
|
||||
"": "插件加载器",
|
||||
|
||||
|
@ -59,6 +59,13 @@
|
||||
|
||||
"": "Events system",
|
||||
|
||||
"events_not_callable": "Unable to add event \"{}\". Use \"{}\" instead. Skipping...",
|
||||
"events_not_found": "Event \"{}\" is not registered. Maybe {}? Skipping...",
|
||||
"events_calling_error": "Error calling \"{}\" in function \"{}\".",
|
||||
"events_lua_function_not_found": "Unable to call {}lua event - \"{}\" not found.",
|
||||
"events_lua_local": "local ",
|
||||
"events_lua_calling_error": "Error: \"{}\" - calling lua event \"{}\", function: \"{}\", arguments: {}",
|
||||
|
||||
"": "Plugins loader",
|
||||
|
||||
"plugins_not_found_load": "Function \"def load():\" not found.",
|
||||
|
@ -59,6 +59,13 @@
|
||||
|
||||
"": "Events system",
|
||||
|
||||
"events_not_callable": "Невозможно добавить ивент \"{}\". Использую лучше \"{}\". Скип...",
|
||||
"events_not_found": "Ивент \"{}\" не зарегистрирован. Может {}? Скип...",
|
||||
"events_calling_error": "Ошибка во время вызова \"{}\" в функции \"{}\".",
|
||||
"events_lua_function_not_found": "Невозможно вызвать {}lua ивент - \"{}\" не найдена.",
|
||||
"events_lua_local": "локальный ",
|
||||
"events_lua_calling_error": "Ошибка: \"{}\" - во время вызова lua ивента \"{}\", функция: \"{}\" , аргументы: {}",
|
||||
|
||||
"": "Plugins loader",
|
||||
|
||||
"plugins_not_found_load": "Функция \"def load():\" не найдена.",
|
||||
|
@ -62,7 +62,12 @@ class i18n:
|
||||
|
||||
# Events system
|
||||
|
||||
|
||||
events_not_callable: str
|
||||
events_not_found: str
|
||||
events_calling_error: str
|
||||
events_lua_function_not_found: str
|
||||
events_lua_local: str
|
||||
events_lua_calling_error: str
|
||||
|
||||
# Plugins loader
|
||||
|
||||
|
@ -106,6 +106,32 @@ class MultiLanguage:
|
||||
"client_event_invalid_data": "Invalid data returned from event: {}",
|
||||
"client_player_disconnected": "Left the server. Playtime: {} min",
|
||||
|
||||
"": "Events system",
|
||||
|
||||
"events_not_callable": "Unable to add event \"{}\". Use \"{}\" instead. Skipping...",
|
||||
"events_not_found": "Event \"{}\" is not registered. Maybe {}? Skipping...",
|
||||
"events_calling_error": "Error calling \"{}\" in function \"{}\".",
|
||||
"events_lua_function_not_found": "Unable to call {}lua event - \"{}\" not found.",
|
||||
"events_lua_local": "local ",
|
||||
"events_lua_calling_error": "Error: \"{}\" - calling lua event \"{}\", function: \"{}\", arguments: {}",
|
||||
|
||||
"": "Plugins loader",
|
||||
|
||||
"plugins_not_found_load": "Function \"def load():\" not found.",
|
||||
"plugins_not_found_start": "Function \"def start():\" not found.",
|
||||
"plugins_not_found_unload": "Function \"def unload():\" not found.",
|
||||
"plugins_kt_invalid": "\"kt\" variable does not belong to the KuiToi class.",
|
||||
"plugins_invalid": "Plugin \"{}\" cannot be run in KuiToi.",
|
||||
"plugins_error_loading": "An error occurred while loading the plugin {}: {}",
|
||||
|
||||
"": "Lua plugins loader",
|
||||
|
||||
"plugins_lua_enabled": "You have enabled Lua plugin support.",
|
||||
"plugins_lua_nuances_warning": "There are some nuances when working with Kuiti. If you have a suggestion for their solution, and it is related to KuiToi, please contact the developer.",
|
||||
"plugins_lua_legacy_config_create_warning": "Some BeamMP plugins require a properly configured ServerConfig.toml file to function.",
|
||||
"plugins_lua_legacy_config_create": "Creating it.",
|
||||
"plugins_lua_unload": "Stopping Lua plugin: {}",
|
||||
|
||||
"": "Command: man",
|
||||
"man_message_man": "man - Shows the help page for COMMAND.\nUsage: man COMMAND",
|
||||
"help_message_man": "Shows the help page for COMMAND.",
|
||||
|
Loading…
x
Reference in New Issue
Block a user