-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update ExamplePlugin to use @event_handler decorator
- Loading branch information
1 parent
b8515c1
commit 62ba844
Showing
1 changed file
with
4 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
from endstone.command import Command, CommandSender | ||
from endstone.event import ServerLoadEvent | ||
from endstone.event import ServerLoadEvent, event_handler | ||
from endstone.plugin import Plugin | ||
|
||
from endstone_example.python_command import PythonCommandExecutor | ||
|
||
|
||
class ExamplePlugin(Plugin): | ||
name = "PythonExamplePlugin" | ||
version = "0.3.0" | ||
version = "0.4.0" | ||
api_version = "0.3" | ||
description = "Python example plugin for Endstone servers" | ||
authors = ["Endstone Developers <[email protected]>"] | ||
|
@@ -54,7 +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 | ||
self.register_events(self) | ||
|
||
def on_disable(self) -> None: | ||
self.logger.info("on_disable is called!") | ||
|
@@ -77,6 +77,6 @@ def on_command(self, sender: CommandSender, command: Command, args: list[str]) - | |
|
||
return True | ||
|
||
# TODO: let's implement a @event_handler decorator | ||
@event_handler | ||
def on_server_load(self, event: ServerLoadEvent): | ||
self.logger.info(f"{event.event_name} is passed to python plugin") |