Class ChestGUI
java.lang.Object
de.marcely.bedwars.tools.gui.type.ChestGUI
- All Implemented Interfaces:
ClickableGUI,GUI
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddCloseListener(Consumer<Player> callback) Adds a close listener to the gui.intaddItem(GUIItem item, @Nullable AddItemCondition condition) Adds the item at the next available slot.booleanReturns if this type allows its items to get moved around and to be droppedvoidclear()Resets its contentvoidcloseAll()Closes this GUI for any playervoidReplaces any slot with the given itemvoidReplaces any empty/air slot with the given itemintReturns the amount of items that fit in a column@Nullable GUIItemgetItem(int slot) Returns the item at the specific slot.intgetNextSpace(@Nullable AddItemCondition condition) Starts at slot 0 and tries to find the next available/empty slot.
Returns -1 if it didn't find anyReturns the player for whom the GUI is currently opengetTitle()Returns the set titleintgetWidth()Returns the amount of items that fit in a rowbooleanGet whether the given player has the inventory currently openbooleanIgnore it.booleanCopy over everything from another instance to this instance.voidOpens the GUI for the playerbooleanremoveCloseListener(Consumer<Player> callback) Removes a close listener from the gui.voidsetHeight(int height) Resizes the inventory and tries to keep the contentvoidSet an item at a specific slotvoidSet the title of the GUI.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface de.marcely.bedwars.tools.gui.ClickableGUI
addItem, addItem, addItem, addItem, addItem, calcSlot, fill, fill, fillSpace, fillSpace, formatAnyColumn, formatAnyColumn, formatAnyRow, formatAnyRow, formatColumn, formatColumn, formatRow, formatRow, getItem, getNextSpace, getSize, setItem, setItem, setItem, setItem, setItemMethods inherited from interface de.marcely.bedwars.tools.gui.GUI
getCloseListeners, onClose
-
Constructor Details
-
ChestGUI
public ChestGUI() -
ChestGUI
public ChestGUI(int height) -
ChestGUI
-
ChestGUI
-
-
Method Details
-
open
Description copied from interface:GUIOpens the GUI for the player -
closeAll
public void closeAll()Description copied from interface:GUICloses this GUI for any player -
setTitle
Description copied from interface:GUISet the title of the GUI. Keep in mind that not every type supports this -
getTitle
Description copied from interface:GUIReturns the set title -
areItemsMoveable
public boolean areItemsMoveable()Description copied from interface:GUIReturns if this type allows its items to get moved around and to be dropped- Specified by:
areItemsMoveablein interfaceGUI- Returns:
- If the items are moveable/dragable
-
ignoresCancelEvent
public boolean ignoresCancelEvent()Description copied from interface:GUIIgnore it. Only for internal use- Specified by:
ignoresCancelEventin interfaceGUI- Returns:
- Something you probably don't need
-
getPlayers
Description copied from interface:GUIReturns the player for whom the GUI is currently open- Specified by:
getPlayersin interfaceGUI- Returns:
- The players for who the GUI has been opened
-
hasOpen
Description copied from interface:GUIGet whether the given player has the inventory currently open -
addCloseListener
Description copied from interface:GUIAdds a close listener to the gui. This listener will be called when a player closes the gui- Specified by:
addCloseListenerin interfaceGUI- Parameters:
callback- the listener that is being added- Returns:
- if the listener was added successfully
-
removeCloseListener
Description copied from interface:GUIRemoves a close listener from the gui.- Specified by:
removeCloseListenerin interfaceGUI- Parameters:
callback- the listener that is being removed- Returns:
- if the listener was removed successfully
-
getWidth
public int getWidth()Description copied from interface:ClickableGUIReturns the amount of items that fit in a row- Specified by:
getWidthin interfaceClickableGUI- Returns:
- The width of the GUI
-
getHeight
public int getHeight()Description copied from interface:ClickableGUIReturns the amount of items that fit in a column- Specified by:
getHeightin interfaceClickableGUI- Returns:
- The width of the GUI
-
setItem
Description copied from interface:ClickableGUISet an item at a specific slot- Specified by:
setItemin interfaceClickableGUI- Parameters:
item- The item to be setslot- The target slot
-
getItem
Description copied from interface:ClickableGUIReturns the item at the specific slot. May return null if there's none- Specified by:
getItemin interfaceClickableGUI- 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:GUIResets its content -
fill
Description copied from interface:ClickableGUIReplaces any slot with the given item- Specified by:
fillin interfaceClickableGUI- Parameters:
item- The given item
-
fillSpace
Description copied from interface:ClickableGUIReplaces any empty/air slot with the given item- Specified by:
fillSpacein interfaceClickableGUI- Parameters:
item- The given item
-
getNextSpace
Description copied from interface:ClickableGUIStarts at slot 0 and tries to find the next available/empty slot.
Returns -1 if it didn't find any- Specified by:
getNextSpacein interfaceClickableGUI- Parameters:
condition- You may specify the search at a specific area- Returns:
- The next available/empty slot. -1 if the inventory is full
-
addItem
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:
addItemin interfaceClickableGUI- Parameters:
item- The item you want to addcondition- You may specify the search at a specific area- Returns:
- The slot to which it was added. -1 if the inventory is full
-
mergeFrom
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 copiedforceRecreate- Different titles and heights require inventory reconstruction. Set this tofalseif you don't want that- Returns:
trueif it was successful.falseif it got cancelled due toforceRecreatebeing false
-