Solved BukkitScheduler question

Discussion in 'Plugin Development' started by L33m4n123, Sep 15, 2013.

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

    L33m4n123

    Hey!

    I want in my plugin that basicly from the start the Plugin is loaded until the server shuts down it checks every so and so often some stats and then update the players scoreboard accordingly.

    Where is the best place to put the BukkitScheduler or if it would cause to much lagg to check every few seconds and update Scoreboard what would you guys use?
     
  2. Offline

    Chinwe

    Put it in onEnable() to run from the start - once every few seconds shouldn't be too intensive, depending on what you do in it of course - looping through players, incrementing values and setting scoreboards (for example) would be fine to run every few seconds :)
     
    L33m4n123 likes this.
  3. Offline

    Tirelessly

    Here's an example of how to do that:
    Code:
    public void onEnable {
          task();
      }
     
    public void task {
        this.getServer().getScheduler().scheduleSyncRepeatingTask(this,new BukkitRunnable(){
          public void run(){
              //Do Stuff
          }
        }, 40L, 40L);
    }
    
    Note that this repeats itself every 2 seconds, as defined by the "40L" at the bottom. If you wanted a different amount of time, you should turn that into (seconds * 20).
     
    L33m4n123 likes this.
  4. Offline

    L33m4n123

Thread Status:
Not open for further replies.

Share This Page