From 99befe91ac09e19cd500eaae6c20b4edcbead386 Mon Sep 17 00:00:00 2001 From: Vincent Date: Sat, 15 Jun 2024 19:07:32 +0100 Subject: [PATCH] feat: add more tests --- src/endstone_test/event_listener.py | 10 +++++++++- src/endstone_test/plugin.py | 9 ++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/endstone_test/event_listener.py b/src/endstone_test/event_listener.py index 61b4e5d..42adb1e 100644 --- a/src/endstone_test/event_listener.py +++ b/src/endstone_test/event_listener.py @@ -2,13 +2,21 @@ from functools import partial from endstone import ColorFormat, Server -from endstone.event import event_handler, PlayerJoinEvent +from endstone.event import event_handler, PlayerLoginEvent, PlayerJoinEvent from endstone.plugin import Plugin class EventListener: def __init__(self, plugin: Plugin): self._plugin = plugin + self._should_kick = True + + @event_handler + def on_player_login(self, event: PlayerLoginEvent) -> None: + if self._should_kick: + event.kick_message = "Player::kick is working. Please join again." + event.cancelled = True + self._should_kick = False @event_handler def on_player_join(self, event: PlayerJoinEvent) -> None: diff --git a/src/endstone_test/plugin.py b/src/endstone_test/plugin.py index dd836ae..0a4fc49 100644 --- a/src/endstone_test/plugin.py +++ b/src/endstone_test/plugin.py @@ -3,7 +3,6 @@ from endstone import __minecraft_version__ from endstone.plugin import Plugin - from endstone_test.event_listener import EventListener @@ -48,6 +47,14 @@ def on_enable(self) -> None: assert self.server.get_player("non-existent") is None assert self.server.get_player(uuid.uuid4()) is None + for level in self.server.levels: + self.logger.info(f"Level: {level.name}") + assert self.server.get_level(level.name) is level + + for dimension in level.dimensions: + self.logger.info(f"\tDimension: {dimension.name}") + assert level.get_dimension(dimension.name) is dimension + self.server.broadcast_message("Hello!") self.server.scheduler.run_task_timer(self, self.send_debug_message, delay=0, period=10)