[Scheduler Programming] How to rerun task?

Discussion in 'Spigot Plugin Development' started by xXBeLkAXx, Jun 25, 2015.

  1. Hello, guys! At the moment I'm developing plugin what need the task, what will stop after some time and run again with new time. For example, I will show you the following code, you should understand me, but it's not working.
    Code (Text):
        private int time;
        private int i = 0;

        public void onEnable() {
            Bukkit.getPluginManager().registerEvents(this, this);
            time = 20;
            new BukkitRunnable() {
                public void run() {
                    if(i == 10) {
                        time += 20;
            }.runTaskTimer(this, 0, time);
  2. runTaskTimer() returns a BukkitTask object for later references.
  3. So, but it won't help me
  4. The BukkitTask object gives you the ability to keep track about your task that was scheduled before. So you can stop the task.
    After you have stopped the old task, you can give another task into order with a new time.
  5. I can't call run method from BukkitTask