Scheduler Programming

Discussion in 'Plugin Development' started by FlareLine, Apr 23, 2014.

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

    FlareLine

    I'm in progress of making a plugin, and I need to run a number of different functions 4 times a second. I know how to set up the Task and all, however I'm not sure whether I should be using Async or Sync.
    I need to do something with Players, but there will be around 100 Players I need to run 4 or 5 methods for.

    Is it better to use Async and have a separate class for my Methods, or use Sync and have my methods in the Task? (I'm not sure if Sync will make the server run at too low TPS or not).

    Any suggestions will be helpful. Cheers.
     
  2. Offline

    Zethariel

    Depends on what you wanna do with the players.

    Generally if a method changes something in the player, adds/removes inventory, relocates, you shouldn't do async.
    You could break it up into smaller segments, like process 20 players per tick (100 players per 1/4 a second), lessening the burst of processing power you might need.
     
  3. Offline

    Rocoty

    What Zethariel said. Plus, looping through 100 players is nothing for the JVM.
     
  4. Offline

    FlareLine

  5. Offline

    Zethariel

    FlareLine

    Lemme put it this way - the only way I managed to make it chug, was looking up the block type + swapping it to something else for 100,000+ blocks at the same time (on top of the plugin doing lots of other stuff in the background)
     
  6. Offline

    FlareLine

    Zethariel Cheers for the useful information. :)
     
Thread Status:
Not open for further replies.

Share This Page