Skip to content

Commit

Permalink
fix: allow plugin to manage the lifecycle of multiple commands
Browse files Browse the repository at this point in the history
  • Loading branch information
wu-vincent committed Mar 7, 2024
1 parent 5c89e72 commit 3fda97f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions python/src/endstone/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3fda97f

Please sign in to comment.