How can i delay commands?

Discussion in 'Plugin Development' started by Btomhat, Aug 27, 2013.

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

    Btomhat

    i have some code:

    Code:java
    1. player.setVelocity(new Vector(0 , 1, 0));
    2.  
    3. player.getWorld().createExplosion(player.getLocation(), (float) 4.0);


    how can i put a delay inbetween with out freezing the whole server. the idea is to get the player to fly in the air then explode. these both work fine but because it all happens so fast its like you explode and the knockback launches you in the air. please help me!

    im very new to coding plugins. its going to take me a while to learn.
     
  2. Offline

    caseif

  3. Btomhat
    Funny, I did the same thing in my plugin a few days ago xD
    Use schedulers.

    Code:java
    1. Bukkit.getServer()
    2. .getScheduler()
    3. .scheduleSyncDelayedTask(plugin,
    4. new Runnable() {
    5. public void run() {
    6. //What you want to run
    7. }
    8. }, 10L);//How many ticks before it runs it
     
  4. Offline

    Btomhat

    thnx you guys
     
Thread Status:
Not open for further replies.

Share This Page