Skip to content

Commit

Permalink
refactor(minecraft_command_register): ♻️ refactor functions
Browse files Browse the repository at this point in the history
  • Loading branch information
AnzhiZhang committed Dec 13, 2024
1 parent 18df36d commit d2dec31
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down

0 comments on commit d2dec31

Please sign in to comment.