Skip to content

Commit

Permalink
feat: add test for scoreboard api
Browse files Browse the repository at this point in the history
  • Loading branch information
wu-vincent committed Sep 1, 2024
1 parent 58ac99e commit c71be05
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/endstone_test/event_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ def on_player_join(self, event: PlayerJoinEvent) -> None:
assert event.player.has_permission("minecraft.command.me") is False
event.player.update_commands()

event.player.allow_flight = True
assert event.player.allow_flight is True
# event.player.allow_flight = True
# assert event.player.allow_flight is True

current_exp_lvl = event.player.exp_level
event.player.give_exp_levels(2)
Expand Down
14 changes: 14 additions & 0 deletions src/endstone_test/tests/test_scoreboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,17 @@ def test_list_objectives(server: Server, scoreboard: Scoreboard) -> None:
objective = scoreboard.get_objective("test_objective")
assert objective is not None
assert objective in scoreboard.objectives


def test_scoreboard_value(server: Server, scoreboard: Scoreboard) -> None:
server.dispatch_command(server.command_sender, "scoreboard objectives add test_objective dummy")
objective = scoreboard.get_objective("test_objective")
assert objective is not None

server.dispatch_command(server.command_sender, "scoreboard players set test_player test_objective 3")
score = objective.get_score("test_player")
assert score.is_score_set
assert score.value == 3

score = objective.get_score("non_existent_player")
assert not score.is_score_set

0 comments on commit c71be05

Please sign in to comment.