package org.bukkit.event; import org.bukkit.plugin.PluginManager; /** * Represents an event. * * All events require a static method named getHandlerList() which returns the same {@link HandlerList} as {@link #getHandlers()}. * * @see PluginManager#callEvent(Event) * @see PluginManager#registerEvents(Listener,Plugin) */ public abstract class Event { private String name; private final boolean async; /** * The default constructor is defined for cleaner code. This constructor * assumes the event is synchronous. */ public Event() { this(false); } /** * This constructor is used to explicitly declare an event as synchronous * or asynchronous. * * @param isAsync true indicates the event will fire asynchronously, false * by default from default constructor */ public Event(boolean isAsync) { this.async = isAsync; } /** * Convenience method for providing a user-friendly identifier. By * default, it is the event's class's {@linkplain Class#getSimpleName() * simple name}. * * @return name of this event */ public String getEventName() { if (name == null) { name = getClass().getSimpleName(); } return name; } public abstract HandlerList getHandlers(); /** * Any custom event that should not by synchronized with other events must * use the specific constructor. These are the caveats of using an * asynchronous event: *