Cancel Event When Another Plugin Has Canceled it?

Discussion in 'Plugin Development' started by XDemonic25, May 20, 2012.

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

    XDemonic25

    So I made 2 plugins, and I found that one of the events is causeing another event to run though it shouldnt.

    Plugin A: Makes It So You Cant Take Damage
    Plugin B: Records Damage Taken

    Though The Player Is Not Taking Any Damage, The Damage Count On Plugin B Is going up still.

    Both Events is on EntityDamage.

    So Bottom Line, I want Plugin B To Not Run The Event If Plugin A Event Is Canceled.
     
  2. Offline

    r0306

    XDemonic25
    Set the priority on Plugin B to high or highest.
     
  3. Then you have to use Priority.MONITOR in plugin B and check if the event was canceled.
    greetz blackwolf12333
     
  4. Offline

    wirher

    I think most important thing is event.isCancelled().
    But priorities in bukkit are kinda weird. For example.
    Plugin A has listener with priority "Lowest" and B has "Highest". Event will be passed to plugin A first. Yes, Lowest mean it will be first. So when you cancrl event in A, B can see it. But when you cancel B, A will not see it because it has processed this event before.
     
    r0306 likes this.
  5. Offline

    Kanlaki101

    Use the EventHandler...


    Code:
    @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
    public void myEvent(EventName event) {
        //blah
    }
     
  6. Offline

    LucasEmanuel

    Plugin b:
    Code:
    if(event.isCanceled() == false) {
        // record damage taken
    }
    Edit: Or you could use the one above me ;)
     
Thread Status:
Not open for further replies.

Share This Page