Skip to content

Commit ba1a637

Browse files
committed
feat: add ServerLoadEvent handling in example plugin
1 parent 63b7c71 commit ba1a637

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/endstone_example/example_plugin.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from endstone.command import Command, CommandSender
2+
from endstone.event import ServerLoadEvent
23
from endstone.plugin import Plugin
34

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

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

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

0 commit comments

Comments
 (0)