Class DynamicGuiElement

java.lang.Object
de.themoep.inventorygui.GuiElement
de.themoep.inventorygui.DynamicGuiElement

public class DynamicGuiElement
extends GuiElement
Represents an element in a gui that will query all it's data when drawn.
  • Constructor Details

    • DynamicGuiElement

      public DynamicGuiElement​(char slotChar, Supplier<GuiElement> query)
      Represents an element in a gui that will query all it's data when drawn.
      Parameters:
      slotChar - The character to replace in the gui setup string
      query - Query the element data, this should return an element with the information
    • DynamicGuiElement

      public DynamicGuiElement​(char slotChar, Function<org.bukkit.entity.HumanEntity,​GuiElement> query)
      Represents an element in a gui that will query all it's data when drawn.
      Parameters:
      slotChar - The character to replace in the gui setup string
      query - Query the element data, this should return an element with the information and handle null players properly
  • Method Details

    • update

      @Deprecated public void update()
      Deprecated.
      Query this element's state even if it shouldn't be done yet
    • update

      @Deprecated public void update​(org.bukkit.entity.HumanEntity player)
      Deprecated.
      This element no longer supports caching, use queryElement(HumanEntity) to query the element
      Query this element's state even if it shouldn't be done yet
      Parameters:
      player - The player for whom to update the element
    • setGui

      public void setGui​(InventoryGui gui)
      Description copied from class: GuiElement
      Set the gui this element belongs to
      Overrides:
      setGui in class GuiElement
      Parameters:
      gui - The GUI that this element is in
    • 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
    • getAction

      public GuiElement.Action getAction​(org.bukkit.entity.HumanEntity who)
      Description copied from class: GuiElement
      Get the action that is executed when clicking on this element
      Overrides:
      getAction in class GuiElement
      Parameters:
      who - The player who views the page
      Returns:
      The action to run
    • getQuery

      public Function<org.bukkit.entity.HumanEntity,​GuiElement> getQuery()
      Get the supplier for this element's content
      Returns:
      The supplier query
    • setQuery

      public void setQuery​(Function<org.bukkit.entity.HumanEntity,​GuiElement> query)
      Set the supplier for this element's content
      Parameters:
      query - The supplier query to set
    • queryElement

      public GuiElement queryElement​(org.bukkit.entity.HumanEntity who)
      Query the element for a player
      Parameters:
      who - The player
      Returns:
      The GuiElement or null
    • getCachedElement

      @Deprecated public GuiElement getCachedElement​(org.bukkit.entity.HumanEntity who)
      Deprecated.
      Caching is no longer supported by this class, this method will now only return the actual element that the query provides. Use queryElement(HumanEntity) as a more stable alternative. Caching might be re-added as a separate element class if there is a demand
      Get the cached element, creates a new one if there is none
      Parameters:
      who - The player to get the element for
      Returns:
      The element that is currently cached
    • getLastCached

      @Deprecated public long getLastCached()
      Deprecated.
      Caching is no longer supported by this class, this method will now only return the current time stamp. Caching might be re-added as a separate element class if there is a demand
      Get the time at which this element was last cached
      Returns:
      The timestamp from when it was last cached