Class ListenerHandler


  • public class ListenerHandler
    extends Object
    This class is used to help invoke listener methods
    • Constructor Detail

      • ListenerHandler

        public ListenerHandler()
    • Method Detail

      • size

        public int size()
        Note: this is for test only
        Returns:
        the listener handler list
      • unregister

        public static void unregister​(Plugin plugin)
        Unregister all listeners bundled to the plugin
        Parameters:
        plugin - the plugin which need to unregister all its listeners
      • unregister

        public static void unregister​(Plugin plugin,
                                      Listener listener)
        Unregister the listener by the plugin
        Parameters:
        plugin - the plugin of the listener
        listener - the listener need to be unregistered
      • register

        public static void register​(Plugin plugin,
                                    Listener listener)
        Add the listener and bundle to the plugin
        Parameters:
        plugin - the plugin
        listener - the listener
      • unregisterAll

        public static boolean unregisterAll()
        Unregister all listeners
        Returns:
        true if there are some listeners not belonging to MainPlugin not been unregistered, false otherwise
      • unregister

        public void unregister​(Listener listener)
        Unregister the listener
        Parameters:
        listener - the listener need to be unregistered
      • register

        public <T extends Event> void register​(Listener listener,
                                               Method method,
                                               EventHandler handler)
        Register the listener
        Type Parameters:
        T - the event type
        Parameters:
        listener - the listener
        method - the listener method to this Event listener handler
        handler - the event handler
      • submit

        public <T extends Event> void submit​(T event)
        Submit the event to this listener handler
        Type Parameters:
        T - the event type
        Parameters:
        event - the event need to be submitted