If you use async scheduler, it can be done like this: Code (Java): Bukkit.getScheduler().scheduleAsyncRepeatingTask(Core.plugin, new Runnable() { public void run() { // some code new BukkitRunnable() { public void run() { // sendPluginMessage here } }.runTask(Core.plugin); } }, 0, 20);
What I should explain about this? It is two long vars - 1) delay before task start 2) delay between repeatings
@EnervateD code example about the }, 0, 20); at the end 0 = delay - the ticks to wait before running the task for the first time 20= period - the ticks to wait between runs
Didnt know you could have a runnable inside a runnable. How does th At even work, also I know that with async you need to do threading and I don't know how to do that.
what the BukkitScheduler has this method Code (Java): scheduleAsyncRepeatingTask(Plugin plugin, Runnable run, long delay, long period); what's the matter about runnable inside another runnable ?
There's not something wrong with a runnable inside a runnable, but you just created an async task to create a sync task to send a plugin message, that doesn't make sence to me.
well if you'd know how it works and what it says in spigot javadoc you'll know a reason that makes sense.
It says that you shouldn't use bukkit api in an async task. I know that, and it's because bukkit isn't thread-safe, but that doesn't mean that all methods aren't thread-safe, there are thread-safe methods, and then you can call it from async tasks. and as far as I know, plugin messaging is thread-safe, so then it's not that necessary, yes it's a bit less safe, because you need to know what methods are thread-safe but if it works in an async thread, then I think that not having to register another task is better, but it always depends on the programmer.