Class ChestGUI

java.lang.Object
de.marcely.bedwars.tools.gui.type.ChestGUI
All Implemented Interfaces:
ClickableGUI, GUI

public class ChestGUI extends Object implements ClickableGUI
  • Constructor Details

    • ChestGUI

      public ChestGUI()
    • ChestGUI

      public ChestGUI(int height)
    • ChestGUI

      public ChestGUI(String title)
    • ChestGUI

      public ChestGUI(int height, String title)
  • Method Details

    • open

      public void open(Player player)
      Description copied from interface: GUI
      Opens the GUI for the player
      Specified by:
      open in interface GUI
      Parameters:
      player - The player who shall see the inventory
    • closeAll

      public void closeAll()
      Description copied from interface: GUI
      Closes this GUI for any player
      Specified by:
      closeAll in interface GUI
    • setTitle

      public void setTitle(String title)
      Description copied from interface: GUI
      Set the title of the GUI. Keep in mind that not every type supports this
      Specified by:
      setTitle in interface GUI
      Parameters:
      title - The new title
    • getTitle

      public String getTitle()
      Description copied from interface: GUI
      Returns the set title
      Specified by:
      getTitle in interface GUI
      Returns:
      The title
    • areItemsMoveable

      public boolean areItemsMoveable()
      Description copied from interface: GUI
      Returns if this type allows its items to get moved around and to be dropped
      Specified by:
      areItemsMoveable in interface GUI
      Returns:
      If the items are moveable/dragable
    • ignoresCancelEvent

      public boolean ignoresCancelEvent()
      Description copied from interface: GUI
      Ignore it. Only for internal use
      Specified by:
      ignoresCancelEvent in interface GUI
      Returns:
      Something you probably don't need
    • getPlayers

      public Collection<Player> getPlayers()
      Description copied from interface: GUI
      Returns the player for whom the GUI is currently open
      Specified by:
      getPlayers in interface GUI
      Returns:
      The players for who the GUI has been opened
    • hasOpen

      public boolean hasOpen(Player player)
      Description copied from interface: GUI
      Get whether the given player has the inventory currently open
      Specified by:
      hasOpen in interface GUI
      Parameters:
      player - The player who might have the GUI open
      Returns:
      true if he's seeing it right now
    • addCloseListener

      public boolean addCloseListener(Consumer<Player> callback)
      Description copied from interface: GUI
      Adds a close listener to the gui. This listener will be called when a player closes the gui
      Specified by:
      addCloseListener in interface GUI
      Parameters:
      callback - the listener that is being added
      Returns:
      if the listener was added successfully
    • removeCloseListener

      public boolean removeCloseListener(Consumer<Player> callback)
      Description copied from interface: GUI
      Removes a close listener from the gui.
      Specified by:
      removeCloseListener in interface GUI
      Parameters:
      callback - the listener that is being removed
      Returns:
      if the listener was removed successfully
    • getWidth

      public int getWidth()
      Description copied from interface: ClickableGUI
      Returns the amount of items that fit in a row
      Specified by:
      getWidth in interface ClickableGUI
      Returns:
      The width of the GUI
    • getHeight

      public int getHeight()
      Description copied from interface: ClickableGUI
      Returns the amount of items that fit in a column
      Specified by:
      getHeight in interface ClickableGUI
      Returns:
      The width of the GUI
    • setItem

      public void setItem(GUIItem item, int slot)
      Description copied from interface: ClickableGUI
      Set an item at a specific slot
      Specified by:
      setItem in interface ClickableGUI
      Parameters:
      item - The item to be set
      slot - The target slot
    • getItem

      @Nullable public @Nullable GUIItem getItem(int slot)
      Description copied from interface: ClickableGUI
      Returns the item at the specific slot. May return null if there's none
      Specified by:
      getItem in interface ClickableGUI
      Parameters:
      slot - The slot at which the item may be
      Returns:
      The placed item. May be null
    • setHeight

      public void setHeight(int height)
      Resizes the inventory and tries to keep the content
      Parameters:
      height - The new height
    • clear

      public void clear()
      Description copied from interface: GUI
      Resets its content
      Specified by:
      clear in interface GUI
    • fill

      public void fill(GUIItem item)
      Description copied from interface: ClickableGUI
      Replaces any slot with the given item
      Specified by:
      fill in interface ClickableGUI
      Parameters:
      item - The given item
    • fillSpace

      public void fillSpace(GUIItem item)
      Description copied from interface: ClickableGUI
      Replaces any empty/air slot with the given item
      Specified by:
      fillSpace in interface ClickableGUI
      Parameters:
      item - The given item
    • getNextSpace

      public int getNextSpace(@Nullable @Nullable AddItemCondition condition)
      Description copied from interface: ClickableGUI
      Starts at slot 0 and tries to find the next available/empty slot.
      Returns -1 if it didn't find any
      Specified by:
      getNextSpace in interface ClickableGUI
      Parameters:
      condition - You may specify the search at a specific area
      Returns:
      The next available/empty slot. -1 if the inventory is full
    • addItem

      public int addItem(GUIItem item, @Nullable @Nullable AddItemCondition condition)
      Adds the item at the next available slot.

      Keep in mind that items with the same materials don't get filled up.
      Also tries to increase height of inventory to make space for items.

      Specified by:
      addItem in interface ClickableGUI
      Parameters:
      item - The item you want to add
      condition - You may specify the search at a specific area
      Returns:
      The slot to which it was added. -1 if the inventory is full
    • mergeFrom

      public boolean mergeFrom(ChestGUI gui, boolean forceRecreate)
      Copy over everything from another instance to this instance.

      This is used to display new content while avoiding flicker.

      Parameters:
      gui - The GUI from which things shall be copied
      forceRecreate - Different titles and heights require inventory reconstruction. Set this to false if you don't want that
      Returns:
      true if it was successful. false if it got cancelled due to forceRecreate being false