What does event handlers do?

Discussion in 'Plugin Development' started by matejdro, Feb 22, 2012.

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

    matejdro

  2. Offline

    hatstand

    @EventHandler - Methods with that are event handlers. They handle events.
     
  3. Offline

    desht

    I think matejdro might be referring specifically to the HandlerList-related methods, which are used for caching a list of registered event handlers for each event. I won't pretend to fully understand them, but they're key to the greatly improved performance of the new 1.1 event model.

    You don't need to worry about them at all for normal event handling. For custom event handling, just add the field & method declarations to your new event as described in the Wiki, and Bukkit does the rest.
     
  4. Offline

    matejdro

    So, I simply enter those blank methods and forget about them?
     
  5. Offline

    hatstand

    Yeah, prettymuch. I do find it odd that they weren't included as abstract methods in the Event class.
     
  6. Offline

    dillyg10

    What no?
    Use eventhandlers to find certain events that happen
    for e/x if you want to find out if a player has a certain permission on login.. yo ucould do a PlayerLoginEvent, if you want to detect when a block is broken you can use a PlaceDestroyedEvent.. events are the bread and butter of bukkit :)
     
  7. Offline

    matejdro

    Ah, okay then thanks.

    dillyg10 we are talking about custom events here.
     
  8. Offline

    desht

    Java doesn't allow static abstract methods, or indeed any inheritance of static methods/fields.
     
    hatstand likes this.
  9. Also, the HanderList needs to belong to your actual event class, not some parent class (remember, static fields aren't bound to an instance but to a class). The list in your class only contains handlers for your event. If the list would be in a parent class, it would contain all handlers for all sub-classes (-events), thus making the whole system pretty redundant.
     
  10. Offline

    matejdro

  11. Offline

    desht

  12. Offline

    feildmaster

    Yeah, it informs you that the event needs a HandlerList, more specifically a function that needs a HandlerList. Hopefully that gets people aware. Also: Custom Events
     
Thread Status:
Not open for further replies.

Share This Page