From 3fda97f670e704dcde16862fc20d07ea0adc62c6 Mon Sep 17 00:00:00 2001 From: Vincent Date: Thu, 7 Mar 2024 00:54:30 +0000 Subject: [PATCH] fix: allow plugin to manage the lifecycle of multiple commands --- python/src/endstone/plugin.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/python/src/endstone/plugin.py b/python/src/endstone/plugin.py index ccc4f0dbb..37fd29dc6 100644 --- a/python/src/endstone/plugin.py +++ b/python/src/endstone/plugin.py @@ -41,11 +41,12 @@ class Plugin(_Plugin): def __init__(self): _Plugin.__init__(self) self._description: PluginDescription | None = None - self._plugin_command: PluginCommand | None = None + self._plugin_commands: list[PluginCommand] = [] # keep them alive def register_command(self, command_type: typing.Type[Command]) -> PluginCommand: - self._plugin_command = PluginCommand(command_type(), self) - return self.server.register_plugin_command(self._plugin_command) + command = PluginCommand(command_type(), self) + self._plugin_commands.append(command) + return self.server.register_plugin_command(command) def _get_description(self) -> PluginDescription: return self._description