Best way to run a method many times after certain amount of time?

Discussion in 'Plugin Development' started by ccrama, Jul 20, 2014.

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

    ccrama

    Hello Bukkit,

    For a plugin I'm developing, I need to edit a block, and after 1 minute need to restore the block back to its original material. Is it bad practice to make a delayed task runnable for each of the blocks? There is the possibility of hundreds of these delayed tasks. If so, is there a better way to go about this?

    Cheers,
    ccrama
     
  2. Offline

    MineStein

    If you are looking to use the same runnable multiple times at once:
    PHP:
    for (int i 1000i--) {
      
    // Insert code here
    }
     
  3. Offline

    Pizza371

    ccrama
    The way I would do this is (depending on how frequently you NEED to check) register a runnable to repeat every second, loop through a hashmap which contains info of the block and the time it was placed, then replace them if the time is equal to 1 minute. I'm not sure if there's a more efficient way though, no.
     
Thread Status:
Not open for further replies.

Share This Page