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 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 for
      priority - The EventPriority for this listener
      handler - 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 listener
      eventClass - The class of the event being listened for
      priority - The EventPriority for this listener
      handler - 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 for
      priority - The EventPriority for this listener
      handler - 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 listener
      eventClass - The class of the event being listened for
      priority - The EventPriority for this listener
      handler - The callback to receive the event
    • BundledListener

      public BundledListener(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 for
      handler - 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 listener
      eventClass - The class of the event being listened for
      handler - The callback to receive the event and this BundledListener
    • BundledListener

      public BundledListener(Class<T> eventClass, Consumer<T> handler)
      Creates and registers a Listener for the given event
      Parameters:
      eventClass - The class of the event being listened for
      handler - The callback to receive the event
    • BundledListener

      public BundledListener(org.bukkit.plugin.Plugin plugin, Class<T> eventClass, Consumer<T> handler)
      Creates and registers a Listener for the given event
      Parameters:
      plugin - The plugin registering the listener
      eventClass - The class of the event being listened for
      handler - 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 for
      priority - The EventPriority for this listener
      handler - 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 for
      handler - The callback to receive the event
    • handleEvent

      public void handleEvent(T event)
    • unregister

      public void unregister()
      Unregisters this listener