Package de.themoep.inventorygui
Class GuiElement
java.lang.Object
de.themoep.inventorygui.GuiElement
- Direct Known Subclasses:
DynamicGuiElement
,GuiElementGroup
,GuiStateElement
,GuiStorageElement
,StaticGuiElement
Represents an element in a gui
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
A functional interface for specifying how clicking on the element should be treated by implementing theGuiElement.Action.onClick(Click)
method.static class
-
Field Summary
-
Constructor Summary
ConstructorDescriptionGuiElement
(char slotChar) Represents an element in a gui that doesn't have any action when clickedGuiElement
(char slotChar, GuiElement.Action action) Represents an element in a gui -
Method Summary
Modifier and TypeMethodDescriptiongetAction
(org.bukkit.entity.HumanEntity who) Get the action that is executed when clicking on this elementgetGui()
Get the gui this element belongs toabstract org.bukkit.inventory.ItemStack
getItem
(org.bukkit.entity.HumanEntity who, int slot) Get the item that is displayed by this element on a certain pagechar
Get the character in the gui setup that corresponds with this elementint
getSlotIndex
(int slot) Get the index that this slot has in the list of slots that this element is displayed inint
getSlotIndex
(int slot, int pageNumber) Get the index that this slot has in the list of slots that this element is displayed inint[]
getSlots()
Get the indexes of the lots that this element is displayed invoid
setAction
(GuiElement.Action action) Set the action that is executed when clicking on this elementvoid
setGui
(InventoryGui gui) Set the gui this element belongs tovoid
setSlots
(int[] slots) Set the ids of the slots where this element is assigned to
-
Field Details
-
slots
protected int[] slots -
gui
-
-
Constructor Details
-
GuiElement
Represents an element in a gui- Parameters:
slotChar
- The character to replace in the gui setup stringaction
- The action to run when the player clicks on this element
-
GuiElement
public GuiElement(char slotChar) Represents an element in a gui that doesn't have any action when clicked- Parameters:
slotChar
- The character to replace in the gui setup string
-
-
Method Details
-
getSlotChar
public char getSlotChar()Get the character in the gui setup that corresponds with this element- Returns:
- The character
-
getItem
public abstract org.bukkit.inventory.ItemStack getItem(org.bukkit.entity.HumanEntity who, int slot) Get the item that is displayed by this element on a certain page- Parameters:
who
- The player who views the pageslot
- The slot to get the item for- Returns:
- The ItemStack that is displayed as this element
-
getAction
Get the action that is executed when clicking on this element- Parameters:
who
- The player who views the page- Returns:
- The action to run
-
setAction
Set the action that is executed when clicking on this element- Parameters:
action
- The action to run. TheGuiElement.Action.onClick(de.themoep.inventorygui.GuiElement.Click)
method should return whether or not the click event should be cancelled
-
getSlots
public int[] getSlots()Get the indexes of the lots that this element is displayed in- Returns:
- An array of the lost indexes
-
setSlots
public void setSlots(int[] slots) Set the ids of the slots where this element is assigned to- Parameters:
slots
- An array of the slot ids where this element is displayed
-
getSlotIndex
public int getSlotIndex(int slot) Get the index that this slot has in the list of slots that this element is displayed in- Parameters:
slot
- The id of the slot- Returns:
- The index in the list of slots that this id has or
-1
if it isn't in that list
-
getSlotIndex
public int getSlotIndex(int slot, int pageNumber) Get the index that this slot has in the list of slots that this element is displayed in- Parameters:
slot
- The id of the slotpageNumber
- The number of the page that the gui is on- Returns:
- The index in the list of slots that this id has or
-1
if it isn't in that list
-
setGui
Set the gui this element belongs to- Parameters:
gui
- The GUI that this element is in
-
getGui
Get the gui this element belongs to- Returns:
- The GUI that this element is in
-