vexsoftware/votifier — pull request #12 by javacraft (2012-06-02 07:06:15+00:00)
Title: Added custom Bukkit event capability, debug mode, and additional diagnostic messages.

Greetings:

As promised, I rewrote some of the error handling code to provide better diagnostic messages. It isn't 100%, but it should ameliorate the number of support requests from users on Votifier and/or Votifier listener developers. Then again, that assumes that users will actually read log entries.

More importantly, I added the ability for Votifier to generate a custom Bukkit event (VotifierEvent), which allows other plugins to receive vote notifications. This is a feature I have been hungering for several months. Below are more specific details about changes to classes.

Please note that I segregate these changes in the update_1.8 branch so that you can fold them in, test them yourselves, if needed. If everything is to your liking, merge it into the master branch.

#### Votifier
* Split try/catch blocks to generate more specific errors pointing to the problem. While information could be gleaned from a stack trace, it doesn’t hurt pointing users in the right direction.

* Consolidated logging and added logging convenience methods to provide a single interface and plugin-specific adornments (e.g. log prefix). The log prefix – [Votifier] – should greatly reduce the number of pilot error messages posed to listener developers.

* Added debug configuration option.

* New configuration file will attempt to use IP address set in server.properties as the host. If none is specified, it reverts back to 0.0.0.0. This change should eliminate some of the headaches encountered with hosting services.

* New configuration file will warn user to verify that the default port (8192) is available for their use.

* Added graceful exit message should Votifier not initialize properly rather than exiting silently or just with a stack trace.

#### ListenerLoader

* Moved exception handling back into ListenerLoader. Failure to create a valid class loader will return an empty listener list. Better to run in an announced degraded state than not at all. Failure to load a listener class will continue to load other valid listeners.

#### VoteReceiver

* Moved socket bind to constructor. Any errors during binding should be caught as early as possible. Should an exception occur, notice is given and exception is recast to allow Votifier to exit gracefully.

* Listener exceptions are identified by listeners simple class names to help users focus on what listener might be broken. As before, its in the stack trace; just pointing them in the right direction.

* During debug mode, VoteReceiver will log vote record contents. This should be very helpful for users to determine if their toplist configuration is correct. This feature should be expanded upon in the troubleshooting section, such as – turn debug on, send test notification, if toplist reports success and no vote record is dumped, its being received by another plugin.

* Generates a custom VotifierEvent synchronized to the main server thread for other plugins to intercept. This feature is a must have as it allows the development of feature-rich plugin “listeners” that do more than just rewarding players. Furthermore, it allows existing plugins to add vote-based features.

* Binding error message specifically instructs user to verify their IP address/port configuration.

* BadPaddingException is caught separately, and instructs users to verify their public keys. A very common error that just needed a little more prodding.