Bukkit/Bukkit — pull request #383 by zml2008 (2011-10-14 04:15:56+00:00)
Title: Events Refactor

This pull request makes event registration and handling faster and more flexible for plugin developers writing plugins and adding custom events. Events are registered in a class implementing Listener with methods that have an EventHandler annotation, which is then registered with the plugin manager through getServer().getPluginManager().registerEvents(Listener, Plugin). An example of a listener class is available at https://gist.github.com/1280163 (from WorldEdit). This method is inspired by the event registration in @sk89q's server plugin. The other major change in this pull request is faster event handling. HashMap lookups are eliminated when calling events, being replaced with per-event HandlerLists and getters. I've gotten over 10 million events processed per second with this system. This change is the only change that immediately breaks plugins. Any plugin that has custom events will have to add a few lines to their custom events to make them work with the fastevents system.

private static final HandlerList handlers = new HandlerList();
public HandlerList getHandlers() { return handlers; }
public static HandlerList getHandlerList() { return handlers; }

Otherwise, events and plugins should continue to work as they did previously in non-updated plugins until the clases and methods I deprecated are removed.