Class SimpleItemComponent
java.lang.Object
io.github.toberocat.guiengine.components.AbstractGuiComponent
io.github.toberocat.guiengine.components.provided.item.SimpleItemComponent
- All Implemented Interfaces:
GuiComponent
,GuiEvents
A GUI component representing a simple item in the GUI.
This component displays a single item at a specific position in the GUI.
Created: 04/02/2023
Author: Tobias Madlberger (Tobias)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final @NotNull org.bukkit.inventory.ItemStack
static final @NotNull String
Fields inherited from class io.github.toberocat.guiengine.components.AbstractGuiComponent
api, clickFunctions, closeFunctions, context, dragFunctions, height, id, offsetX, offsetY, priority, width
-
Constructor Summary
ConstructorsConstructorDescriptionSimpleItemComponent
(int offsetX, int offsetY, @NotNull RenderPriority priority, @NotNull String id, @NotNull List<GuiFunction> clickFunctions, @NotNull List<GuiFunction> dragFunctions, @NotNull List<GuiFunction> closeFunctions, @NotNull org.bukkit.inventory.ItemStack stack, boolean hidden) Constructor for SimpleItemComponent. -
Method Summary
Modifier and TypeMethodDescription@NotNull String
getType()
Get the type 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.void
serialize
(@NotNull GeneratorContext gen, @NotNull com.fasterxml.jackson.databind.SerializerProvider serializers) Serialize the GUI component using the provided GeneratorContext and SerializerProvider.Methods inherited from class io.github.toberocat.guiengine.components.AbstractGuiComponent
clickedComponent, closedComponent, draggedComponent, getClickFunctions, getCloseFunctions, getDragFunctions, getId, height, hidden, offsetX, offsetY, renderPriority, setApi, setContext, setHidden, setOffsetX, setOffsetY, width
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.github.toberocat.guiengine.components.GuiComponent
addActions, isInComponent
Methods inherited from interface io.github.toberocat.guiengine.event.GuiEvents
onViewInit
-
Field Details
-
TYPE
- See Also:
-
stack
@NotNull protected final @NotNull org.bukkit.inventory.ItemStack stack
-
-
Constructor Details
-
SimpleItemComponent
public SimpleItemComponent(int offsetX, int offsetY, @NotNull @NotNull RenderPriority priority, @NotNull @NotNull String id, @NotNull @NotNull List<GuiFunction> clickFunctions, @NotNull @NotNull List<GuiFunction> dragFunctions, @NotNull @NotNull List<GuiFunction> closeFunctions, @NotNull @NotNull org.bukkit.inventory.ItemStack stack, boolean hidden) Constructor for SimpleItemComponent.- Parameters:
offsetX
- The X offset of the GUI component.offsetY
- The Y offset of the GUI component.priority
- The rendering priority of the GUI component.id
- The ID of the GUI component.clickFunctions
- The list of click functions for the GUI component.dragFunctions
- The list of drag functions for the GUI component.closeFunctions
- The list of close functions for the GUI component.stack
- The ItemStack to be displayed in the GUI component.hidden
- true if the GUI component is hidden, false otherwise.
-
-
Method Details
-
serialize
public void serialize(@NotNull @NotNull GeneratorContext gen, @NotNull @NotNull com.fasterxml.jackson.databind.SerializerProvider serializers) throws IOException Description copied from interface:GuiComponent
Serialize the GUI component using the provided GeneratorContext and SerializerProvider. This method is used to serialize the component's properties to a JSON representation.- Specified by:
serialize
in interfaceGuiComponent
- Overrides:
serialize
in classAbstractGuiComponent
- Parameters:
gen
- The GeneratorContext used for serialization.serializers
- The SerializerProvider used for serialization.- Throws:
IOException
- If there is an error during serialization.
-
getType
Description copied from interface:GuiComponent
Get the type of the GUI component.- Returns:
- The type of the GUI component.
-
render
public void render(@NotNull @NotNull org.bukkit.entity.Player viewer, @NotNull @NotNull org.bukkit.inventory.ItemStack[][] inventory) Description copied from interface:GuiComponent
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.
-