Package com.sk89q.worldguard.bukkit.util
Class Events
java.lang.Object
com.sk89q.worldguard.bukkit.util.Events
Utility methods to deal with events.
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
fire
(org.bukkit.event.Event event) Fire an event.static <T extends org.bukkit.event.Event & org.bukkit.event.Cancellable>
booleanfireAndTestCancel
(T eventToFire) Fire theeventToFire
and return whether the event was cancelled.static <T extends org.bukkit.event.Event & org.bukkit.event.Cancellable & BulkEvent>
booleanfireBulkEventToCancel
(org.bukkit.event.Cancellable original, T eventToFire) Fire theeventToFire
and cancel the original if the fired event is explicitly cancelled.static <T extends org.bukkit.event.Event & org.bukkit.event.Cancellable>
booleanfireItemEventToCancel
(org.bukkit.event.player.PlayerInteractEvent original, T eventToFire) Fire theeventToFire
and cancel the original if the fired event is cancelled.static <T extends org.bukkit.event.Event & org.bukkit.event.Cancellable>
booleanfireToCancel
(org.bukkit.event.Cancellable original, T eventToFire) Fire theeventToFire
and cancel the original if the fired event is cancelled.static boolean
isExplosionCause
(org.bukkit.event.entity.EntityDamageEvent.DamageCause cause) Return whether the given cause is an explosion.static boolean
isFireCause
(org.bukkit.event.entity.EntityDamageEvent.DamageCause cause) Return whether the given damage cause is fire-reltaed.static void
restoreStatistic
(org.bukkit.entity.Entity entity, org.bukkit.event.entity.EntityDamageEvent.DamageCause cause) Restore the statistic associated with the given cause.
-
Method Details
-
fire
public static void fire(org.bukkit.event.Event event) Fire an event.- Parameters:
event
- the event
-
fireAndTestCancel
public static <T extends org.bukkit.event.Event & org.bukkit.event.Cancellable> boolean fireAndTestCancel(T eventToFire) Fire theeventToFire
and return whether the event was cancelled.- Type Parameters:
T
- an event that can be fired and is cancellable- Parameters:
eventToFire
- the event to fire- Returns:
- true if the event was cancelled
-
fireToCancel
public static <T extends org.bukkit.event.Event & org.bukkit.event.Cancellable> boolean fireToCancel(org.bukkit.event.Cancellable original, T eventToFire) Fire theeventToFire
and cancel the original if the fired event is cancelled.- Type Parameters:
T
- an event that can be fired and is cancellable- Parameters:
original
- the original event to potentially canceleventToFire
- the event to fire to consider cancelling the original event- Returns:
- true if the event was fired and it caused the original event to be cancelled
-
fireItemEventToCancel
public static <T extends org.bukkit.event.Event & org.bukkit.event.Cancellable> boolean fireItemEventToCancel(org.bukkit.event.player.PlayerInteractEvent original, T eventToFire) Fire theeventToFire
and cancel the original if the fired event is cancelled.- Type Parameters:
T
- an event that can be fired and is cancellable- Parameters:
original
- the original event to potentially canceleventToFire
- the event to fire to consider cancelling the original event- Returns:
- true if the event was fired and it caused the original event to be cancelled
-
fireBulkEventToCancel
public static <T extends org.bukkit.event.Event & org.bukkit.event.Cancellable & BulkEvent> boolean fireBulkEventToCancel(org.bukkit.event.Cancellable original, T eventToFire) Fire theeventToFire
and cancel the original if the fired event is explicitly cancelled.- Type Parameters:
T
- an event that can be fired and is cancellable- Parameters:
original
- the original event to potentially canceleventToFire
- the event to fire to consider cancelling the original event- Returns:
- true if the event was fired and it caused the original event to be cancelled
-
isFireCause
public static boolean isFireCause(org.bukkit.event.entity.EntityDamageEvent.DamageCause cause) Return whether the given damage cause is fire-reltaed.- Parameters:
cause
- the cause- Returns:
- true if fire related
-
isExplosionCause
public static boolean isExplosionCause(org.bukkit.event.entity.EntityDamageEvent.DamageCause cause) Return whether the given cause is an explosion.- Parameters:
cause
- the cause- Returns:
- true if it is an explosion cuase
-
restoreStatistic
public static void restoreStatistic(org.bukkit.entity.Entity entity, org.bukkit.event.entity.EntityDamageEvent.DamageCause cause) Restore the statistic associated with the given cause. For example, for theEntityDamageEvent.DamageCause.DROWNING
cause, the entity would have its air level set to its maximum.- Parameters:
entity
- the entitycause
- the cuase
-