To call a custom event with Bukkit's event handler, I assume that each unique event will need to have it's own object that extends the generic org.java.bukkit.event, right? I assume we also will need a CustomEventListener of some kind to pick up the event. Then to call that custom event, do we just use getServer().getPluginManager().callEvent(ourEventObject)? An example of a simple custom event would be awesome.
There is a CustomEventListener.java file. Code: package org.bukkit.event; public interface CustomEventListener { public void onCustomEvent(Event event); } It seems like all custom events will go through the same listener though, which is maybe not the most efficient. The register function takes: public void registerEvent(Event.Type type, Listener listener, Priority priority, Plugin plugin); so, it doesn't seem to allow registering just a specific names hook. (I could also insert a question about thread safety here )
So if it is a custom event.. what triggers it? As least with OnPlayerChat() etc we have an idea of how and when to register it; and from reading the docs I'm under the possibly incorrect assumption that the custom event is never actualy triggered as the docs don't tell you what this event does. This leads to the idea that if this event is triggered by the game, that it need to be re-factored so the events are more clearly defined. Or just defined better so we know when to use it.
A custom event is triggered by a plugin. It allows a plugin to inform other plugins (or parts of the same plugin) something has happened.
Custom Event is more generic, I don't see a problem with it. Anyway, custom events are named by an internal string parameter when creating the event object, so you can tell your custom event apart from others.
True, but you still get notified of all of them. They could use a HashMap to map the custom strings to a list of plugins registered on that event.
I'm trying to catch a custom event now, and I get nothing. I've even recompiled the plugin calling callEvent() to log right before it calls it, so I know execution is making it to callEvent() (the plugin is HeroChat). I can't seem to trap it on the backend though. Is there something special that needs to be done? I can post code if you like. SOLVED: Eclipse problems again, grr