Overriding other plugin's decisions

  • I wanted to ask if there is any way one plugin can override the decisions of another plugin.


    For example we have one plugin that cancels the PlayerMountNpcEvent is there any way I can force allow the event through another plugin or if one plugin cancels it, the event cannot happen? (I know the other plugins will still receive the event to do whatever they want with it but will they be able to force "uncancel" it?)

  • Well, basically the "cancelled state" can be removed by calling setCancelled(false);. But that depends on when the event listener is executed exactly (or more precisely, in which order the plugins are executed). Example: You have three plugins and they're actually called in this order (plugin 1, plugin 2, plugin 3). By default, the "cancelled" state is set to false. Now if plugin 1 cancels the event, plugin 2 and 3 can see that (by calling isCancelled()), so they can either ignore it (so the event will be cancelled), or set the cancel state to false (then the event will be executed). But if plugin 1 cancels the event, plugin 2 explicitly sets the cancelled state to false and plugin 3 cancels the event again, the event will be cancelled.

  • Hmmm... this seems to me hard to tell. Scenario:

    • Both plug-in A and plug-in B hooks the SomekindofEvent.
    • According to A, one of these events should be cancelled, but according to B it should not.

    I see at least two fuzzy points:

    • If A cancels it (event.setCancelled(true)) and, afterwards, B un-cancels it (event.setCancelled(false)), who wins? the last one?
    • There is no way to be sure that A gets the event before B or of any notification order in general.

    From one point of view, one could say that plug-in A is not the right solution for the task and it should be modified (which might be possible or not).


    From another point of view, this might be a much more general problem and an actual "protocol" should be devised for plug-ins to speak to each other. Still, in general, it might be impossible to tell which of not just two, but n plug-ins dealing with the same matter is right.


    EDIT: oh well, red51 beat me by 5 min!

  • And there is currently no way to know in which order plugins get the event right?


    A plugin load/execution order list for servers at least would be very convenient for such cases but still wouldn't solve the problem in every possible case, especially when considering n plugins. :/

Participate now!

Don’t have an account yet? Create a new account now and be part of our community!