mirror of
https://github.com/kuitoi/kuitoi-Server.git
synced 2025-08-18 00:35:36 +00:00
Optimize imports; Rethink i18n;
This commit is contained in:
parent
b1eab1d1a4
commit
499c9f2149
@ -8,13 +8,20 @@
|
|||||||
__title__ = 'KuiToi-Server'
|
__title__ = 'KuiToi-Server'
|
||||||
__description__ = 'BeamingDrive Multiplayer server compatible with BeamMP clients.'
|
__description__ = 'BeamingDrive Multiplayer server compatible with BeamMP clients.'
|
||||||
__url__ = 'https://github.com/kuitoi/kuitoi-Server'
|
__url__ = 'https://github.com/kuitoi/kuitoi-Server'
|
||||||
__version__ = '0.1.2'
|
__version__ = '0.1.3'
|
||||||
__build__ = 178
|
__build__ = 214
|
||||||
__author__ = 'SantaSpeen'
|
__author__ = 'SantaSpeen'
|
||||||
__author_email__ = 'admin@kuitoi.su'
|
__author_email__ = 'admin@kuitoi.su'
|
||||||
__license__ = "FPA"
|
__license__ = "FPA"
|
||||||
__copyright__ = 'Copyright 2023 © SantaSpeen (Maxim Khomutov)'
|
__copyright__ = 'Copyright 2023 © SantaSpeen (Maxim Khomutov)'
|
||||||
|
|
||||||
|
from main import parser
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
if args.version:
|
||||||
|
print(f"{__title__}:\n\tVersion: {__version__}\n\tBuild: {__build__}")
|
||||||
|
exit(0)
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import builtins
|
import builtins
|
||||||
import os
|
import os
|
||||||
@ -22,22 +29,30 @@ import webbrowser
|
|||||||
|
|
||||||
from prompt_toolkit.shortcuts import input_dialog, yes_no_dialog
|
from prompt_toolkit.shortcuts import input_dialog, yes_no_dialog
|
||||||
|
|
||||||
from modules import ConfigProvider
|
from .utils import get_logger
|
||||||
|
from modules import ConfigProvider, EventsSystem, PluginsLoader
|
||||||
from modules import Console
|
from modules import Console
|
||||||
from modules import MultiLanguage
|
from modules import MultiLanguage
|
||||||
from main import parser
|
|
||||||
from core.core import Core
|
from core.core import Core
|
||||||
from .utils import get_logger
|
|
||||||
|
|
||||||
args = parser.parse_args()
|
|
||||||
if args.version:
|
|
||||||
print(f"KuiToi-Server:\n\tVersion: {__version__}\n\tBuild: {__build__}")
|
|
||||||
exit(0)
|
|
||||||
|
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
asyncio.set_event_loop(loop)
|
asyncio.set_event_loop(loop)
|
||||||
log = get_logger("init")
|
log = get_logger("init")
|
||||||
|
|
||||||
|
# Config file init
|
||||||
|
config_path = "kuitoi.yml"
|
||||||
|
if args.config:
|
||||||
|
config_path = args.config
|
||||||
|
config_provider = ConfigProvider(config_path)
|
||||||
|
config = config_provider.open_config()
|
||||||
|
log.info("Use %s for config." % config_path)
|
||||||
|
if config.Server['debug'] is True:
|
||||||
|
core.utils.set_debug_status()
|
||||||
|
log.info("Getting new logging with DEBUG level!")
|
||||||
|
log = get_logger("init")
|
||||||
|
log.debug("Debug mode enabled!")
|
||||||
|
log.debug("Use %s for config." % config)
|
||||||
|
|
||||||
# i18n init
|
# i18n init
|
||||||
log.debug("Initializing i18n...")
|
log.debug("Initializing i18n...")
|
||||||
ml = MultiLanguage()
|
ml = MultiLanguage()
|
||||||
@ -46,19 +61,15 @@ ml.builtins_hook()
|
|||||||
|
|
||||||
log.info(i18n.hello)
|
log.info(i18n.hello)
|
||||||
|
|
||||||
# Config file init
|
ev = EventsSystem()
|
||||||
config_path = "kuitoi.yml"
|
ev.builtins_hook()
|
||||||
if args.config:
|
|
||||||
config_path = args.config
|
if not os.path.exists("plugins"):
|
||||||
config_provider = ConfigProvider(config_path)
|
os.mkdir("plugins")
|
||||||
config = config_provider.open_config()
|
pl = PluginsLoader("plugins")
|
||||||
log.info(i18n.config_file % config_path)
|
pl.load_plugins()
|
||||||
if config.Server['debug'] is True:
|
|
||||||
core.utils.set_debug_status()
|
ev.call_event("on_starting")
|
||||||
log.info(i18n.debug)
|
|
||||||
log = get_logger("init")
|
|
||||||
log.debug("Debug mode enabled!")
|
|
||||||
log.debug(i18n.config_info % config)
|
|
||||||
|
|
||||||
# Key handler..
|
# Key handler..
|
||||||
if not config.Auth['key']:
|
if not config.Auth['key']:
|
||||||
@ -88,11 +99,7 @@ console.logger_hook()
|
|||||||
console.add_command("stop", console.stop, "stop - Just shutting down the server.\nUsage: stop", "Server shutdown.")
|
console.add_command("stop", console.stop, "stop - Just shutting down the server.\nUsage: stop", "Server shutdown.")
|
||||||
console.add_command("exit", console.stop, "stop - Just shutting down the server.\nUsage: stop", "Server shutdown.")
|
console.add_command("exit", console.stop, "stop - Just shutting down the server.\nUsage: stop", "Server shutdown.")
|
||||||
|
|
||||||
|
|
||||||
# Dirs
|
|
||||||
if not os.path.exists("mods"):
|
if not os.path.exists("mods"):
|
||||||
os.mkdir("mods")
|
os.mkdir("mods")
|
||||||
if not os.path.exists("plugins"):
|
|
||||||
os.mkdir("plugins")
|
|
||||||
|
|
||||||
log.info(i18n.init)
|
log.info(i18n.init)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user