From 6a24262169bdda8fcda291c98584cc37245d4b41 Mon Sep 17 00:00:00 2001 From: Vincent Date: Tue, 17 Sep 2024 23:54:37 +0100 Subject: [PATCH] test: add tests for player.perform_command --- src/endstone_test/command_executor.py | 1 + src/endstone_test/event_listener.py | 2 +- src/endstone_test/tests/on_player_join/test_player.py | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/endstone_test/command_executor.py b/src/endstone_test/command_executor.py index cf46376..cb4f895 100644 --- a/src/endstone_test/command_executor.py +++ b/src/endstone_test/command_executor.py @@ -79,6 +79,7 @@ def on_command(self, sender: CommandSender, command: Command, args: list[str]) - sender.send_message("You are the console!") else: sender.send_error_message(f"Unknown sender: {sender.__class__}") + return False case ["player", ("toast" | "title" | "kick") as test_type]: if not isinstance(sender, Player): diff --git a/src/endstone_test/event_listener.py b/src/endstone_test/event_listener.py index 92ea4e6..c729899 100644 --- a/src/endstone_test/event_listener.py +++ b/src/endstone_test/event_listener.py @@ -39,7 +39,7 @@ def on_player_join(self, event: PlayerJoinEvent) -> None: @event_handler def on_player_interact(self, event: PlayerInteractEvent): self._plugin.logger.info( - f"{event.player.name} interacts with {event.block} (face={event.block_face}) using {event.item.type} item") + f"{event.player.name} interacts with {event.block} (face={event.block_face}) using {event.item} item") @event_handler def on_player_interact_actor(self, event: PlayerInteractActorEvent): diff --git a/src/endstone_test/tests/on_player_join/test_player.py b/src/endstone_test/tests/on_player_join/test_player.py index 1411338..f46dbf7 100644 --- a/src/endstone_test/tests/on_player_join/test_player.py +++ b/src/endstone_test/tests/on_player_join/test_player.py @@ -82,3 +82,7 @@ def test_player_scoreboard(player: Player, server: Server): player.scoreboard = server.scoreboard assert player.scoreboard is server.scoreboard + + +def test_run_command(player: Player): + assert player.perform_command("test sender")