Interface GuiComponent
- All Superinterfaces:
GuiEvents
- All Known Implementing Classes:
AbstractGuiComponent,EmbeddedGuiComponent,PagedComponent,SimpleItemComponent,ToggleItemComponent
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 TypeMethodDescriptiondefault voidaddActions(@NotNull Set<io.github.toberocat.toberocore.action.Action> actions) Add actions to the GUI component.@NotNull StringgetId()Get the ID of the GUI component.@NotNull StringgetType()Get the type of the GUI component.intheight()Get the height of the GUI component.booleanhidden()Check if the GUI component is hidden.default booleanisInComponent(int slot) Check if the provided slot is within the bounds of the GUI component.intoffsetX()Get the X offset of the GUI component.intoffsetY()Get the Y offset of the GUI component.voidrender(@NotNull org.bukkit.entity.Player viewer, @NotNull org.bukkit.inventory.ItemStack[][] inventory) Render the GUI component for a specific player and inventory configuration.@NotNull RenderPriorityGet the rendering priority of the GUI component.voidserialize(@NotNull GeneratorContext gen, @NotNull com.fasterxml.jackson.databind.SerializerProvider serializers) Serialize the GUI component using the provided GeneratorContext and SerializerProvider.voidsetApi(@NotNull GuiEngineApi api) Set the GUI Engine API for the component.voidsetContext(@NotNull GuiContext context) Set the GUI context for the component.voidsetHidden(boolean hidden) Set the visibility of the GUI component.voidsetOffsetX(int x) Set the X offset of the GUI component.voidsetOffsetY(int y) Set the Y offset of the GUI component.intwidth()Get the width of the GUI component.Methods inherited from interface io.github.toberocat.guiengine.event.GuiEvents
clickedComponent, closedComponent, draggedComponent, onViewInit
-
Method Details
-
getId
Get the ID of the GUI component.- Returns:
- The ID of the GUI component.
-
getType
Get the type of the GUI component.- Returns:
- The type of the GUI component.
-
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.
-
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
Set the GUI Engine API for the component.- Parameters:
api- The GuiEngineApi to set.
-
setContext
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.
-