Interface GuiEventListener

All Known Implementing Classes:
GuiContext

public interface GuiEventListener
Represents a listener for GUI-related events. It provides a method to register a listener for a specific event class, and the associated event handler.

This class is licensed under the GNU General Public License. Created: 21.05.2023 Author: Tobias Madlberger (Tobias)

  • Method Summary

    Modifier and Type
    Method
    Description
    @NotNull GuiContext
    Gets the associated `GuiContext` for the listener.
    default <E extends GuiEngineEvent>
    void
    listen(@NotNull Class<E> clazz, @NotNull Consumer<E> listener)
    Registers a listener for a specific event class along with its associated event handler.
  • Method Details

    • getContext

      @NotNull @NotNull GuiContext getContext()
      Gets the associated `GuiContext` for the listener.
      Returns:
      The `GuiContext` associated with the listener.
    • listen

      default <E extends GuiEngineEvent> void listen(@NotNull @NotNull Class<E> clazz, @NotNull @NotNull Consumer<E> listener)
      Registers a listener for a specific event class along with its associated event handler. The `listener` parameter is a consumer that handles the event when it is triggered. The event will only be handled if the event class is assignable from the actual event's class, and if the context of the event matches the context associated with this `GuiEventListener`.
      Type Parameters:
      E - The type of the event.
      Parameters:
      clazz - The class of the event to listen for.
      listener - The event handler that consumes the event when triggered.