Interface CustomListener

All Superinterfaces:
org.bukkit.event.Listener, Registrable

public interface CustomListener extends org.bukkit.event.Listener, Registrable
Represents a custom event listener with built-in registration management.

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 Classes
    Modifier and Type
    Interface
    Description
    static final class 
    A simple status holder for tracking the registration state of a CustomListener.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the current registration status of this listener.
    default boolean
    Checks whether this listener is registered.
    default boolean
    Registers this listener using the plugin that provides the CustomListener class.
    default boolean
    register(org.bukkit.plugin.Plugin plugin)
    Registers this listener with the specified plugin.
    default boolean
    Unregisters this listener from all event handlers.
  • Method Details

    • getStatus

      @NotNull @NotNull CustomListener.Status getStatus()
      Returns the current registration status of this listener.
      Returns:
      the CustomListener.Status object 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:
      isRegistered in interface Registrable
      Returns:
      true if the listener is currently registered, false otherwise.
    • 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 and false is returned. Upon successful registration, the internal status is updated.

      Parameters:
      plugin - the Plugin with which to register this listener.
      Returns:
      true if registration was successful, false otherwise.
    • register

      default boolean register()
      Registers this listener using the plugin that provides the CustomListener class.

      This is a convenience method that automatically fetches the providing plugin via JavaPlugin.getProvidingPlugin(Class).

      Specified by:
      register in interface Registrable
      Returns:
      true if registration was successful, false otherwise.
    • 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:
      unregister in interface Registrable
      Returns:
      true if unregistration was successful, false otherwise.