Class GUIHolder<T extends InventoryContext>
java.lang.Object
me.hsgamer.hscore.minecraft.gui.holder.GUIHolder<T>
- Type Parameters:
T- the type of the inventory context
- All Implemented Interfaces:
GUIElement
- Direct Known Subclasses:
BukkitGUIHolder,MinestomGUIHolder
The base holder for Minecraft GUI implementation
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleancanSetItem(int slot) Check if the item can be set in the slotprotected abstract TCreate the inventory contextFunction<@NotNull InventoryContext, @Nullable Map<Integer, ActionItem>> Get the button mapGet the inventory contextgetItem(int slot) Get the item in the slotGet the item mapGet the unique ID of the viewervoidhandleClick(ClickEvent event) Override this method to add custom behavior.voidhandleClose(CloseEvent event) Handle the close event.voidhandleOpen(OpenEvent event) Handle the open event.voidinit()Initialize the element.voidopen()Open the inventoryabstract voidOpen the inventoryvoidsetButtonMap(Function<@NotNull InventoryContext, @Nullable Map<Integer, ActionItem>> buttonMap) Set the button mapprotected abstract voidsetItem(int slot, @Nullable ActionItem item) Set the item in the slotvoidstop()Stop the element.voidupdate()Update the inventory
-
Constructor Details
-
GUIHolder
Create a new holder- Parameters:
viewerID- the unique ID of the viewer
-
-
Method Details
-
createInventoryContext
Create the inventory context- Returns:
- the inventory context
-
setItem
Set the item in the slot- Parameters:
slot- the slotitem- the item
-
canSetItem
protected boolean canSetItem(int slot) Check if the item can be set in the slot- Parameters:
slot- the slot- Returns:
- true if the item can be set
-
open
Open the inventory- Parameters:
viewerID- the unique ID of the player
-
handleOpen
Handle the open event. Override this method to add custom behavior.- Parameters:
event- the event
-
handleClose
Handle the close event. Override this method to add custom behavior.- Parameters:
event- the event
-
handleClick
Override this method to add custom behavior. -
update
public void update()Update the inventory -
init
public void init()Description copied from interface:GUIElementInitialize the element. Should be called before adding to the GUI.- Specified by:
initin interfaceGUIElement
-
stop
public void stop()Description copied from interface:GUIElementStop the element. Should be called after removing from the GUI.- Specified by:
stopin interfaceGUIElement
-
getViewerID
Get the unique ID of the viewer- Returns:
- the unique ID of the viewer
-
getInventoryContext
Get the inventory context- Returns:
- the inventory context
-
getItem
Get the item in the slot- Parameters:
slot- the slot- Returns:
- the item
-
getItemMap
Get the item map- Returns:
- the item map
-
getButtonMap
Get the button map- Returns:
- the button map
-
setButtonMap
public void setButtonMap(Function<@NotNull InventoryContext, @Nullable Map<Integer, ActionItem>> buttonMap) Set the button map- Parameters:
buttonMap- the button map
-
open
public void open()Open the inventory
-