Class EventBus
java.lang.Object
com.github.darksoulq.abyssallib.server.event.EventBus
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
ConstructorsConstructorDescriptionEventBus(org.bukkit.plugin.Plugin plugin) Constructs a new EventBus for the given plugin. -
Method Summary
-
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
Registers an object with the event bus. All methods annotated withSubscribeEventwill be scanned and registered with Bukkit if they accept a singleEventparameter.- 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.
-