Class StarEvents

java.lang.Object
com.stardevllc.starevents.StarEvents

public final class StarEvents extends Object
Main class for StarEvents
  • Field Details

    • BUS

      public static final com.stardevllc.starlib.eventbus.IEventBus<org.bukkit.event.Event,org.bukkit.event.Cancellable> BUS
      The event bus used for passing Bukkit Events into
  • Method Details

    • registerListener

      public static void registerListener(Object listener)
      Registers a listener to the event bus. This must follow the rules of StarEventBus
      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 class
      listener - The listener
    • unregisterListener

      public static void unregisterListener(EventListener<?> listener)
      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 located
      listenerClassName - The name of the class that is generated
      eventClasses - 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 search
      classLoader - The classloader for the jar file
      Returns:
      The event classes in the jar that have a static getHandlerList and not deprecated
    • addEventListener

      public static StarEvents.Status addEventListener(BukkitEventListener listener)
      Adds an event listener that listents for Event's to then pass to the IEventBus
      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

      public static List<BukkitEventListener> getSuccesfulListeners()
      Returns a copy of the successful listeners
      Returns:
      The successful listeners
    • getFailedListeners

      public static Map<BukkitEventListener,Throwable> 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,Method>> getEventsTracked()
      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