Skip to content

Commit 5ed7edc

Browse files
committed
refactor: use new command registration api
1 parent 8616969 commit 5ed7edc

3 files changed

Lines changed: 9 additions & 21 deletions

File tree

src/endstone_example/example_plugin.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
from endstone.command import Command, CommandSender
22
from endstone.plugin import Plugin
33

4-
from endstone_example.python_command import PythonCommand, PythonCommandExecutor
5-
from endstone_example.test_command import TestCommand
4+
from endstone_example.python_command import PythonCommandExecutor
65

76

87
class ExamplePlugin(Plugin):
@@ -11,9 +10,14 @@ def on_load(self) -> None:
1110

1211
def on_enable(self) -> None:
1312
self.logger.info("on_enable is called!")
14-
# note we pass in PythonCommand instead of PythonCommand() - use a class rather than an instance
15-
self.register_command(PythonCommand).executor = PythonCommandExecutor()
16-
self.register_command(TestCommand)
13+
14+
self.register_command(
15+
name="python", description="Zen of python", usages=["/python"], aliases=["py"]
16+
).executor = PythonCommandExecutor()
17+
18+
self.register_command(
19+
name="test", description="This is a test command from python", usages=["/test", "/test [value: int]"]
20+
)
1721

1822
def on_disable(self) -> None:
1923
self.logger.info("on_disable is called!")

src/endstone_example/python_command.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,6 @@
2424
Namespaces are one honking great idea -- let's do more of those!"""
2525

2626

27-
class PythonCommand(Command):
28-
def __init__(self):
29-
Command.__init__(self, "python")
30-
self.description = "Zen of python"
31-
self.usages = ["/python"]
32-
self.aliases = ["py"]
33-
34-
3527
class PythonCommandExecutor(CommandExecutor):
3628
def on_command(self, sender: CommandSender, command: Command, args: list[str]) -> bool:
3729
sender.send_message(zen_of_python)

src/endstone_example/test_command.py

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)