how can i cancel/stop the bukkit runnable

Discussion in 'Plugin Development' started by BasimTM, Nov 20, 2020.

  1. Offline


    hello i've been trying for 2 days i tried and searched in every website
    please someone tell me how can i stop this bukkit runnable task
    why the cancel(): not working
    public class stest extends JavaPlugin {
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            Player player = (Player) sender;
            new BukkitRunnable() {
            public void run() {
                if (cmd.getName().equalsIgnoreCase("Srun")) {
                    for(Player online : Bukkit.getOnlinePlayers()) {
                if (cmd.getName().equalsIgnoreCase("Sstop")) {
        }.runTaskTimer(this, 60, 60);
        return true;
  2. Offline


    @BasimTM cancel isn't working (in your case) because you aren't calling it on the first runnable that you schedule the first time. You are canceling a second one.
    To cancel the first one, you must somehow keep track of the first runnable and cancel that.

Share This Page