Solved Looking for Example Usage of BukkitRunnable

Discussion in 'Plugin Development' started by Eggspurt, Jun 7, 2015.

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

    Eggspurt

    I want to run a Task that teleports a player to a specific location over and over for like 15 seconds or any time really. I am new to using Tasks so all I really need is one example of what I am looking for and I should be good :)

    Thanks y'all :)
     
  2. Offline

    BizarrePlatinum

    Eggspurt, teej107 and Konato_K like this.
  3. Offline

    justin_393

    Absolute easiest way is
    Code:
    new BukkitRunnable() {
      @Override
      public void run() {
    //whatever you want scheduled here
    }.runTaskTimer(instance of your plugin, long, long);
    }
     
  4. Offline

    Eggspurt

    Thanks for that, it doesn't really explain how to make a Repeating Counter, but not forever inside of a class. I am using like a Counter++ until a specific number, but I don't know how to make it stop or make it change phases. I've tried doing if (counter >= 10 && counter <= 20) {
    }
    It'll stop even after 20
     
  5. Offline

    justin_393

    Oh, if you want a counter do a simple for loop

    for (int x =o; x<whatever your max is; x++){
    This code will execute how ever many times you want.
    }
     
  6. Offline

    CraftBang

  7. Offline

    Eggspurt

    The issue with that is, then it'll run the same task for every player on the server. I need it individually, so each player has their own task, if that possible?
     
  8. Offline

    justin_393

    Get the player from the event/command, do the code I posted the first time, and bam, it runs individually for said player.
     
Thread Status:
Not open for further replies.

Share This Page