Solved Repeating task won't stop

Discussion in 'Spigot Plugin Development' started by Maxiceks, Nov 10, 2019.

Thread Status:
Not open for further replies.
  1. Hello, I'm a something between amateur and beginner.

    My error is that my Repeating Task won't start
    Code (Java):
    package yt.mejx.threads;

    import org.bukkit.Bukkit;

    import yt.mejx.Main;
    import yt.mejx.handlers.Game;

    public class Odpocet {
        private static int cislo = 3; // zmenit na 61
        public static boolean hasStarted = false;

        public static void zacit() {
            Bukkit.getScheduler().scheduleSyncRepeatingTask(Main.pl, new Runnable() {

                @Override
                public void run() {
                    hasStarted = true;
                    if (cislo > 1) {
                        cislo--;
                        Bukkit.broadcastMessage("Hra zacina za ยง6" + cislo);
                    } else if (cislo == 1) {
                        Bukkit.getScheduler().cancelTasks(Main.pl);
    //                    Game.zacit();
                        Bukkit.broadcastMessage("Jsi dobry");
                    }
                }          
            },0L,20L);

        }

        public static int getCislo() {
            return cislo;
        }
    }
     
     
  2. Fixed it with replacing
    Bukkit.getScheduler().cancelTasks(Main.pl);
    to
    Bukkit.getScheduler().cancelTask(Main.pl);
     
Thread Status:
Not open for further replies.