Multiple Runnables or one big runnable

Discussion in 'Plugin Development' started by wand555, Mar 14, 2020.

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

    wand555

    Hello, I'm wondering whether it is best to do multiple BukkitRunnables or one big one.
    Lets say I have 5 things I have to check. These include checking if a player has a certain thing (e.g. is in an area, has potion effect, etc..). Would it be smart to check everything on the same tick in the same runnable or should you split it up? (Splitting up also offers the end user the set their own intervals in the config, so I think thats an advantage)
     
  2. Offline

    timtower Moderator Moderator

    @wand555 Are the checks depending on each other or are they different things all together?
    Checking those things in the same tick should not be an issue btw.
     
  3. Offline

    wand555

    They are different things. I'm doing my best at this right now and I have to check for thirst, temperature and if a player is in a certain area (I thought it's better to that in a runnable instead of in every PlayerMoveEvent). Now it'd look a lot cleaner if each check has its own runnable, but I obviously don't want to sacrifice performance.
     
  4. Offline

    timtower Moderator Moderator

    @wand555 For a game that runs with 20 ticks per second: think that having a runnable for each task is just fine.
    But if they all use the same time: have 1 runnable that calls multiple functions.
     
Thread Status:
Not open for further replies.

Share This Page