Is it possible to subscribe to all events?

Discussion in 'Plugin Development' started by apiocera, Oct 23, 2011.

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

    apiocera

    Is it possible to subscribe to all events without using lots of Listener classes? I need to harvest all possible events into a single function, yet the only way I see now is to make Listener classes and then manually subscribe to each event. And that is too much code.

    Is there any way to circumvent this?
     
  2. Offline

    daemitus

    Just normally register all the events, then send them to an aggregating listener than collects it all. Simple as onPlayerJoin(PlayerJoinEvent pje) {eventEater.eat(pje);}

    public class EventEater {
    public void eat(Event e) {...}
    }
    Check what each is later using instanceof PlayerJoinEvent if you need to.
     
  3. The more events you register, the more listeners are gonna listen. And if you register all events you would get performance issues.
     
  4. The question is: Why would you want to do that? I can't imagine a situation where you'd need to handle every single event that is fired.
    There are probably better and easier ways to do that.
     
Thread Status:
Not open for further replies.

Share This Page