Solved Cancelling a BukkitRunnable class from another class

Discussion in 'Plugin Development' started by Maxx_Qc, Oct 24, 2015.

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


    Last edited: Oct 24, 2015
  2. Offline


    Store the new Runnable as a variable, then enact on it later?
  3. Offline


    public static int taskid = 1;
    taskid = Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable(){
    public void run{
    etc etc

    Anyways to cancel it from the DuelManager class you'd do Bukkit.getScheduler().cancelTask(StartRequestThread.taskid);
  4. Offline


    The taskId doesn't change for each time we call it?
    Because there could be multiple countdown running at the time

    How can I store it as a variable without puthing any argument?

    BukkitTask.cancel() with cancel every BukkitRunnable if I'm not wrong and this is not what I want.
    My case is the player send a request to player, after 30 sec if the target do not accept the request, this request will be
    expired. But, when the target accept the request, we need to stop the 30 sec's timer.

    I check my hashmap to see if it contains the player and if not, cancel the action.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Jul 23, 2018
  5. Offline


    When you create the task, store it as a variable somewhere
    BukkitTask taskInst = new BukkitRunnable()............

    Then you can use BukkitTask.cancel() later
  6. Offline


    You are wrong, it only cancels the task it refers to.
Thread Status:
Not open for further replies.

Share This Page