Class EventBus

java.lang.Object
com.github.darksoulq.abyssallib.server.event.EventBus

public class EventBus extends Object
A lightweight event bus for registering Bukkit event handlers using the SubscribeEvent format.

This class scans listener objects for annotated methods and registers them with Bukkit's event system. It uses MethodHandle for fast invocation and supports event priority and cancel-ignoring behavior.

  • Constructor Summary

    Constructors
    Constructor
    Description
    EventBus(org.bukkit.plugin.Plugin plugin)
    Constructs a new EventBus for the given plugin.
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T extends org.bukkit.event.Event>
    T
    post(T event)
    Posts a Bukkit event to all registered listeners.
    void
    register(Object listenerObject)
    Registers an object with the event bus.

    Methods inherited from class Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • EventBus

      public EventBus(org.bukkit.plugin.Plugin plugin)
      Constructs a new EventBus for the given plugin.
      Parameters:
      plugin - The plugin that owns this event bus and will be used as the event listener owner.
  • Method Details

    • register

      public void register(Object listenerObject)
      Registers an object with the event bus. All methods annotated with SubscribeEvent will be scanned and registered with Bukkit if they accept a single Event parameter.
      Parameters:
      listenerObject - The object containing annotated event handler methods.
      Throws:
      IllegalArgumentException - if any annotated method is invalid (e.g., wrong parameter count or type).
    • post

      public static <T extends org.bukkit.event.Event> T post(T event)
      Posts a Bukkit event to all registered listeners.
      Type Parameters:
      T - The type of event being posted.
      Parameters:
      event - The event to post.
      Returns:
      The same event instance after it has been processed by all listeners.