When should you use the MONITOR event priority?

Discussion in 'Plugin Development' started by imjake9, Jun 27, 2012.

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

    imjake9

    I'm starting to wonder exactly what the best practices are for using EventPriority.MONITOR for handling events. The basic usage is obvious. You should clearly use it for logging plugins since it only needs to know if the event happened or not. However, there are less clear cases when I'm unsure about if using it's a good idea or not.

    For example, let's say I have a plugin that gives a player some items when he dies. Should I listen to PlayerRespawnEvent using the MONITOR priority? I'm not modifying the event in any way, so there's no real reason to use other priorities. Also, if I use a lower priority, there's a chance that a higher priority listener might cancel the event, and I would not have any way to remove the items from the player, since I didn't know it was cancelled. On the other hand, monitor seems like something reserved for logging. What's the correct priority here?
     
  2. Offline

    nisovin

    If you want to perform some action based on the outcome of an event, use MONITOR. If you plan on modifying the event in any way, don't use MONITOR. It's that simple. So for your example, the answer is yes, you can use MONITOR in that situation.
     
    ReddChicken and thebiologist13 like this.
  3. Offline

    imjake9

    Alright, great. Thanks for the help!
     
  4. Offline

    theguynextdoor

    MONITOR is generally used if you have no intention of changing the outcome of the event, so you could use it here. As stated before anyway :p
     
Thread Status:
Not open for further replies.

Share This Page