This is an example plugin I wrote, feel free to use it however you wish, for a tutorial on how to install and configure the plugin to work on a minecraft server, excludeing placeing it in your minecraft server and error checking see here
Also, you can download the entire source here