Solved Get plugin HandlerList

Discussion in 'Plugin Development' started by NemesisMate, Oct 16, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    NemesisMate

    I would like to unregister a full Listener class (all it's handlers) without having to disable event by event.
    For example, I have a class MyListener (implements Listener) and there I have BlockBreakEvent, BlockPlaceEvent and EtityDeathEvent. If I want to unregister this three events inside that class without affecting other events of the same type on the plugin I know the way:
    Code:java
    1. BlockBreakEvent.getHandlerList().ungeregister(myListenerInstance);
    2. BlockPlaceEvent.getHandlerList().ungeregister(myListenerInstance);
    3. EntityDeathEvent.getHandlerList().ungeregister(myListenerInstance);

    But what about unregistering all the handlers from the same class on a single operation?, something like:
    pluginInstance.getHandlerList().ungeregister(myListenerInstance);
    Is it possible?
     
  2. Offline

    xize

    NemesisMate

    use this:
    Code:
    HandlerList.unregisterAll(yourplugin);
    
    edit I had misread something, you can also use the HandlerList to unregister all listeners from the same type by using HandlerList.unregisterAll(EventName);
     
  3. Offline

    NemesisMate

    xize I think you did it bad again xD, is:
    Code:java
    1. HandlerList.unregisterAll(listenerInstance);

    Thanks very much :D.
     
Thread Status:
Not open for further replies.

Share This Page