Solved Cannot Schedule an Object that Extends BukkitRunnable a Second Time after Canceling

Discussion in 'Bukkit Help' started by qsik, Jul 27, 2014.

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

    qsik

    So it seems that I can't schedule an object that extends bukkitrunnable again even though the first scheduled instance is canceled.
    for example, the following code is executed when the Player right clicks
    Code:
    try {
        blizzard.cancel();
    }
    finally {
        blizzard.runTaskTimer(Main.plugin, 0, 1);
    }
    Where blizzard is an object that extends BukkitRunnable
    The first time runs just fine but never runs again no matter how many times I right click. What am I doing wrong?

    Running on Windows 8 64 bit, using Bukkit & Craftbukkit 1.7.10 R0.1 and running Java 7

    Got the answer. Looks like BukkitRunnable doesn't reset the task ID to -1 after the cancel() is called.

    *Answer from Stack Overflow

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  2. Offline

    Deleted user

    qsik
    Try using Bukkit.getScheduler() and running some task and supplying the runnable. That allows for multiple usages.
     
Thread Status:
Not open for further replies.

Share This Page