Writing a repeating task for a plugin

We already have a BukkitRunnable class. Therefore, in order to run a task timer, we just need to determine the delay and the period by which the task is delayed. We want the delay to be 0. That way, if it is night when the plugin is enabled, the time will be set to noon right away. As for the period, we can repeat the task every second if we want to keep the sun always directly above. The task only contains one simple line of code. Repeating it often will not cause the server to lag. However, repeating the task every minute will still prevent the world from ever growing dark and will be less of a strain on the computer. Therefore, we will delay the task by 0 ticks and repeat it every 1,200 ticks. This results ...

Get Building Minecraft Server Modifications - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.