public final class ListenerManager extends Object
SubListener
referencesModifier and Type | Method and Description |
---|---|
static <S extends SubListener<? extends Plugin>> |
getListener(Class<S> listener)
Gets a listener by its string name.
|
static <P extends Plugin,S extends SubListener<P>> |
getRegisteringPlugin(Class<S> listener)
Returns the
Plugin relevant to the passed SubListener
class |
static <T extends SubListener<?>> |
isRegistered(Class<T> listener)
Returns whether or not a listener is registered under the relevant
listener key
|
static boolean |
isRegisteredToBukkit(Plugin p,
Listener l)
Returns
true if the passed Listener has another Listener
of the same class type already registered for bukkit. |
static <T extends Event> |
listen(Class<T> clazz,
Consumer<T> event)
Allows registering an anonymous listener for any bukkit listeners using
Java 8's function API, useful for listening to events in one-liner solutions
|
static <S extends SubListener<?>> |
registerListener(S listener)
Registers a listener through Bukkit and
ListenerManager |
static <T extends SubListener<?>> |
registerListeners(T... listeners)
Calls
registerListener(SubListener) for every
passed listener. |
static void |
release()
Unregisters all the listeners attached to this
ListenerManager . |
static void |
unregisterListener(Class<? extends SubListener<?>> listener)
Unregisters a specific
SubListener from both CodelanxLib and
Bukkit |
public static <S extends SubListener<? extends Plugin>> S getListener(Class<S> listener)
S
- The SubListener
typelistener
- An instance of the class type to retrieveIllegalArgumentException
- If the listener isn't registeredpublic static <P extends Plugin,S extends SubListener<P>> P getRegisteringPlugin(Class<S> listener)
Plugin
relevant to the passed SubListener
classP
- The Plugin
typeS
- The SubListener
typelistener
- The SubListener
class that was registeredPlugin
that registered the SubListener
IllegalArgumentException
- If the listener isn't registeredpublic static <T extends SubListener<?>> boolean isRegistered(Class<T> listener)
T
- The SubListener
class to getlistener
- The listener class to look fortrue
if registered, false
otherwisepublic static boolean isRegisteredToBukkit(Plugin p, Listener l)
true
if the passed Listener
has another Listener
of the same class type already registered for bukkit. This should not be
used with any listeners that are from an anonymous class, as this will
return true
for any other anonymous classes as wellpublic static <S extends SubListener<?>> S registerListener(S listener)
ListenerManager
S
- The SubListener
class to registerlistener
- The listener to registerIllegalArgumentException
- Attempted to register a Listener twicepublic static <T extends SubListener<?>> void registerListeners(T... listeners)
registerListener(SubListener)
for every
passed listener. Any exception thrown will be re-thrown after all
listeners are registeredT
- The SubListener
class to registerlisteners
- The listeners to registerIllegalArgumentException
- Attempted to register a Listener twicepublic static void unregisterListener(Class<? extends SubListener<?>> listener)
SubListener
from both CodelanxLib and
Bukkitlistener
- The SubListener
class to unregisterpublic static void release()
ListenerManager
.
Can only be called from CodelanxLib
com.codelanx.commons.util.exception.IllegalInvocationException
- Only CodelanxLib
can useCopyright © 2017. All rights reserved.