Skip to content

Commit

Permalink
feat: add ServerLoadEvent handling in example plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
wu-vincent committed Mar 22, 2024
1 parent 63b7c71 commit ba1a637
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/endstone_example/example_plugin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from endstone.command import Command, CommandSender
from endstone.event import ServerLoadEvent
from endstone.plugin import Plugin

from endstone_example.python_command import PythonCommandExecutor
Expand Down Expand Up @@ -53,6 +54,7 @@ def on_load(self) -> None:
def on_enable(self) -> None:
self.logger.info("on_enable is called!")
self.get_command("python").executor = PythonCommandExecutor()
self.register_event_handler(self.on_server_load) # TODO: use a decorate @event_handler instead

def on_disable(self) -> None:
self.logger.info("on_disable is called!")
Expand All @@ -74,3 +76,7 @@ def on_command(self, sender: CommandSender, command: Command, args: list[str]) -
sender.send_message(f"/{command.name} is executed from Python with arguments {args}!")

return True

# TODO: let's implement a @event_handler decorator
def on_server_load(self, event: ServerLoadEvent):
self.logger.info(f"{event.event_name} is passed to python plugin")

0 comments on commit ba1a637

Please sign in to comment.