BedrioxDOCUMENTATION
PLAYER EVENT

PlayerAttackEvent

Runs before the related authoritative action and may be cancelled within the documented server boundary.

Cancellable pre-eventBedriox\Api\Event\Player
WHAT IT REPRESENTS

Represents a player attack intent before Bedriox commits combat damage. It exposes the authoritative attacker, target, interaction type, and bounded proposed damage.

WHEN IT FIRES

Bedriox dispatches this before the related action commits. Cancelling it prevents that action at this event boundary.

EVENT SEQUENCE

Event after this

If this event is not cancelled and the action succeeds, Bedriox dispatches PlayerAttackedEvent as the committed outcome. That event cannot cancel or undo the result.

Event data

Bedriox\Api\Player\Player $attacker

Read-only event value supplied by Bedriox.

Bedriox\Api\Player\Player $target

Read-only event value supplied by Bedriox.

Bedriox\Api\Player\PlayerInteractionType $interaction

Read-only event value supplied by Bedriox.

Available methods

damage(): float

Typed public method.

setDamage(float $damage): void

Typed public method.

Inherited methods

isCancelled(): bool from Bedriox\Api\Event\CancellableEvent

Typed public method.

cancel(): void from Bedriox\Api\Event\CancellableEvent

Typed public method.

setCancelled(bool $cancelled): void from Bedriox\Api\Event\CancellableEvent

Typed public method.

captureState(): mixed from Bedriox\Api\Event\Event

Typed public method.

restoreState(mixed $state): void from Bedriox\Api\Event\Event

Typed public method.

setReadOnly(bool $readOnly): void from Bedriox\Api\Event\Event

Typed public method.

Listen for this event

Register the containing object with PluginContext::events()->registerSubscriber($this), then add a typed handler:

PHP
use Bedriox\Api\Event\EventHandler;
use Bedriox\Api\Event\Player\PlayerAttackEvent;

#[EventHandler]
public function onPlayerAttackEvent(PlayerAttackEvent $event): void
{
    // Keep listener work bounded and use public capabilities only.
}

View exact source ↗