Repeating task with scedular doesn't seem to trigger at all

Discussion in 'Spigot Plugin Development' started by MCrafterzz, Aug 5, 2018.

  1. I'm want to create a update methoud that triggers 1 time per second and this is how I do it:
    Code (Text):
    Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
                @Override
                public void run() {
                    System.out.println("TEST");
                    for (Player player : getServer().getOnlinePlayers()) {
                        player.sendMessage("Test");
                    }
                }
            }, 0, 20);
    Nothing is printed out and no errors are logged so I have no clue what's wrong.
     
  2. Does it even reach the scheduleSyncRepeatingTask method?
     
  3. How should I test that? I can't print anything out there.
     
  4. Surely if the line of code 'Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {' is getting reached, you can print something just before that line seeing if that part is being run?