We will start by creating the AlwaysDay
plugin. The code that we will write for this plugin will be put inside the onEnable
method. The first step to creating a scheduled task is to create a BukkitRunnable
class. This class will comprise very few lines of code. Therefore, it is not necessary to create a whole new Java file for it. For this reason, we will create a class within the onEnable
method. This can be done using the following line of code:
BukkitRunnable runnable = new BukkitRunnable();
Normally, this code would be valid since you are constructing a new instance of a class. However, BukkitRunnable
is an abstract class, which means that it cannot be instantiated. The purpose of an abstract class is to provide some base code that other classes can extend and build on top of. An example of this is the JavaPlugin
class. For each plugin that you created, you started with a class that extends JavaPlugin
. This allows you to override methods, such as onEnable...