Class EmbeddedGuiComponent
java.lang.Object
io.github.toberocat.guiengine.components.AbstractGuiComponent
io.github.toberocat.guiengine.components.provided.embedded.EmbeddedGuiComponent
- All Implemented Interfaces:
GuiComponent
,GuiEvents
- Direct Known Subclasses:
PagedComponent
A GUI component that embeds another GUI inside it.
This component allows embedding and rendering a target GUI inside the current GUI.
Created: 06.04.2023
Author: Tobias Madlberger (Tobias)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final boolean
protected @Nullable GuiContext
protected final boolean
protected final @NotNull String
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
ConstructorsConstructorDescriptionEmbeddedGuiComponent
(int offsetX, int offsetY, int width, int height, @NotNull RenderPriority priority, @NotNull String id, @NotNull List<GuiFunction> clickFunctions, @NotNull List<GuiFunction> dragFunctions, @NotNull List<GuiFunction> closeFunctions, boolean hidden, @NotNull String targetGui, boolean copyAir, boolean interactions) Constructor for EmbeddedGuiComponent. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clickedComponent
(@NotNull org.bukkit.event.inventory.InventoryClickEvent event) Called when a player clicks on a component in the GUI.void
closedComponent
(@NotNull org.bukkit.event.inventory.InventoryCloseEvent event) Called when a player closes the GUI.void
draggedComponent
(@NotNull org.bukkit.event.inventory.InventoryDragEvent event) Called when a player drags an item in the GUI.@NotNull String
getType()
Get the type of the GUI component.void
onViewInit
(@NotNull Map<String, String> placeholders) Called when the GUI is initialized and the viewer (player) opens it.void
render
(@NotNull org.bukkit.entity.Player viewer, @NotNull org.bukkit.inventory.ItemStack[][] buffer) 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
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
-
Field Details
-
TYPE
- See Also:
-
targetGui
-
copyAir
protected final boolean copyAir -
interactions
protected final boolean interactions -
embedded
-
-
Constructor Details
-
EmbeddedGuiComponent
public EmbeddedGuiComponent(int offsetX, int offsetY, int width, int height, @NotNull @NotNull RenderPriority priority, @NotNull @NotNull String id, @NotNull @NotNull List<GuiFunction> clickFunctions, @NotNull @NotNull List<GuiFunction> dragFunctions, @NotNull @NotNull List<GuiFunction> closeFunctions, boolean hidden, @NotNull @NotNull String targetGui, boolean copyAir, boolean interactions) Constructor for EmbeddedGuiComponent.- Parameters:
offsetX
- The X offset of the GUI component.offsetY
- The Y offset of the GUI component.width
- The width of the GUI component.height
- The height 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.hidden
- true if the GUI component is hidden, false otherwise.targetGui
- The ID of the target GUI to embed inside this component.copyAir
- true to copy air slots from the embedded GUI, false to skip empty slots.interactions
- true to allow interactions with the embedded GUI, false to ignore interactions.
-
-
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.
-
onViewInit
Description copied from interface:GuiEvents
Called when the GUI is initialized and the viewer (player) opens it. This method is intended to handle any necessary initialization tasks before the GUI is shown to the player. The `placeholders` parameter can be used to store additional information specific to the GUI. The default behavior is to do nothing.- Parameters:
placeholders
- A map containing placeholder data for the GUI.
-
clickedComponent
public void clickedComponent(@NotNull @NotNull org.bukkit.event.inventory.InventoryClickEvent event) Description copied from interface:GuiEvents
Called when a player clicks on a component in the GUI. The default behavior is to cancel the event and deny its result. If the action does not involve dropping an item, the event handling is skipped.- Specified by:
clickedComponent
in interfaceGuiEvents
- Overrides:
clickedComponent
in classAbstractGuiComponent
- Parameters:
event
- The `InventoryClickEvent` representing the click event.
-
draggedComponent
public void draggedComponent(@NotNull @NotNull org.bukkit.event.inventory.InventoryDragEvent event) Description copied from interface:GuiEvents
Called when a player drags an item in the GUI. The default behavior is to cancel the event.- Specified by:
draggedComponent
in interfaceGuiEvents
- Overrides:
draggedComponent
in classAbstractGuiComponent
- Parameters:
event
- The `InventoryDragEvent` representing the drag event.
-
closedComponent
public void closedComponent(@NotNull @NotNull org.bukkit.event.inventory.InventoryCloseEvent event) Description copied from interface:GuiEvents
Called when a player closes the GUI. The default behavior is to do nothing.- Specified by:
closedComponent
in interfaceGuiEvents
- Overrides:
closedComponent
in classAbstractGuiComponent
- Parameters:
event
- The `InventoryCloseEvent` representing the close event.
-
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[][] buffer) 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.buffer
- The inventory configuration used for rendering the GUI.
-