Chapter 10. The Bukkit Scheduler
The Bukkit scheduler is a very powerful tool and using it is not too complicated to learn. It allows you to create repetitive tasks such as saving data. It also allows you to delay how long until a block of code executed. The Bukkit scheduler can also be used to compute lengthy tasks asynchronously. A task such as writing data to a file or downloading a file to the server can be scheduled to run on a separate thread to prevent the main thread, and thus the game, from lagging. In this chapter you will learn how to do these by continuing work on our teleportation plugin, Warper
, as well as creating a new plugin called
AlwaysDay
. This plugin will ensure that it is always daytime on the server by repeatedly setting the time to noon. This chapter will cover the following topics:
Creating a
BukkitRunnable
classSynchronous and asynchronous tasks and when each should be used
Running a task from a
BukkitRunnable
classScheduling a delayed task from a
BukkitRunnable
...