Ewww... Cobble...
Warning
I am a professional programmer. This is what I do for a living, but I am not coding this for a living. I have been coding for a long time with at least some of that time writing Java professionally, but I am not very familiar with Bukkit so I cannot guarantee this project will be free of noob mistakes. I *CAN* guarantee that this code will be very clean and understandable... to me... I cannot assure anyone it will suit their needs unless those needs are exactly as described below. Finally this is a learning project for me and will be reflected in the way it is and will be coded. Things may not be done as efficiently as they might be if there is another way that exercises more of Bukkit. Some of the features may very likely make no sense at all, but will be written just to use some feature or other. Other features may be just some crazy thing I threw in because I was tired and suffered from poor judgement at the time.
A Plugin Is Born
As a professional computer programmer when I learn a new programming language or framework I like to create something along the lines of a traditional "Hello World" project. Simply saying "Hello World", however, would not get me familiar with much of the Bukkit framework at all. With that in mind I decided that instead of "Hello World" it should tell the world how I feel about cobblestone. And doing that when the mod loads would just be far too easy, so I decided to link it to a user actually using cobblestone. After that I decided I needed to find out about reading and writing configuration files so I made it so that it is configurable and pulls that configuration from a config.yml file like most plugins do. I'm also fairly anal-retentive about my code so I have documented the heck out of it.
Since the goal is to ultimately exercise as much of Bukkit as possible it might make a good reference for other people attempting to learn Bukkit. Ultimately I may even put out a tutorial that leads users through creating this mod and the thought that went into it.
Plugin Functionality
By default on a server with this plugin installed when a user places a cobblestone block the message "Ewww... Cobble..." will show up in their chat. In order to accomplish this the plugin listens to every player click. A quick check determines if they right clicked with a piece of cobble in their hand. If they did it sends that message to the chat window. There is another limitation here as well: If it has displayed the message in the past five minutes it does not send the message.
Plugin Configurability
- The behavior can be triggered by any one of the "Action" types listed here: http://jd.bukkit.org/apidocs/org/bukkit/event/block/Action.html
- The behavior can also be restricted to any block in the player's hand. Here is the list: http://jd.bukkit.org/apidocs/org/bukkit/Material.html
- The message to say can be set.
- The minimum amount of time between messages in milliseconds can be set.
- Whether to display the message in the player's chat or make the player say it can be set. If the plugin makes the player say it, if the message is a command it will be as if the player entered that command.