From d2dec31d38c2c5ed9eb15f4dc7a609d0ac92b437 Mon Sep 17 00:00:00 2001 From: Andy Zhang <37402126+AnzhiZhang@users.noreply.github.com> Date: Fri, 13 Dec 2024 11:41:22 +0000 Subject: [PATCH] =?UTF-8?q?refactor(minecraft=5Fcommand=5Fregister):=20?= =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor=20functions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../minecraft_command_register/__init__.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/minecraft_command_register/minecraft_command_register/__init__.py b/src/minecraft_command_register/minecraft_command_register/__init__.py index e9c11cc..5d5c444 100644 --- a/src/minecraft_command_register/minecraft_command_register/__init__.py +++ b/src/minecraft_command_register/minecraft_command_register/__init__.py @@ -55,7 +55,7 @@ def dict(self): } -def register(server: PluginServerInterface): +def read_registered_command(server: PluginServerInterface): # return if server is not startup if not server.is_server_startup(): return @@ -67,13 +67,17 @@ def register(server: PluginServerInterface): plugin_command_holder: PluginCommandHolder = value[0] json_data['data'].append(Node(key, plugin_command_holder.node).dict) - # register + # return + return json_data + + +def register(server: PluginServerInterface): + json_data = read_registered_command(server) server.logger.debug( f'Register commands to minecraft, tree:' f'\n{json.dumps(json_data, indent=4)}' ) server.execute(f'mcdr register {json.dumps(json_data)}') - return json_data def on_load(server: PluginServerInterface, prev_module):