Registering an event listener

After deciding which event we will listen for, it is time to start programming. Create a new project, as described in Chapter 3, Creating Your First Bukkit Plugin, and call it NoRain. Don't forget to create a plugin.yml file as well.

In order to listen for an event, your plugin must have a class that is registered as a Listener class. We will only have one class, named NoRain.java, for this project. Therefore, we will make this a Listener class as well. The class declaration will look like the following line of code:

public class NoRain extends JavaPlugin implements Listener

Alternatively, if this is a large project, you can make a class for the Listener class, which is similar to how the Enchanter project had CommandExecutor ...

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.