Package de.themoep.inventorygui
Class StaticGuiElement
java.lang.Object
de.themoep.inventorygui.GuiElement
de.themoep.inventorygui.StaticGuiElement
- Direct Known Subclasses:
GuiBackElement
,GuiPageElement
Represents a simple element in a gui to which an action can be assigned.
If you want the item to change on click you have to do that yourself.
-
Nested Class Summary
Nested classes/interfaces inherited from class de.themoep.inventorygui.GuiElement
GuiElement.Action, GuiElement.Click
-
Field Summary
Fields inherited from class de.themoep.inventorygui.GuiElement
gui, slots
-
Constructor Summary
ConstructorDescriptionStaticGuiElement
(char slotChar, org.bukkit.inventory.ItemStack item, int number, GuiElement.Action action, String... text) Represents an element in a guiStaticGuiElement
(char slotChar, org.bukkit.inventory.ItemStack item, GuiElement.Action action, String... text) Represents an element in a guiStaticGuiElement
(char slotChar, org.bukkit.inventory.ItemStack item, String... text) Represents an element in a gui that doesn't have any action when clicked -
Method Summary
Modifier and TypeMethodDescriptionorg.bukkit.inventory.ItemStack
getItem
(org.bukkit.entity.HumanEntity who, int slot) Get the item that is displayed by this element on a certain pageint
Get the number that this element should displayorg.bukkit.inventory.ItemStack
Get the raw item displayed by this element which was passed to the constructor or set withsetItem(ItemStack)
.String[]
getText()
Get the text that this element displaysvoid
setItem
(org.bukkit.inventory.ItemStack item) Set the item that is displayed by this elementboolean
setNumber
(int number) Set the number that this element should display (via the Item's amount)void
Set this element's display text.Methods inherited from class de.themoep.inventorygui.GuiElement
getAction, getGui, getSlotChar, getSlotIndex, getSlotIndex, getSlots, setAction, setGui, setSlots
-
Constructor Details
-
StaticGuiElement
public StaticGuiElement(char slotChar, org.bukkit.inventory.ItemStack item, int number, GuiElement.Action action, String... text) throws IllegalArgumentException Represents an element in a gui- Parameters:
slotChar
- The character to replace in the gui setup stringitem
- The item this element displaysnumber
- The number, 1 will not display the numberaction
- The action to run when the player clicks on this elementtext
- The text to display on this element, placeholders are automatically replaced, seeInventoryGui.replace(java.lang.String, java.util.Map<java.lang.String, java.lang.String>)
for a list of the placeholder variables. Empty text strings are also filter out, use a single space if you want to add an empty line!
If it's not set/empty the item's default name will be used- Throws:
IllegalArgumentException
- If the number is below 1 or above the max stack count (currently 64)
-
StaticGuiElement
public StaticGuiElement(char slotChar, org.bukkit.inventory.ItemStack item, GuiElement.Action action, String... text) Represents an element in a gui- Parameters:
slotChar
- The character to replace in the gui setup stringitem
- The item this element displaysaction
- The action to run when the player clicks on this elementtext
- The text to display on this element, placeholders are automatically replaced, seeInventoryGui.replaceVars(org.bukkit.entity.HumanEntity, java.lang.String, java.lang.String...)
for a list of the placeholder variables. Empty text strings are also filter out, use a single space if you want to add an empty line!
If it's not set/empty the item's default name will be used
-
StaticGuiElement
Represents an element in a gui that doesn't have any action when clicked- Parameters:
slotChar
- The character to replace in the gui setup stringitem
- The item this element displaystext
- The text to display on this element, placeholders are automatically replaced, seeInventoryGui.replaceVars(org.bukkit.entity.HumanEntity, java.lang.String, java.lang.String...)
for a list of the placeholder variables. Empty text strings are also filter out, use a single space if you want to add an empty line!
If it's not set/empty the item's default name will be used
-
-
Method Details
-
setItem
public void setItem(org.bukkit.inventory.ItemStack item) Set the item that is displayed by this element- Parameters:
item
- The item that should be displayed by this element
-
getRawItem
public org.bukkit.inventory.ItemStack getRawItem()Get the raw item displayed by this element which was passed to the constructor or set withsetItem(ItemStack)
. This item will not have the amount or text applied! UsegetItem(HumanEntity, int)
for that!- Returns:
- The raw item
-
getItem
public org.bukkit.inventory.ItemStack getItem(org.bukkit.entity.HumanEntity who, int slot) Description copied from class:GuiElement
Get the item that is displayed by this element on a certain page- Specified by:
getItem
in classGuiElement
- Parameters:
who
- The player who views the pageslot
- The slot to get the item for- Returns:
- The ItemStack that is displayed as this element
-
setText
Set this element's display text. If this is an empty array the item's name will be displayed- Parameters:
text
- The text to display on this element, placeholders are automatically replaced, seeInventoryGui.replaceVars(org.bukkit.entity.HumanEntity, java.lang.String, java.lang.String...)
for a list of the placeholder variables. Empty text strings are also filter out, use a single space if you want to add an empty line!
If it's not set/empty the item's default name will be used
-
getText
Get the text that this element displays- Returns:
- The text that is displayed on this element
-
setNumber
public boolean setNumber(int number) Set the number that this element should display (via the Item's amount)- Parameters:
number
- The number, 1 will not display the number- Returns:
true
if the number was set;false
if it was below 1 or above 64
-
getNumber
public int getNumber()Get the number that this element should display- Returns:
- The number (item amount) that this element currently has
-