https://pastebin.com/xsSPMxEW That is the post. Can anyone help me? A little bit of code would be very appreciated.
To cancel it inside itself you need to use the BukkitRunnable. Otherwise you have to store the Scheduler Process ID in an Integer and cancel it by calling Bukkit.getScheduler().cancel(pScheduler);
Try it without the scheduler like this: Code (Java): new BukkitRunnable(){ @Override public void run() { Bukkit.getConsoleSender().sendMessage(" running"); cancel(); } }.runTaskTimerAsynchronously(plugin, 20, 20);
First off that method is deprecated use this https://hub.spigotmc.org/javadocs/spigot/org/bukkit/scheduler/BukkitRunnable.html#runTaskTimer(org.bukkit.plugin.Plugin, long, long) Second thing it clearly states Asynchronous tasks should never access any API in Bukkit. Great care should be taken to assure the thread-safety of asynchronous tasks. And there you are using Bukkit.broascastMessage. Use the link for the right thing
When it comes to broadcasting a message, thread safety is not of concern. The only real concerns is when you start interacting with entities and components regarding the world. As long as you're not modifying anything asynchronously, you're fine. Broadcasting a message is simply sending a packet. No biggy