Does order matter for Listeners?

Discussion in 'Plugin Development' started by T0pAz7, Mar 25, 2015.

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

    T0pAz7

    For example, if I register Listener1 and then register Listener2 and have onPlayerDamage on both listeners, will the Listener1 be called before the Listener2?
     
  2. Offline

    nverdier

  3. Offline

    T0pAz7

    Here is another question. What if I use the default priority?
     
  4. Offline

    nverdier

    @T0pAz7 Then it will be EventPriority.NORMAL.
     
  5. Offline

    T0pAz7

    If all the events are on priority normal, will it run at the same time asynchronously or does it still run in order which listener registered first?
     
  6. Offline

    teej107

    @T0pAz7 It definitely won't run asynchronously. Honestly, I don't know. The best way to find out is to print out something to the console in both events and see which one comes first.
     
  7. Offline

    mythbusterma

    @T0pAz7

    No events that are not explicitly marked as asynchronous should be called asynchronously. According to the official docs, handlers with the same priority are called in an arbitrary order, although there should be no reason you need to ensure the order within the same level, there are enough levels provided.
     
    T0pAz7 likes this.
  8. Offline

    T0pAz7

    Thanks. Just was making sure since I was getting unexpected random result. I am going to use event priority now.
     
    mythbusterma likes this.
Thread Status:
Not open for further replies.

Share This Page