Jump to content

"Configurable" event priority - is this OK?


CosmicDan

Recommended Posts

Howdy,

 

Is this alright or is there a better way?

 

@SubscribeEvent(priority = EventPriority.LOWEST)
public void onSomeEventWithResultLate(SomeEventWithResult event) {
  if (ModConfig.COMPATIBILITY.runLatest) {
    // do stuff as late as possible so hopefully our result is the one that counts
  }
}

@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onSomeEventWithResultEarly(SomeEventWithResult event) {
  if (!ModConfig.COMPATIBILITY.runLatest) {
    // do stuff as soon as possible to let other mod events override it if they want
  }
}

 

Obviously the idea is to let the user decide whether they want this aspect of a mod to be more important to less important than other mods.

 

I may also have logic in the LOWEST priority to react differently depending on an existing result, if any, but that's neither here nor there.

Edited by CosmicDan
Method names

Windows software, Android hacking, and other curios

Link to comment
Share on other sites

Yeah, I think that should work except that if other mods set their priority to highest then you you're not guaranteed to have yours go before theirs (I assume the order is based on mod loading or modID alphabetical) and if other mods set their priority to lowest then you're not guaranteed to have yours go after thiers. In fact, one or the other will not fully work because if you're first in order for the highest then you'll be first in order for the lowest, and vice versa. But at least you can say you tried. And it should work for mods where they leave the priority at default (normal).

Edited by jabelar
  • Thanks 1

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.