Cancelling A Task..

Discussion in 'Plugin Development' started by lx3krypticx, Sep 27, 2012.

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

    lx3krypticx

    Hey guys. I'm trying to cancel a specific task. Here is my problem.

    I have this repeating task.

    Code:
          public void countdown(){
            if(this.started == true){
                return;
            }
            this.started = true;
            final int Bla = Bukkit.getScheduler().scheduleAsyncRepeatingTask(this, new Runnable() 
            {
            
                @Override
                public void run() {
                    
                    if(startedofficial == true){
                        return;
                    }
                    
                    if(started == true){
                        
                        if(time == 0){
                                if(mode == "kits"){
                                    kits();
                                }
                                if(mode == "normal"){
                                    normal();
                                }
                                time = 0;
                            return;
                        }
                        
                        Bukkit.broadcastMessage(ChatColor.AQUA + "" + time + " Seconds Remaining To Reveal The Choice Of Game!");
                        
                        time --;
                        
                        
                    }
                    
                }
            }, 0L, 20L);
        }
    
    How would I cancel it in a constructor

    Code:
        public void kits(){
            this.startedofficial = true;
            Bukkit.broadcastMessage(ChatColor.RED + "We Are Playing A Kits Game!");
        }
     
  2. Offline

    gregthegeek

    You would have to store that new Runnable() somewhere it can be accessed by that constructor before starting it.
     
  3. Offline

    lx3krypticx

    Wait so put int Bla = Bukkit.getScheduler().scheduleAsyncRepeatingTask(this, new Runnable() ); somewhere? I'm confused ;O

    NVM figured it out.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 28, 2016
Thread Status:
Not open for further replies.

Share This Page