diff --git a/.gitignore b/.gitignore index 8d0a001..0662bcb 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ # python __pycache__ +/*_cache diff --git a/mcdreforged.plugin.json b/mcdreforged.plugin.json index 84a9372..b78a221 100644 --- a/mcdreforged.plugin.json +++ b/mcdreforged.plugin.json @@ -1,6 +1,6 @@ { "id": "tpm", - "version": "0.3.4", + "version": "0.4.0", "name": "TpManager", "description": { "en_us": "A Minecraft teleport manager", @@ -10,7 +10,7 @@ "link": "https://github.com/kmcsr/tpmanager_mcdr", "dependencies": { "mcdreforged": "^2.3.0", - "kpi": "~1.4.3" + "kpi": "~1.4.6" }, "resources": [ "LICENSE", diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..895c29a --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,18 @@ + +[tool.ruff] + +ignore = [ + "F403", + "F405", + "E701", +] + +line-length = 100 + +[tool.mypy] + +mypy_path = "${MYPY_CONFIG_FILE_DIR}/../kpi_mcdr/" +ignore_missing_imports = true +disable_error_code = ['misc'] + +[tool.poetry] diff --git a/tpm/__init__.py b/tpm/__init__.py index 8fbfc52..0c69fe2 100644 --- a/tpm/__init__.py +++ b/tpm/__init__.py @@ -9,7 +9,7 @@ __all__ = [] -export_pkg(globals_(), api) +__all__.extend(api.__all__) def on_load(server: MCDR.PluginServerInterface, prev_module): if prev_module is None: diff --git a/tpm/api.py b/tpm/api.py index 25960c5..02e8853 100644 --- a/tpm/api.py +++ b/tpm/api.py @@ -3,7 +3,7 @@ from .utils import * -__all__ = [] +__all__: list[str] = [] def on_load(server: MCDR.PluginServerInterface, prev_module): pass diff --git a/tpm/commands.py b/tpm/commands.py index b4f1f36..3c040f9 100644 --- a/tpm/commands.py +++ b/tpm/commands.py @@ -115,7 +115,7 @@ def askhere(self, source: MCDR.PlayerCommandSource, target: str): def accept(self, source: MCDR.PlayerCommandSource): cbs = self.__tpask_map.pop(source.player, None) if cbs is None: - send_message(s, MCDR.RText(tr('word.no_action'), color=MCDR.RColor.red)) + send_message(source, MCDR.RText(tr('word.no_action'), color=MCDR.RColor.red)) return cbs[0](source) @@ -124,7 +124,7 @@ def accept(self, source: MCDR.PlayerCommandSource): def reject(self, source: MCDR.PlayerCommandSource): cbs = self.__tpask_map.pop(source.player, None) if cbs is None: - send_message(s, MCDR.RText(tr('word.no_action'), color=MCDR.RColor.red)) + send_message(source, MCDR.RText(tr('word.no_action'), color=MCDR.RColor.red)) return cbs[1](source) @@ -133,7 +133,7 @@ def reject(self, source: MCDR.PlayerCommandSource): def cancel(self, source: MCDR.PlayerCommandSource): cb = self.__tpsender_map.pop(source.player, None) if cb is None: - send_message(s, MCDR.RText(tr('word.no_action'), color=MCDR.RColor.red)) + send_message(source, MCDR.RText(tr('word.no_action'), color=MCDR.RColor.red)) return cb(source) diff --git a/tpm/globals.py b/tpm/globals.py index 0d96ede..2d89b3b 100644 --- a/tpm/globals.py +++ b/tpm/globals.py @@ -4,6 +4,7 @@ import mcdreforged.api.all as MCDR from kpi.config import * +from kpi.utils import LazyData from .utils import * __all__ = [ diff --git a/tpm/utils.py b/tpm/utils.py index 62bdf83..7d766a9 100644 --- a/tpm/utils.py +++ b/tpm/utils.py @@ -1,16 +1,17 @@ import mcdreforged.api.all as MCDR -import kpi.utils +from kpi.utils import * __all__ = [ - 'new_thread', 'tr' + 'new_thread', 'tr', 'debug', 'log_info', 'log_warn', 'log_error', + 'get_server_instance', + 'new_timer', 'new_command', 'join_rtext', 'send_message', 'broadcast_message', + 'assert_instanceof', 'require_player', ] -kpi.utils.export_pkg(globals(), kpi.utils) - def new_thread(call): return MCDR.new_thread('tp_manager')(call) def tr(key: str, *args, **kwargs): - return MCDR.ServerInterface.get_instance().rtr(f'tpm.{key}', *args, **kwargs) + return get_server_instance().rtr(f'tpm.{key}', *args, **kwargs)