Chapter 7. The Bukkit Event System
At this point, you know how to create a plugin that will run some code when a command is executed. This is very useful in many situations. However, we would rather not be required to type in a command sometimes. We'd prefer it if the code could be automatically triggered to be executed. The trigger could be a specific event that occurs on the server, such as a block being broken, a creeper exploding, or a player sending a message in a chat. The Bukkit event system allows a developer to listen for an event and automatically run a block of code based on that event. By using the Bukkit event system, you can automate your server, which means less work for you to maintain the server in the future. In this chapter, we'll cover the following topics:
- Choosing an event
- Registering an event listener
- Listening for an event
- Canceling an event
- Communicating between events
- Modifying an event as it occurs
- Creating more plugins on your own