Interface CustomListener
- All Superinterfaces:
org.bukkit.event.Listener,Registrable
This interface extends both the standard Bukkit Listener and the Registrable interface,
providing a convenient way to register and unregister event listeners in a Bukkit/Spigot plugin.
It also maintains an internal Status to keep track of the registration state.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final classA simple status holder for tracking the registration state of aCustomListener. -
Method Summary
Modifier and TypeMethodDescription@NotNull CustomListener.StatusReturns the current registration status of this listener.default booleanChecks whether this listener is registered.default booleanregister()Registers this listener using the plugin that provides theCustomListenerclass.default booleanregister(org.bukkit.plugin.Plugin plugin) Registers this listener with the specified plugin.default booleanUnregisters this listener from all event handlers.
-
Method Details
-
getStatus
Returns the current registration status of this listener.- Returns:
- the
CustomListener.Statusobject representing whether this listener is registered.
-
isRegistered
default boolean isRegistered()Checks whether this listener is registered.This is a convenience method inherited from
Registrable.- Specified by:
isRegisteredin interfaceRegistrable- Returns:
trueif the listener is currently registered,falseotherwise.
-
register
default boolean register(org.bukkit.plugin.Plugin plugin) Registers this listener with the specified plugin.If the listener is already registered or the plugin is
null, the registration will not occur andfalseis returned. Upon successful registration, the internal status is updated.- Parameters:
plugin- thePluginwith which to register this listener.- Returns:
trueif registration was successful,falseotherwise.
-
register
default boolean register()Registers this listener using the plugin that provides theCustomListenerclass.This is a convenience method that automatically fetches the providing plugin via
JavaPlugin.getProvidingPlugin(Class).- Specified by:
registerin interfaceRegistrable- Returns:
trueif registration was successful,falseotherwise.
-
unregister
default boolean unregister()Unregisters this listener from all event handlers.If the listener is not registered, no action is taken. Upon successful unregistration, the internal status is updated.
- Specified by:
unregisterin interfaceRegistrable- Returns:
trueif unregistration was successful,falseotherwise.
-