Allow other plugins to override mine?

Discussion in 'Plugin Development' started by CRAZYxMUNK3Y, Mar 12, 2012.

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

    CRAZYxMUNK3Y

    Is it possible to allow certain plugins (Possibly set in a config) to override my plugin completly?

    EG: As stated here, my plugin breaks Factions as glass can still be broken in protected areas.

    Is there anyway to allow Factions (Or other plugins) to override my plugin in certain worlds/areas or just in general?

    Thanks
     
  2. Offline

    HappyPikachu

    I believe you want to lower your event priorities:
    http://forums.bukkit.org/threads/getting-your-priorities-straight-the-plugin-version.788/
     
  3. Offline

    CRAZYxMUNK3Y

  4. Offline

    nisovin

    You actually want to raise your event's priority, probably to HIGHEST, and you want to ignore if it's canceled. Thus:

    @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
     
  5. Offline

    CRAZYxMUNK3Y

    That worked thanks!

    How come the HIGHEST priority works though? Wouldn't that override others?

    (Sorry if dumb questions, just trying to get why it worked)

    Thanks
     
  6. It's not really a "priority" but more a "execute order"... the lowest events execute first and the highest executes last and the monitor priority executes after that.

    Also, if you won't cancel the event, you just want to monitor it, use monitor priority.
     
  7. Offline

    HappyPikachu

    Digi

    Since Crazy's event is now executed after Factions, shouldn't Crazy's event be getting the final say? This seems to contradict what Dinnerbone said:
     
  8. Offline

    CRAZYxMUNK3Y

    Digi HappyPikachu

    I thinking the same thing as what HappyPikachu said, or is it something to do with ignoreCancelled = true?
     
  9. Offline

    dsmyth1915

    My take on the whole priority is, lowest gets first say, but highest gets the final count. So if lowest sais to cancel an event, and then a plugin with a highest priority comes in and sais ignored cancelled=true then it overrides the lowest like it never happened.
     
  10. The thread is about a plugin allowing itself to be overwritten by other plugins... so, if the plugin sets the priority on lowest, it will cancel the event first BUT other plugins that have higher priority and cancel the same event will overwrite the initial plugin.

    And no, if you want to overwrite some other plugin's events you really shouldn't ignore cancelled because then it doesn't even trigger so you can't overwrite it.
     
  11. Offline

    HappyPikachu

    Digi: By that logic (which seems legit), Crazy's plugin event should be on Priority.LOWEST, but for some reason this works as desired when his event is on HIGHEST.

    Sorry to drag this out - I've got a personal interest. Maybe nisovin can shed some light on this?
     
  12. Well, if you want to clear stuff up, just register the same event multiple times with each possible priority and print them in the console... you can also do the same thing in a clone plugin to see how 2 plugins are triggered.
     
  13. Offline

    nisovin

    Listeners are called from LOWEST to HIGHEST. If you want to give other plugins a chance to cancel the event before you do something, you need to register your event at a higher priority than those other plugins.
     
  14. Well... this depends on what you mean by "overwrite" it seems... in my opinion:

    - If you use a event to trigger some code that shouldn't be triggered if some other plugin cancells that event, use MONITOR.
    - If you modify a event (setCancelled() or setResult(), etc) and you want to allow other plugins to overwrite those actions, use LOWEST or LOW.
    - If you want to do both from the above, use NORMAL or HIGH :p
    - If you want to do the 1st and 2nd without it beeing overwriteable (unless plugin devs overwrite events using MONITOR which is really bad practice), use HIGHEST.
     
  15. Offline

    HappyPikachu

    I think I got this. By putting Crazy's event on HIGHEST, Factions (assuming it's HIGH or NORMAL) can cancel out Crazy's event before it gets called. That right?
     
  16. Offline

    nisovin

    Right, which allows Crazy to ignore the cancelled event.
     
    HappyPikachu likes this.
Thread Status:
Not open for further replies.

Share This Page