Solved Need help with schedulers

Discussion in 'Plugin Development' started by Tdarnell, Apr 9, 2013.

Thread Status:
Not open for further replies.
  1. quick problem, I have no idea how to have a very simple sleep function using bukkits built in schedulers, I want to have a player.sendMessage send a few thousand ticks after the player joins, but when I have tried thread.sleep it has slept the entire server 0_o is there a simple way I can make the message wait x time before sending?? any help is appreciated ^.^ (it is not in the Main class, just incase that makes a difference :p)

    *bump*

    Bump
     
  2. Offline

    nggmc

  3. Ok sorry its in the wrong place, I didn't notice. but no that does not help. I've seen that, it just confused me more.
     
  4. Offline

    TnT

    Moved to the correct forum.
     
  5. Ok, Thanks
     
  6. Offline

    ScottGambler

  7. Offline

    chasechocolate

    Tdarnell use BukkitRunnables:
    Code:java
    1. new BukkitRunnable(){
    2. @Override
    3. public void run(){
    4. //Task to run later
    5. }
    6. }.runTaskLater(<plugin instance>, <delay in ticks>L); //20 ticks = 1 second, "L" means it is a long
     
  8. what I dont get is if I want to send a player a message when they join, can I use this runtasklater to make it run 5 seconds after join. I though this could not be used for player messages. :S very confused by all this
     
  9. Offline

    chasechocolate

    Yes... just put that in PlayerJoinEvent and make the delay in ticks 100 (20 ticks/second * 5 seconds = 100 ticks) and send the player a message in the run() method.
     
  10. ok, thanks, I didn't know how to use schedulers at all, I have never had to before, I usually use the system time and a hash table to make cooldowns or time limits, never had to simply make something wait for a few seconds before running. also I don't think my usual method would work with an on join event. thanks though
     
Thread Status:
Not open for further replies.

Share This Page