Skip to content

Commit

Permalink
feat: add tests for boss bar
Browse files Browse the repository at this point in the history
  • Loading branch information
wu-vincent committed Feb 23, 2025
1 parent 79e9579 commit a73afa3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/endstone_test/command_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import numpy as np
from endstone import ColorFormat, Player
from endstone.boss import BarColor, BarStyle
from endstone.command import (
Command,
CommandExecutor,
Expand Down Expand Up @@ -117,7 +118,7 @@ def on_command(
sender.send_error_message(f"Unknown sender: {sender.__class__}")
return False

case ["player", ("toast" | "title" | "kick" | "particle") as test_type]:
case ["player", test_type]:
if not isinstance(sender, Player):
sender.send_error_message(
"You must execute this command as a player"
Expand All @@ -144,6 +145,13 @@ def on_command(
location.y,
location.z,
)
elif test_type == "boss":
boss_bar = sender.server.create_boss_bar(
title="Test", color=BarColor.RED, style=BarStyle.SEGMENTED_10
)
boss_bar.progress = 0.75
boss_bar.add_player(sender)
sender.send_message("Boss bar added!")

case ["block", *rest]:
sender.send_message(str(rest))
Expand Down
8 changes: 8 additions & 0 deletions src/endstone_test/event_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,14 @@ def on_script_message(self, event: ScriptMessageEvent):
f"Script message received from {event.sender}: message_id={event.message_id}, message={event.message}"
)

# @event_handler
# def on_packet_receive(self, event: DataPacketReceiveEvent):
# self._plugin.logger.info(f"IN: {event.player.name} " + " ".join(f"{byte:02x}" for byte in event.data))

# @event_handler
# def on_packet_send(self, event: DataPacketSendEvent):
# self._plugin.logger.info(f"OUT: {event.player.name} " + " ".join(f"{byte:02x}" for byte in event.data))

@property
def server(self) -> Server:
return self._plugin.server
2 changes: 1 addition & 1 deletion src/endstone_test/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class EndstoneTest(Plugin):
"usages": [
"/test (form)<test: FormTestAction> (message|action|modal)<type: FormTestTypes>",
"/test (sender)<test: SenderTestAction>",
"/test (player)<test: PlayerTestAction> (toast|title|kick|particle)<type: PlayerTestTypes>",
"/test (player)<test: PlayerTestAction> (toast|title|kick|particle|boss)<type: PlayerTestTypes>",
"/test (block)<test: BlockTestAction> <block: block> [blockStates: block_states]",
"/test (broadcast)<test: BroadcastTestAction>",
],
Expand Down

0 comments on commit a73afa3

Please sign in to comment.