Class BaseSimpleGUIPane<C extends GUISection,S extends BaseSimpleGUIPane<C,S>>

java.lang.Object
de.placeblock.betterinventories.content.GUISection
de.placeblock.betterinventories.content.pane.GUIPane
de.placeblock.betterinventories.content.pane.impl.simple.BaseSimpleGUIPane<C,S>
Type Parameters:
C - Which types of GUISection can be placed inside the BaseSimpleGUIPane
S - The implementing class to return this-type correctly e.g. addItemEmptySlot(GUIItem)
All Implemented Interfaces:
Sizeable
Direct Known Subclasses:
BaseSimpleItemGUIPane, SimpleGUIPane

public abstract class BaseSimpleGUIPane<C extends GUISection,S extends BaseSimpleGUIPane<C,S>> extends GUIPane
The Base for GUIPanes where content can be just placed with a Vector2d as the position.
  • Field Details

    • content

      protected final List<BaseSimpleGUIPane.ChildData<C extends GUISection>> content
      The content currently added to this Pane
    • autoSize

      protected final boolean autoSize
      Whether to automatically resize the pane according to the children. If true it will set the size to the bounding box of all children.
  • Constructor Details

    • BaseSimpleGUIPane

      protected BaseSimpleGUIPane(GUI gui, Vector2d minSize, Vector2d maxSize, boolean autoSize)
      Creates a new BaseSimpleGUIPane
      Parameters:
      gui - The GUI
      minSize - The minimum size of the Pane
      maxSize - The maximum size of the Pane
      autoSize - Whether to automatically resize the pane according to the children. If true it will set the size to the bounding box of all children.
  • Method Details

    • updateSizeRecursive

      public void updateSizeRecursive(Sizeable parent)
      Is called to recursively update the size of all GUIPanes
      Specified by:
      updateSizeRecursive in class GUIPane
      Parameters:
      parent - The parent Pane or GUI (Sizeable)
    • updateSize

      public void updateSize(Sizeable parent)
      Sets the size of the Pane to the bounding-box of all children if auto-size is enabled.
      Specified by:
      updateSize in class GUIPane
      Parameters:
      parent - The parent Pane or GUI (Sizeable)
    • getChildren

      public List<GUISection> getChildren()
      Description copied from class: GUIPane
      Implemented by GUIPanes Should return all children sections
      Specified by:
      getChildren in class GUIPane
      Returns:
      All children
    • onItemProvide

      public void onItemProvide(org.bukkit.inventory.ItemStack item)
      Description copied from class: GUIPane
      Called when an item is provided by an inventory MOVE_TO_OTHER_INVENTORY event
      Specified by:
      onItemProvide in class GUIPane
      Parameters:
      item - The provided item. Method reduces the amount of the item by the number that got accepted.
    • render

      public List<org.bukkit.inventory.ItemStack> render()
      Renders the Pane on a list
      Specified by:
      render in class GUISection
      Returns:
      The List
    • search

      public void search(SearchData searchData)
      Searches the GUISection recursively. The SearchData is filled recursively.
      Specified by:
      search in class GUISection
      Parameters:
      searchData - The searchData that contains all needed information
    • addItemEmptySlot

      public S addItemEmptySlot(GUIItem item)
      Adds an Item to an empty slot on the pane.
      Parameters:
      item - The Item
      Returns:
      this
    • fill

      public S fill(GUIItem item)
      Fills all empty slots with this Item.
      Parameters:
      item - The Item
      Returns:
      this
    • getNextEmptySlot

      public int getNextEmptySlot()
      Returns:
      The next empty slot or -1
    • removeSection

      public boolean removeSection(C section)
      Removes a section from the pane.
      Parameters:
      section - The Section
      Returns:
      Whether the section existed
    • removeSection

      public boolean removeSection(Vector2d position)
      Removes a section from the pane
      Parameters:
      position - The position of the section
      Returns:
      Whether the section existed
    • clear

      public S clear()
      Removes all sections from the pane
      Returns:
      this
    • setSectionAt

      public S setSectionAt(int slot, C section)
      Sets a section at a specific slot. Note that the specified slot is converted to a vector using the pane's width. This can lead to exceptions when the size of this pane is zero. Bear in mind that the vector conversion happens at the time calling this method, which means if you change the size afterward the position will stay the same. If it comes to issues you can use setSectionAt(Vector2d, GUISection)
      Parameters:
      slot - The slot
      section - The section
      Returns:
      this
    • setSectionAt

      public S setSectionAt(Vector2d position, C section)
      Sets a section at a specific position
      Parameters:
      position - The position
      section - The Section
      Returns:
      this
    • setSection

      public S setSection(C section)
      Sets a section at coordinates 0,0
      Parameters:
      section - The Section
      Returns:
      this
    • getSections

      public Collection<C> getSections(Vector2d position)
      Returns all sections at the given position
      Parameters:
      position - The position
      Returns:
      All sections at the position