Package be.seeseemelk.mockbukkit.plugin
Class ListenerEntry
java.lang.Object
be.seeseemelk.mockbukkit.plugin.ListenerEntry
The
ListenerEntry is a class that represents a single event handler
of a plugin.-
Constructor Summary
ConstructorsConstructorDescriptionListenerEntry(org.bukkit.plugin.Plugin plugin, org.bukkit.event.Listener listener, @NotNull Method method) Creates a new listener entry for a given method. -
Method Summary
Modifier and TypeMethodDescriptionorg.bukkit.event.Listener@NotNull Methodorg.bukkit.plugin.Pluginvoidinvoke(org.bukkit.event.Event event) Tries to invoke the method handler with a given event.voidinvokeUnsafe(org.bukkit.event.Event event) Tries to invoke the method, but will cast any exceptions to RuntimeExceptions.booleanisCompatibleFor(org.bukkit.event.Event event) Checks if this method is compatible for a given event type.
-
Constructor Details
-
ListenerEntry
public ListenerEntry(org.bukkit.plugin.Plugin plugin, org.bukkit.event.Listener listener, @NotNull @NotNull Method method) Creates a new listener entry for a given method.- Parameters:
plugin- The plugin that owns the listener.listener- The listener object that contains the method.method- The method to call on events.
-
-
Method Details
-
getPlugin
public org.bukkit.plugin.Plugin getPlugin()- Returns:
- The plugin that owns the listener.
-
getListener
public org.bukkit.event.Listener getListener()- Returns:
- The listener.
-
getMethod
- Returns:
- The method this listener is attached to.
-
invoke
public void invoke(org.bukkit.event.Event event) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException Tries to invoke the method handler with a given event.- Parameters:
event- The event to pass on to the method.- Throws:
IllegalAccessException- Can be thrown by the event handler.IllegalArgumentException- Can be thrown by the event handler.InvocationTargetException- Can be thrown by the event handler.
-
invokeUnsafe
public void invokeUnsafe(org.bukkit.event.Event event) Tries to invoke the method, but will cast any exceptions to RuntimeExceptions.- Parameters:
event- The event to pass on to the method.
-
isCompatibleFor
public boolean isCompatibleFor(org.bukkit.event.Event event) Checks if this method is compatible for a given event type.- Parameters:
event- The event type the handler should be able to handle.- Returns:
trueif the handler can handle that event,falseif it can't.
-