Class EnchantmentEventBusImpl
java.lang.Object
io.artificial.enchantments.internal.EnchantmentEventBusImpl
- All Implemented Interfaces:
EnchantmentEventBus
Implementation of
EnchantmentEventBus.
Provides thread-safe subscription management using ConcurrentHashMap
and CopyOnWriteArrayList. Subscriptions are sorted by EventPriority
ordinal during dispatch.
- Since:
- 0.2.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.artificial.enchantments.api.EnchantmentEventBus
EnchantmentEventBus.EventSubscription<T extends EnchantEffectEvent> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T extends EnchantEffectEvent>
TDispatches an event created by a factory function.<T extends EnchantEffectEvent>
Tdispatch(T event) Dispatches an event to all registered handlers.<T extends EnchantEffectEvent>
@NotNull EnchantmentEventBus.EventSubscription<T> register(@NotNull org.bukkit.plugin.Plugin plugin, @NotNull Class<T> eventType, @NotNull Consumer<T> handler) Registers a simple event handler with default priority and cancellation handling.<T extends EnchantEffectEvent>
@NotNull EnchantmentEventBus.EventSubscription<T> register(@NotNull org.bukkit.plugin.Plugin plugin, @NotNull Class<T> eventType, @NotNull org.bukkit.event.EventPriority priority, boolean ignoreCancelled, @NotNull Consumer<T> handler) Registers an event handler with full control over priority and cancellation.<T extends EnchantEffectEvent>
@NotNull EnchantmentEventBus.EventSubscription<T> register(@NotNull org.bukkit.plugin.Plugin plugin, @NotNull Class<T> eventType, @NotNull org.bukkit.event.EventPriority priority, @NotNull Consumer<T> handler) Registers an event handler with specific priority.<T extends EnchantEffectEvent>
voidunregister(@NotNull EnchantmentEventBus.EventSubscription<T> subscription) Unregisters a specific subscription.voidunregisterAll(@NotNull org.bukkit.plugin.Plugin plugin) Unregisters all handlers for a plugin.
-
Constructor Details
-
EnchantmentEventBusImpl
public EnchantmentEventBusImpl()Creates a new enchantment event bus.- Since:
- 0.2.0
-
-
Method Details
-
register
@NotNull public <T extends EnchantEffectEvent> @NotNull EnchantmentEventBus.EventSubscription<T> register(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull Class<T> eventType, @NotNull @NotNull Consumer<T> handler) Description copied from interface:EnchantmentEventBusRegisters a simple event handler with default priority and cancellation handling.- Specified by:
registerin interfaceEnchantmentEventBus- Type Parameters:
T- the event type- Parameters:
plugin- the plugin registering the handler (must not be null)eventType- the event class to listen for (must not be null)handler- the handler to invoke (must not be null)- Returns:
- a subscription object for later unsubscription
-
register
@NotNull public <T extends EnchantEffectEvent> @NotNull EnchantmentEventBus.EventSubscription<T> register(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull Class<T> eventType, @NotNull @NotNull org.bukkit.event.EventPriority priority, @NotNull @NotNull Consumer<T> handler) Description copied from interface:EnchantmentEventBusRegisters an event handler with specific priority.- Specified by:
registerin interfaceEnchantmentEventBus- Type Parameters:
T- the event type- Parameters:
plugin- the plugin registering the handler (must not be null)eventType- the event class to listen for (must not be null)priority- the Bukkit event priority (must not be null)handler- the handler to invoke (must not be null)- Returns:
- a subscription object for later unsubscription
-
register
@NotNull public <T extends EnchantEffectEvent> @NotNull EnchantmentEventBus.EventSubscription<T> register(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull Class<T> eventType, @NotNull @NotNull org.bukkit.event.EventPriority priority, boolean ignoreCancelled, @NotNull @NotNull Consumer<T> handler) Description copied from interface:EnchantmentEventBusRegisters an event handler with full control over priority and cancellation.- Specified by:
registerin interfaceEnchantmentEventBus- Type Parameters:
T- the event type- Parameters:
plugin- the plugin registering the handler (must not be null)eventType- the event class to listen for (must not be null)priority- the Bukkit event priority (must not be null)ignoreCancelled- if true, handler won't fire for cancelled eventshandler- the handler to invoke (must not be null)- Returns:
- a subscription object for later unsubscription
-
unregisterAll
public void unregisterAll(@NotNull @NotNull org.bukkit.plugin.Plugin plugin) Description copied from interface:EnchantmentEventBusUnregisters all handlers for a plugin.- Specified by:
unregisterAllin interfaceEnchantmentEventBus- Parameters:
plugin- the plugin to unregister (must not be null)
-
unregister
public <T extends EnchantEffectEvent> void unregister(@NotNull @NotNull EnchantmentEventBus.EventSubscription<T> subscription) Description copied from interface:EnchantmentEventBusUnregisters a specific subscription.- Specified by:
unregisterin interfaceEnchantmentEventBus- Type Parameters:
T- the event type- Parameters:
subscription- the subscription to cancel (must not be null)
-
dispatch
Description copied from interface:EnchantmentEventBusDispatches an event to all registered handlers.Typically called internally by the library. Plugins can use this for testing or custom event scenarios.
- Specified by:
dispatchin interfaceEnchantmentEventBus- Type Parameters:
T- the event type- Parameters:
event- the event to dispatch (must not be null)- Returns:
- the dispatched event (may be modified by handlers)
-
dispatch
@NotNull public <T extends EnchantEffectEvent> T dispatch(@NotNull @NotNull Class<T> type, @NotNull Supplier<T> factory) Description copied from interface:EnchantmentEventBusDispatches an event created by a factory function.Convenience method that creates and dispatches in one call.
- Specified by:
dispatchin interfaceEnchantmentEventBus- Type Parameters:
T- the event type- Parameters:
type- the event class (must not be null)factory- the factory to create the event (must not be null)- Returns:
- the dispatched event
-