Custom Events Tutorial

Discussion in 'Plugin Development' started by NoLiver92, Aug 26, 2013.

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

    NoLiver92

    Is there anywhere where i can get a clear tutorial on how to create and use custom events?
     
  2. Offline

    Napkin222

    Essentially, create your event and extend the Event class.

    Then, you need to add this set of code:

    Code:java
    1. private static HandlerList handlers = new HandlerList();
    2.  
    3. public static HandlerList getHandlerList(){
    4. return handlers;
    5. }
    6.  
    7. public HandlerList getHandlers(){
    8. return handlers;
    9. }


    If you wish to add isCancelled() and setCancelled() then make the class implement Cancellable and add:

    Code:java
    1. private boolean cancelled = false;
    2.  
    3. public void setCancelled(boolean cancelled){
    4. this.cancelled = cancelled;
    5. }
    6.  
    7. public boolean isCancelled(){
    8. return cancelled;
    9. }


    It is all explained here: http://wiki.bukkit.org/Event_API_Reference
     
    evilmidget38 likes this.
Thread Status:
Not open for further replies.

Share This Page