Package com.stardevllc.starevents
Class StarEvents
java.lang.Object
com.stardevllc.starevents.StarEvents
Main class for StarEvents
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.stardevllc.starlib.eventbus.IEventBus<org.bukkit.event.Event, org.bukkit.event.Cancellable> The event bus used for passing Bukkit Events into -
Method Summary
Modifier and TypeMethodDescriptionstatic StarEvents.StatusaddEventListener(BukkitEventListener listener) Adds an event listener that listents forEvent's to then pass to theIEventBusstatic voidaddFromPlugin(org.bukkit.plugin.Plugin p) Creates and adds a generated event listener from a pluginstatic BukkitEventListenercreateListener(URLClassLoader classLoader, String listenerClassName, Collection<Class<? extends org.bukkit.event.Event>> eventClasses) Creates a listener that is generated dynamicallystatic Collection<Class<? extends org.bukkit.event.Event>> getEventClassesFromJar(File jarFile, ClassLoader classLoader) Finds and returns all event classes from a Jar File that have a static getHandlerList and no deprecated
This is the same rules for registering an event listener to Bukkitstatic Map<Class<? extends org.bukkit.event.Event>, com.stardevllc.starlib.helper.Pair<Object, Method>> Returns a copy of the map of the events tracked by StarEvents
The Key is the event class
The value is a pair with the first value being the listener instance, and the second value being the method of the listenerstatic Map<BukkitEventListener, Throwable> Returns a copy of the failed listeners.static org.bukkit.plugin.java.JavaPluginReturns the plugin that initalized StarEventsstatic List<BukkitEventListener> Returns a copy of the successful listenersstatic voidinit(org.bukkit.plugin.java.JavaPlugin plugin) Initalizes StarEvents.static <E extends org.bukkit.event.Event>
voidregisterListener(Class<E> eventType, EventListener<E> listener) Registers a listener to the event busstatic voidregisterListener(Object listener) Registers a listener to the event bus.static voidunregisterListener(EventListener<?> listener) Unregisters an event listener
-
Field Details
-
BUS
public static final com.stardevllc.starlib.eventbus.IEventBus<org.bukkit.event.Event,org.bukkit.event.Cancellable> BUSThe event bus used for passing Bukkit Events into
-
-
Method Details
-
registerListener
Registers a listener to the event bus. This must follow the rules ofStarEventBus- Parameters:
listener- The listener to register
-
registerListener
public static <E extends org.bukkit.event.Event> void registerListener(Class<E> eventType, EventListener<E> listener) Registers a listener to the event bus- Type Parameters:
E- The event type- Parameters:
eventType- The event classlistener- The listener
-
unregisterListener
Unregisters an event listener- Parameters:
listener- The listener to unregister
-
init
public static void init(org.bukkit.plugin.java.JavaPlugin plugin) Initalizes StarEvents. This can only be called once as long as the plugin is not null- Parameters:
plugin- The plugin that holds StarEvents
-
addFromPlugin
public static void addFromPlugin(org.bukkit.plugin.Plugin p) Creates and adds a generated event listener from a plugin- Parameters:
p- The plugin
-
createListener
public static BukkitEventListener createListener(URLClassLoader classLoader, String listenerClassName, Collection<Class<? extends org.bukkit.event.Event>> eventClasses) Creates a listener that is generated dynamically- Parameters:
classLoader- The classloader where the events are locatedlistenerClassName- The name of the class that is generatedeventClasses- The Event classes themselves. These must be normally registerable in the plugin manager- Returns:
- The created event listener instance
-
getEventClassesFromJar
public static Collection<Class<? extends org.bukkit.event.Event>> getEventClassesFromJar(File jarFile, ClassLoader classLoader) Finds and returns all event classes from a Jar File that have a static getHandlerList and no deprecated
This is the same rules for registering an event listener to Bukkit- Parameters:
jarFile- The jar file to searchclassLoader- The classloader for the jar file- Returns:
- The event classes in the jar that have a static getHandlerList and not deprecated
-
addEventListener
Adds an event listener that listents forEvent's to then pass to theIEventBus- Parameters:
listener- The listener to register- Returns:
- The status of the listener registration
-
getPlugin
public static org.bukkit.plugin.java.JavaPlugin getPlugin()Returns the plugin that initalized StarEvents- Returns:
- The plugin instance
-
getSuccesfulListeners
Returns a copy of the successful listeners- Returns:
- The successful listeners
-
getFailedListeners
Returns a copy of the failed listeners.
The key is the listener instance that failed
The value is the throwable instance that caused the listener to fail- Returns:
- A copy of the map of failed listeners
-
getEventsTracked
public static Map<Class<? extends org.bukkit.event.Event>,com.stardevllc.starlib.helper.Pair<Object, getEventsTracked()Method>> Returns a copy of the map of the events tracked by StarEvents
The Key is the event class
The value is a pair with the first value being the listener instance, and the second value being the method of the listener- Returns:
- A copy of the mapping of events
-