Tutorial by Examples

The time for Scheduler Tasks are measured in Ticks. Under normal conditions, there are 20 ticks per second. Tasks scheduled with .scheduleSyncRepeatingTask will be run on the Main Thread Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() { @Override public void run(...
The time for Scheduler Tasks are measured in Ticks. Under normal conditions, there are 20 ticks per second. Tasks scheduled with .scheduleSyncDelayedTask will be run on the Main Thread Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { ...
You can make code run asynchronously from the main thread using runTaskAsynchronously. This is useful for doing intensive math or database operations, as they will prevent the main thread from freezing (and the server from lagging). Few Bukkit API methods are thread-safe, so many will cause undefin...
You can also make code run synchronously with the main thread using runTask. This is useful when you want to call Bukkit API methods after running code asynchronously from the main thread. Code called inside of this Runnable will be executed on the main thread, making it safe to call Bukkit API met...
The BukkitRunnable is a Runnable found in Bukkit. It's possible to schedule a task directly from a BukkitRunnable, and also cancel it from inside itself. Important: The time on the tasks is measured in Ticks. A second has 20 ticks. Non-RepeatingTask: JavaPlugin plugin; //Your plugin instance ...
Sometimes you'll need to execute synchronous code from within an asynchronous task. To do this, simply schedule a synchronous task from within the asynchronous block. Bukkit.getScheduler().runTaskTimerAsynchronously(VoidFlame.getPlugin(), () -> { Bukkit.getScheduler().runTask(VoidFlame.ge...

Page 1 of 1