Class PlayerAttackEntityEvent

java.lang.Object
fr.fidorial.event.player.PlayerAttackEntityEvent
All Implemented Interfaces:
Cancellable, Event, PlayerEvent

public final class PlayerAttackEntityEvent extends Object implements PlayerEvent, Cancellable
Fired when a player swings at an entity, before any damage is applied.
Since:
0.1.0
  • Constructor Details

    • PlayerAttackEntityEvent

      public PlayerAttackEntityEvent(Player player, Entity target, float damage, double knockback, float attackStrength, boolean critical, boolean sweeping)
  • Method Details

    • player

      public Player player()
      Specified by:
      player in interface PlayerEvent
    • target

      public Entity target()
    • damage

      public float damage()
      Returns:
      the damage about to be dealt, in half-hearts, critical already applied
    • setDamage

      public void setDamage(float damage)
      Parameters:
      damage - the damage to deal instead; <= 0 makes the hit harmless
    • knockback

      public double knockback()
      Returns:
      the horizontal knockback strength about to be applied
    • setKnockback

      public void setKnockback(double knockback)
      Parameters:
      knockback - the knockback strength to apply instead; 0 disables it
    • attackStrength

      public float attackStrength()
      Returns:
      the attack cooldown charge of this swing, between 0.2 and 1
    • isCritical

      public boolean isCritical()
      Returns:
      true when this swing landed as a critical hit
    • isSweeping

      public boolean isSweeping()
      Returns:
      true when this swing also hits the entities around the target
    • setSweeping

      public void setSweeping(boolean sweeping)
      Parameters:
      sweeping - false to keep the hit on the primary target only
    • isCancelled

      public boolean isCancelled()
      Specified by:
      isCancelled in interface Cancellable
    • setCancelled

      public void setCancelled(boolean cancelled)
      Specified by:
      setCancelled in interface Cancellable