Class StaticGuiElement

java.lang.Object
de.themoep.inventorygui.GuiElement
de.themoep.inventorygui.StaticGuiElement
Direct Known Subclasses:
GuiBackElement, GuiPageElement

public class StaticGuiElement extends GuiElement
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.
  • 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 string
      item - The item this element displays
      number - The number, 1 will not display the number
      action - The action to run when the player clicks on this element
      text - The text to display on this element, placeholders are automatically replaced, see InventoryGui.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 string
      item - The item this element displays
      action - The action to run when the player clicks on this element
      text - The text to display on this element, placeholders are automatically replaced, see InventoryGui.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

      public StaticGuiElement(char slotChar, org.bukkit.inventory.ItemStack item, String... text)
      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
      item - The item this element displays
      text - The text to display on this element, placeholders are automatically replaced, see InventoryGui.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 with setItem(ItemStack). This item will not have the amount or text applied! Use getItem(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 class GuiElement
      Parameters:
      who - The player who views the page
      slot - The slot to get the item for
      Returns:
      The ItemStack that is displayed as this element
    • setText

      public void setText(String... text)
      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, see InventoryGui.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

      public String[] 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