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 24, 2024
1 parent 1c68c40 commit 11e5797
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ build-backend = "hatchling.build"
[project]
name = "endstone-test"
version = "0.0.1"
dependencies = []
dependencies = [
"babel"
]
authors = [
{ name = "Vincent Wu", email = "[email protected]" },
{ name = "Endstone Developers", email = "[email protected]" },
Expand Down
12 changes: 12 additions & 0 deletions src/endstone_test/event_listener.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import datetime
from functools import partial

from babel import Locale
from endstone import ColorFormat, Server, Translatable
from endstone.event import *
from endstone.plugin import Plugin
Expand Down Expand Up @@ -42,6 +43,8 @@ def send_welcome_message(player_name: str) -> None:
self._plugin.logger.info(f"Velocity: {event.player.velocity}")
self._plugin.logger.info(f"Op status: {event.player.is_op}")
self._plugin.logger.info(f"Ping: {event.player.ping / datetime.timedelta(milliseconds=1)}")
self._plugin.logger.info(f"Locale: {event.player.locale}")
self._plugin.logger.info(f"Device: {event.player.device_os} {event.player.device_id}")
self._plugin.logger.info("===========================")

assert event.player.inventory.size == 36
Expand All @@ -62,6 +65,15 @@ def send_welcome_message(player_name: str) -> None:
event.player.exp_level = current_exp_lvl + 1
assert event.player.exp_level == current_exp_lvl + 1

event.player.fly_speed = 0.5
event.player.walk_speed = 0.05
assert abs(event.player.fly_speed - 0.5) <= 0.00001
assert abs(event.player.walk_speed - 0.05) <= 0.00001
event.player.fly_speed = 0.05
event.player.walk_speed = 0.10

assert Locale.parse(event.player.locale) is not None, event.player.locale

@event_handler
def on_player_death(self, event: PlayerDeathEvent):
# TODO: add player.is_dead check
Expand Down
1 change: 1 addition & 0 deletions src/endstone_test/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,6 @@ def send_debug_message(self):
f"Dimension: {player.location.dimension.name}\n"
f"InWater: {player.is_in_water}, InLava: {player.is_in_lava}\n"
f"OnGround: {player.is_on_ground}, MayFly: {player.allow_flight}, Flying: {player.is_flying}\n"
f"FlySpeed: {player.fly_speed:.2f}, WalkSpeed: {player.walk_speed:.2f}\n"
f"Exp: {player.exp_progress}, Lv: {player.exp_level}, Total: {player.total_exp}"
)

0 comments on commit 11e5797

Please sign in to comment.