mirror of
https://github.com/kuitoi/kuitoi-Server.git
synced 2025-08-17 16:25:36 +00:00
Optimize imports; Rethink i18n;
This commit is contained in:
parent
b1eab1d1a4
commit
499c9f2149
@ -8,13 +8,20 @@
|
||||
__title__ = 'KuiToi-Server'
|
||||
__description__ = 'BeamingDrive Multiplayer server compatible with BeamMP clients.'
|
||||
__url__ = 'https://github.com/kuitoi/kuitoi-Server'
|
||||
__version__ = '0.1.2'
|
||||
__build__ = 178
|
||||
__version__ = '0.1.3'
|
||||
__build__ = 214
|
||||
__author__ = 'SantaSpeen'
|
||||
__author_email__ = 'admin@kuitoi.su'
|
||||
__license__ = "FPA"
|
||||
__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 builtins
|
||||
import os
|
||||
@ -22,22 +29,30 @@ import webbrowser
|
||||
|
||||
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 MultiLanguage
|
||||
from main import parser
|
||||
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()
|
||||
asyncio.set_event_loop(loop)
|
||||
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
|
||||
log.debug("Initializing i18n...")
|
||||
ml = MultiLanguage()
|
||||
@ -46,19 +61,15 @@ ml.builtins_hook()
|
||||
|
||||
log.info(i18n.hello)
|
||||
|
||||
# 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(i18n.config_file % config_path)
|
||||
if config.Server['debug'] is True:
|
||||
core.utils.set_debug_status()
|
||||
log.info(i18n.debug)
|
||||
log = get_logger("init")
|
||||
log.debug("Debug mode enabled!")
|
||||
log.debug(i18n.config_info % config)
|
||||
ev = EventsSystem()
|
||||
ev.builtins_hook()
|
||||
|
||||
if not os.path.exists("plugins"):
|
||||
os.mkdir("plugins")
|
||||
pl = PluginsLoader("plugins")
|
||||
pl.load_plugins()
|
||||
|
||||
ev.call_event("on_starting")
|
||||
|
||||
# Key handler..
|
||||
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("exit", console.stop, "stop - Just shutting down the server.\nUsage: stop", "Server shutdown.")
|
||||
|
||||
|
||||
# Dirs
|
||||
if not os.path.exists("mods"):
|
||||
os.mkdir("mods")
|
||||
if not os.path.exists("plugins"):
|
||||
os.mkdir("plugins")
|
||||
|
||||
log.info(i18n.init)
|
||||
|
Loading…
x
Reference in New Issue
Block a user