Class Events

java.lang.Object
com.sk89q.worldguard.bukkit.util.Events

public final class Events extends Object
Utility methods to deal with events.
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    fire(org.bukkit.event.Event event)
    Fire an event.
    static <T extends org.bukkit.event.Event & org.bukkit.event.Cancellable>
    boolean
    fireAndTestCancel(T eventToFire)
    Fire the eventToFire and return whether the event was cancelled.
    static <T extends org.bukkit.event.Event & org.bukkit.event.Cancellable & BulkEvent>
    boolean
    fireBulkEventToCancel(org.bukkit.event.Cancellable original, T eventToFire)
    Fire the eventToFire and cancel the original if the fired event is explicitly cancelled.
    static <T extends org.bukkit.event.Event & org.bukkit.event.Cancellable>
    boolean
    fireItemEventToCancel(org.bukkit.event.player.PlayerInteractEvent original, T eventToFire)
    Fire the eventToFire and cancel the original if the fired event is cancelled.
    static <T extends org.bukkit.event.Event & org.bukkit.event.Cancellable>
    boolean
    fireToCancel(org.bukkit.event.Cancellable original, T eventToFire)
    Fire the eventToFire 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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 the eventToFire 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 the eventToFire 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 cancel
      eventToFire - 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 the eventToFire 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 cancel
      eventToFire - 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 the eventToFire 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 cancel
      eventToFire - 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 the EntityDamageEvent.DamageCause.DROWNING cause, the entity would have its air level set to its maximum.
      Parameters:
      entity - the entity
      cause - the cuase