Interface GuiComponent

All Superinterfaces:
GuiEvents
All Known Implementing Classes:
AbstractGuiComponent, EmbeddedGuiComponent, PagedComponent, SimpleItemComponent, ToggleItemComponent

public interface GuiComponent extends GuiEvents
Represents a GUI component that can be rendered and interacted with in the graphical user interface. This interface extends the GuiEvents interface, providing methods for handling GUI events related to the component.

Created: 04/02/2023 Author: Tobias Madlberger (Tobias)

  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    addActions(@NotNull Set<io.github.toberocat.toberocore.action.Action> actions)
    Add actions to the GUI component.
    @NotNull String
    Get the ID of the GUI component.
    @NotNull String
    Get the type of the GUI component.
    int
    Get the height of the GUI component.
    boolean
    Check if the GUI component is hidden.
    default boolean
    isInComponent(int slot)
    Check if the provided slot is within the bounds of the GUI component.
    int
    Get the X offset of the GUI component.
    int
    Get the Y offset of the GUI component.
    void
    render(@NotNull org.bukkit.entity.Player viewer, @NotNull org.bukkit.inventory.ItemStack[][] inventory)
    Render the GUI component for a specific player and inventory configuration.
    Get the rendering priority of the GUI component.
    void
    serialize(@NotNull GeneratorContext gen, @NotNull com.fasterxml.jackson.databind.SerializerProvider serializers)
    Serialize the GUI component using the provided GeneratorContext and SerializerProvider.
    void
    setApi(@NotNull GuiEngineApi api)
    Set the GUI Engine API for the component.
    void
    setContext(@NotNull GuiContext context)
    Set the GUI context for the component.
    void
    setHidden(boolean hidden)
    Set the visibility of the GUI component.
    void
    setOffsetX(int x)
    Set the X offset of the GUI component.
    void
    setOffsetY(int y)
    Set the Y offset of the GUI component.
    int
    Get the width of the GUI component.

    Methods inherited from interface io.github.toberocat.guiengine.event.GuiEvents

    clickedComponent, closedComponent, draggedComponent, onViewInit
  • Method Details

    • getId

      @NotNull @NotNull String getId()
      Get the ID of the GUI component.
      Returns:
      The ID of the GUI component.
    • getType

      @NotNull @NotNull String getType()
      Get the type of the GUI component.
      Returns:
      The type of the GUI component.
    • renderPriority

      @NotNull @NotNull RenderPriority renderPriority()
      Get the rendering priority of the GUI component. The rendering priority determines the order in which the component is rendered relative to other components.
      Returns:
      The rendering priority of the GUI component.
    • hidden

      boolean hidden()
      Check if the GUI component is hidden.
      Returns:
      true if the component is hidden, false otherwise.
    • offsetX

      int offsetX()
      Get the X offset of the GUI component. The X offset represents the horizontal position of the component within the GUI layout.
      Returns:
      The X offset of the GUI component.
    • offsetY

      int offsetY()
      Get the Y offset of the GUI component. The Y offset represents the vertical position of the component within the GUI layout.
      Returns:
      The Y offset of the GUI component.
    • width

      int width()
      Get the width of the GUI component.
      Returns:
      The width of the GUI component.
    • height

      int height()
      Get the height of the GUI component.
      Returns:
      The height of the GUI component.
    • render

      void render(@NotNull @NotNull org.bukkit.entity.Player viewer, @NotNull @NotNull org.bukkit.inventory.ItemStack[][] inventory)
      Render the GUI component for a specific player and inventory configuration. This method is responsible for rendering the component to the graphical user interface.
      Parameters:
      viewer - The player for whom the component should be rendered.
      inventory - The inventory configuration used for rendering the GUI.
    • setApi

      void setApi(@NotNull @NotNull GuiEngineApi api)
      Set the GUI Engine API for the component.
      Parameters:
      api - The GuiEngineApi to set.
    • setContext

      void setContext(@NotNull @NotNull GuiContext context)
      Set the GUI context for the component.
      Parameters:
      context - The GuiContext to set.
    • setHidden

      void setHidden(boolean hidden)
      Set the visibility of the GUI component.
      Parameters:
      hidden - true to hide the component, false to make it visible.
    • setOffsetX

      void setOffsetX(int x)
      Set the X offset of the GUI component.
      Parameters:
      x - The X offset to set.
    • setOffsetY

      void setOffsetY(int y)
      Set the Y offset of the GUI component.
      Parameters:
      y - The Y offset to set.
    • serialize

      void serialize(@NotNull @NotNull GeneratorContext gen, @NotNull @NotNull com.fasterxml.jackson.databind.SerializerProvider serializers) throws IOException
      Serialize the GUI component using the provided GeneratorContext and SerializerProvider. This method is used to serialize the component's properties to a JSON representation.
      Parameters:
      gen - The GeneratorContext used for serialization.
      serializers - The SerializerProvider used for serialization.
      Throws:
      IOException - If there is an error during serialization.
    • addActions

      default void addActions(@NotNull @NotNull Set<io.github.toberocat.toberocore.action.Action> actions)
      Add actions to the GUI component. This method allows adding GUI actions that can be triggered by the player interacting with the component.
      Parameters:
      actions - A set of actions to be added to the component.
    • isInComponent

      default boolean isInComponent(int slot)
      Check if the provided slot is within the bounds of the GUI component. This method is used to determine if a player's interaction (e.g., clicking a slot) is within the component's area.
      Parameters:
      slot - The slot index to check.
      Returns:
      true if the slot is within the component's bounds, false otherwise.