Package com.marcusslover.plus.lib.events
Class BundledListener<T extends org.bukkit.event.Event>
java.lang.Object
com.marcusslover.plus.lib.events.BundledListener<T>
- Type Parameters:
T- The event being listened for
- All Implemented Interfaces:
org.bukkit.event.Listener
public class BundledListener<T extends org.bukkit.event.Event>
extends Object
implements org.bukkit.event.Listener
A compact way to define a Listener using a lambda
-
Constructor Summary
ConstructorsConstructorDescriptionBundledListener(Class<T> eventClass, BiConsumer<BundledListener<T>, T> handler) Creates and registers a Listener for the given eventBundledListener(Class<T> eventClass, Consumer<T> handler) Creates and registers a Listener for the given eventBundledListener(Class<T> eventClass, org.bukkit.event.EventPriority priority, BiConsumer<BundledListener<T>, T> handler) Creates and registers a Listener for the given eventBundledListener(Class<T> eventClass, org.bukkit.event.EventPriority priority, Consumer<T> handler) Creates and registers a Listener for the given eventBundledListener(org.bukkit.plugin.Plugin plugin, Class<T> eventClass, BiConsumer<BundledListener<T>, T> handler) Creates and registers a Listener for the given eventBundledListener(org.bukkit.plugin.Plugin plugin, Class<T> eventClass, Consumer<T> handler) Creates and registers a Listener for the given eventBundledListener(org.bukkit.plugin.Plugin plugin, Class<T> eventClass, org.bukkit.event.EventPriority priority, BiConsumer<BundledListener<T>, T> handler) Creates and registers a Listener for the given eventBundledListener(org.bukkit.plugin.Plugin plugin, Class<T> eventClass, org.bukkit.event.EventPriority priority, Consumer<T> handler) Creates and registers a Listener for the given event -
Method Summary
Modifier and TypeMethodDescriptionvoidhandleEvent(T event) static <T extends org.bukkit.event.Event>
BundledListener<T> of(Class<T> eventClass, BiConsumer<BundledListener<T>, T> handler) Creates and registers a Listener for the given eventstatic <T extends org.bukkit.event.Event>
BundledListener<T> of(Class<T> eventClass, org.bukkit.event.EventPriority priority, BiConsumer<BundledListener<T>, T> handler) Creates and registers a Listener for the given eventvoidUnregisters this listener
-
Constructor Details
-
BundledListener
public BundledListener(Class<T> eventClass, org.bukkit.event.EventPriority priority, BiConsumer<BundledListener<T>, T> handler) Creates and registers a Listener for the given event- Parameters:
eventClass- The class of the event being listened forpriority- The EventPriority for this listenerhandler- The callback to receive the event and this BundledListener
-
BundledListener
public BundledListener(org.bukkit.plugin.Plugin plugin, Class<T> eventClass, org.bukkit.event.EventPriority priority, BiConsumer<BundledListener<T>, T> handler) Creates and registers a Listener for the given event- Parameters:
plugin- The plugin registering the listenereventClass- The class of the event being listened forpriority- The EventPriority for this listenerhandler- The callback to receive the event and this BundledListener
-
BundledListener
public BundledListener(Class<T> eventClass, org.bukkit.event.EventPriority priority, Consumer<T> handler) Creates and registers a Listener for the given event- Parameters:
eventClass- The class of the event being listened forpriority- The EventPriority for this listenerhandler- The callback to receive the event
-
BundledListener
public BundledListener(org.bukkit.plugin.Plugin plugin, Class<T> eventClass, org.bukkit.event.EventPriority priority, Consumer<T> handler) Creates and registers a Listener for the given event- Parameters:
plugin- The plugin registering the listenereventClass- The class of the event being listened forpriority- The EventPriority for this listenerhandler- The callback to receive the event
-
BundledListener
Creates and registers a Listener for the given event- Parameters:
eventClass- The class of the event being listened forhandler- The callback to receive the event and this BundledListener
-
BundledListener
public BundledListener(org.bukkit.plugin.Plugin plugin, Class<T> eventClass, BiConsumer<BundledListener<T>, T> handler) Creates and registers a Listener for the given event- Parameters:
plugin- The plugin registering the listenereventClass- The class of the event being listened forhandler- The callback to receive the event and this BundledListener
-
BundledListener
Creates and registers a Listener for the given event- Parameters:
eventClass- The class of the event being listened forhandler- The callback to receive the event
-
BundledListener
Creates and registers a Listener for the given event- Parameters:
plugin- The plugin registering the listenereventClass- The class of the event being listened forhandler- The callback to receive the event
-
-
Method Details
-
of
public static <T extends org.bukkit.event.Event> BundledListener<T> of(Class<T> eventClass, org.bukkit.event.EventPriority priority, BiConsumer<BundledListener<T>, T> handler) Creates and registers a Listener for the given event- Parameters:
eventClass- The class of the event being listened forpriority- The EventPriority for this listenerhandler- The callback to receive the event
-
of
public static <T extends org.bukkit.event.Event> BundledListener<T> of(Class<T> eventClass, BiConsumer<BundledListener<T>, T> handler) Creates and registers a Listener for the given event- Parameters:
eventClass- The class of the event being listened forhandler- The callback to receive the event
-
handleEvent
-
unregister
public void unregister()Unregisters this listener
-