Package dev.demeng.pluginbase
Class Events
java.lang.Object
dev.demeng.pluginbase.Events
A functional event listening utility.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcall(@NotNull org.bukkit.event.Event event) Submit the event on the current threadstatic <T extends org.bukkit.event.Event>
TcallAndReturn(T event) Submit the event on the current threadstatic voidcallAsync(@NotNull org.bukkit.event.Event event) Submit the event on a new async thread.static <T extends org.bukkit.event.Event>
TcallAsyncAndJoin(T event) Submit the event on a new async thread.static voidcallSync(@NotNull org.bukkit.event.Event event) Submit the event on the main server thread.static <T extends org.bukkit.event.Event>
TcallSyncAndJoin(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 typestatic <S extends org.bukkit.event.Event>
@NotNull MergedSubscriptionBuilder<S>Makes a MergedSubscriptionBuilder for a super event classstatic <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 classstatic <T> @NotNull MergedSubscriptionBuilder<T>Makes a MergedSubscriptionBuilder for a given super typestatic <T extends org.bukkit.event.Event>
@NotNull SingleSubscriptionBuilder<T>Makes a SingleSubscriptionBuilder for a given eventstatic <T extends org.bukkit.event.Event>
@NotNull SingleSubscriptionBuilder<T>Makes a SingleSubscriptionBuilder for a given event
-
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
SingleSubscriptionBuilderto 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 eventpriority- the priority to listen at- Returns:
- a
SingleSubscriptionBuilderto 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
MergedSubscriptionBuilderto 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
MergedSubscriptionBuilderto 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 classeventClasses- the event classes to be bound to- Returns:
- a
MergedSubscriptionBuilderto 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 classpriority- the priority to listen ateventClasses- the event classes to be bound to- Returns:
- a
MergedSubscriptionBuilderto 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
-