I can't cancel static scheduler

Discussion in 'Plugin Development' started by zlToxicNetherlz, Jul 16, 2015.

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

    zlToxicNetherlz

    Forgive my bad English
    No achievement cancel a task within a static method . Please help.

    Code:
    private static int c;
          
            public static void BoardLobby(final Player p) {
                c = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(a.plugin, new Runnable() {
                  public void run() {
                        if(ScoreboardBooleans.ON_LOBBY == "on") {
                                BoardLobbyUpdate(p);
                            }
                            else     {
                                a.plugin.getServer().getScheduler().cancelTask(c); // no cancel task
                                for(String p : list.ple) {
                                ScoreboardManager sbm = Bukkit.getScoreboardManager();
                                Bukkit.getPlayer(p).setScoreboard(sbm.getNewScoreboard());
                                }
                            }
                        }
                    }, (long) (20*0.8), (long) (20*0.8));
     
  2. Either create a method in the class to cancel the task or use a BukkitRunnable instead of the .getScheduler().schedule ... thing
     
  3. Offline

    mine-care

    What is line 6 supose to do? is it comparing two strings with == ?
    Keep in mind that object comparason with == is only gonna work safely for Singleton objects!
     
Thread Status:
Not open for further replies.

Share This Page