Class Events

java.lang.Object
dev.demeng.pluginbase.Events

public final class Events extends Object
A functional event listening utility.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    call(@NotNull org.bukkit.event.Event event)
    Submit the event on the current thread
    static <T extends org.bukkit.event.Event>
    T
    callAndReturn(T event)
    Submit the event on the current thread
    static void
    callAsync(@NotNull org.bukkit.event.Event event)
    Submit the event on a new async thread.
    static <T extends org.bukkit.event.Event>
    T
    Submit the event on a new async thread.
    static void
    callSync(@NotNull org.bukkit.event.Event event)
    Submit the event on the main server thread.
    static <T extends org.bukkit.event.Event>
    T
    callSyncAndJoin(T event)
    Submit the event on the main server thread.
    static <T> @NotNull MergedSubscriptionBuilder<T>
    merge(@NotNull com.google.common.reflect.TypeToken<T> type)
    Makes a MergedSubscriptionBuilder for a given super type
    static <S extends org.bukkit.event.Event>
    @NotNull MergedSubscriptionBuilder<S>
    merge(@NotNull Class<S> superClass, @NotNull Class<? extends S>... eventClasses)
    Makes a MergedSubscriptionBuilder for a super event class
    static <S extends org.bukkit.event.Event>
    @NotNull MergedSubscriptionBuilder<S>
    merge(@NotNull Class<S> superClass, @NotNull org.bukkit.event.EventPriority priority, @NotNull Class<? extends S>... eventClasses)
    Makes a MergedSubscriptionBuilder for a super event class
    static <T> @NotNull MergedSubscriptionBuilder<T>
    merge(@NotNull Class<T> handledClass)
    Makes a MergedSubscriptionBuilder for a given super type
    static <T extends org.bukkit.event.Event>
    @NotNull SingleSubscriptionBuilder<T>
    subscribe(@NotNull Class<T> eventClass)
    Makes a SingleSubscriptionBuilder for a given event
    static <T extends org.bukkit.event.Event>
    @NotNull SingleSubscriptionBuilder<T>
    subscribe(@NotNull Class<T> eventClass, @NotNull org.bukkit.event.EventPriority priority)
    Makes a SingleSubscriptionBuilder for a given event

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Events

      public Events()
  • Method Details

    • subscribe

      @NotNull public static <T extends org.bukkit.event.Event> @NotNull SingleSubscriptionBuilder<T> subscribe(@NotNull @NotNull Class<T> eventClass)
      Makes a SingleSubscriptionBuilder for a given event
      Type Parameters:
      T - the event type
      Parameters:
      eventClass - the class of the event
      Returns:
      a SingleSubscriptionBuilder to construct the event handler
      Throws:
      NullPointerException - if eventClass is null
    • subscribe

      @NotNull public static <T extends org.bukkit.event.Event> @NotNull SingleSubscriptionBuilder<T> subscribe(@NotNull @NotNull Class<T> eventClass, @NotNull @NotNull org.bukkit.event.EventPriority priority)
      Makes a SingleSubscriptionBuilder for a given event
      Type Parameters:
      T - the event type
      Parameters:
      eventClass - the class of the event
      priority - the priority to listen at
      Returns:
      a SingleSubscriptionBuilder to construct the event handler
      Throws:
      NullPointerException - if eventClass or priority is null
    • merge

      @NotNull public static <T> @NotNull MergedSubscriptionBuilder<T> merge(@NotNull @NotNull Class<T> handledClass)
      Makes a MergedSubscriptionBuilder for a given super type
      Type Parameters:
      T - the super type class
      Parameters:
      handledClass - the super type of the event handler
      Returns:
      a MergedSubscriptionBuilder to construct the event handler
    • merge

      @NotNull public static <T> @NotNull MergedSubscriptionBuilder<T> merge(@NotNull @NotNull com.google.common.reflect.TypeToken<T> type)
      Makes a MergedSubscriptionBuilder for a given super type
      Type Parameters:
      T - the super type class
      Parameters:
      type - the super type of the event handler
      Returns:
      a MergedSubscriptionBuilder to construct the event handler
    • merge

      @NotNull @SafeVarargs public static <S extends org.bukkit.event.Event> @NotNull MergedSubscriptionBuilder<S> merge(@NotNull @NotNull Class<S> superClass, @NotNull @NotNull Class<? extends S>... eventClasses)
      Makes a MergedSubscriptionBuilder for a super event class
      Type Parameters:
      S - the super class type
      Parameters:
      superClass - the abstract super event class
      eventClasses - the event classes to be bound to
      Returns:
      a MergedSubscriptionBuilder to construct the event handler
    • merge

      @NotNull @SafeVarargs public static <S extends org.bukkit.event.Event> @NotNull MergedSubscriptionBuilder<S> merge(@NotNull @NotNull Class<S> superClass, @NotNull @NotNull org.bukkit.event.EventPriority priority, @NotNull @NotNull Class<? extends S>... eventClasses)
      Makes a MergedSubscriptionBuilder for a super event class
      Type Parameters:
      S - the super class type
      Parameters:
      superClass - the abstract super event class
      priority - the priority to listen at
      eventClasses - the event classes to be bound to
      Returns:
      a MergedSubscriptionBuilder to construct the event handler
    • call

      public static void call(@NotNull @NotNull org.bukkit.event.Event event)
      Submit the event on the current thread
      Parameters:
      event - the event to call
    • callAsync

      public static void callAsync(@NotNull @NotNull org.bukkit.event.Event event)
      Submit the event on a new async thread.
      Parameters:
      event - the event to call
    • callSync

      public static void callSync(@NotNull @NotNull org.bukkit.event.Event event)
      Submit the event on the main server thread.
      Parameters:
      event - the event to call
    • callAndReturn

      @NotNull public static <T extends org.bukkit.event.Event> T callAndReturn(@NotNull T event)
      Submit the event on the current thread
      Parameters:
      event - the event to call
    • callAsyncAndJoin

      @NotNull public static <T extends org.bukkit.event.Event> T callAsyncAndJoin(@NotNull T event)
      Submit the event on a new async thread.
      Parameters:
      event - the event to call
    • callSyncAndJoin

      @NotNull public static <T extends org.bukkit.event.Event> T callSyncAndJoin(@NotNull T event)
      Submit the event on the main server thread.
      Parameters:
      event - the event to call