Class ListenerEntry

java.lang.Object
be.seeseemelk.mockbukkit.plugin.ListenerEntry

public class ListenerEntry extends Object
The ListenerEntry is a class that represents a single event handler of a plugin.
  • Constructor Details

    • ListenerEntry

      public ListenerEntry(Plugin plugin, 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 Plugin getPlugin()
      Returns:
      The plugin that owns the listener.
    • getListener

      public Listener getListener()
      Returns:
      The listener.
    • getMethod

      @NotNull public @NotNull Method getMethod()
      Returns:
      The method this listener is attached to.
    • invoke

      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(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(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:
      true if the handler can handle that event, false if it can't.