Class EntityEffectEvent
java.lang.Object
fr.fidorial.event.entity.EntityEffectEvent
- All Implemented Interfaces:
Cancellable, Event
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumWhat happens to the effect. -
Constructor Summary
ConstructorsConstructorDescriptionEntityEffectEvent(LivingEntity entity, EntityEffectEvent.Action action, @Nullable MobEffectInstance previous, @Nullable MobEffectInstance effect) Creates an event. -
Method Summary
Modifier and TypeMethodDescriptionaction()Returns what happens to the effect.effect()Returns the effect running after,nullwhen the effect is removed.entity()Returns the affected entity.booleanReturnstrueif the action this event describes will not happen.previous()Returns the effect running before,nullwhen the effect is added.voidsetCancelled(boolean cancelled) Prevents or re-allows the action this event describes.voidsetEffect(MobEffectInstance effect) Replaces the effect about to be applied, for instance to shorten it.
-
Constructor Details
-
EntityEffectEvent
public EntityEffectEvent(LivingEntity entity, EntityEffectEvent.Action action, @Nullable MobEffectInstance previous, @Nullable MobEffectInstance effect) Creates an event.- Parameters:
entity- the affected entityaction- what happens to the effectprevious- the effect running before, ornullwhen it isEntityEffectEvent.Action.ADDEDeffect- the effect running after, ornullwhen it is removed- Since:
- 0.1.0
-
-
Method Details
-
entity
-
action
Returns what happens to the effect.- Returns:
- what happens to the effect
- Since:
- 0.1.0
-
previous
Returns the effect running before,nullwhen the effect is added.- Returns:
- the effect running before,
nullwhen the effect is added - Since:
- 0.1.0
-
effect
Returns the effect running after,nullwhen the effect is removed.- Returns:
- the effect running after,
nullwhen the effect is removed - Since:
- 0.1.0
-
setEffect
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 removedIllegalArgumentException- if the effect is of another type- Since:
- 0.1.0
-
isCancelled
public boolean isCancelled()Description copied from interface:CancellableReturnstrueif the action this event describes will not happen.- Specified by:
isCancelledin interfaceCancellable- Returns:
trueif the action this event describes will not happen
-
setCancelled
public void setCancelled(boolean cancelled) Description copied from interface:CancellablePrevents or re-allows the action this event describes.- Specified by:
setCancelledin interfaceCancellable- Parameters:
cancelled-trueto prevent it
-