Class EntityEffectEvent

java.lang.Object
fr.fidorial.event.entity.EntityEffectEvent
All Implemented Interfaces:
Cancellable, Event

public class EntityEffectEvent extends Object implements Event, Cancellable
Fired before a status effect of an entity is added, changed or removed.

Cancelling it keeps the previous effects untouched, except for EntityEffectEvent.Action.EXPIRED: an effect that ran out is always removed.

Since:
0.1.0
  • Constructor Details

  • Method Details

    • entity

      public LivingEntity entity()
      Returns the affected entity.
      Returns:
      the affected entity
      Since:
      0.1.0
    • action

      public EntityEffectEvent.Action action()
      Returns what happens to the effect.
      Returns:
      what happens to the effect
      Since:
      0.1.0
    • previous

      public @Nullable MobEffectInstance previous()
      Returns the effect running before, null when the effect is added.
      Returns:
      the effect running before, null when the effect is added
      Since:
      0.1.0
    • effect

      public @Nullable MobEffectInstance effect()
      Returns the effect running after, null when the effect is removed.
      Returns:
      the effect running after, null when the effect is removed
      Since:
      0.1.0
    • setEffect

      public void setEffect(MobEffectInstance effect)
      Replaces the effect about to be applied, for instance to shorten it.
      Parameters:
      effect - the effect to apply instead, of the same type
      Throws:
      IllegalStateException - if the effect is being removed
      IllegalArgumentException - if the effect is of another type
      Since:
      0.1.0
    • isCancelled

      public boolean isCancelled()
      Description copied from interface: Cancellable
      Returns true if the action this event describes will not happen.
      Specified by:
      isCancelled in interface Cancellable
      Returns:
      true if the action this event describes will not happen
    • setCancelled

      public void setCancelled(boolean cancelled)
      Description copied from interface: Cancellable
      Prevents or re-allows the action this event describes.
      Specified by:
      setCancelled in interface Cancellable
      Parameters:
      cancelled - true to prevent it