Skip to content

Commit

Permalink
feat: add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wu-vincent committed Jun 15, 2024
1 parent b1cce60 commit 99befe9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/endstone_test/event_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
9 changes: 8 additions & 1 deletion src/endstone_test/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

from endstone import __minecraft_version__
from endstone.plugin import Plugin

from endstone_test.event_listener import EventListener


Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 99befe9

Please sign in to comment.