Class ChestGUI
java.lang.Object
de.marcely.bedwars.tools.gui.type.ChestGUI
- All Implemented Interfaces:
ClickableGUI
,GUI
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
addCloseListener
(Consumer<Player> callback) Adds a close listener to the gui.int
addItem
(GUIItem item, @Nullable AddItemCondition condition) Adds the item at the next available slot.boolean
Returns if this type allows its items to get moved around and to be droppedvoid
clear()
Resets its contentvoid
closeAll()
Closes this GUI for any playervoid
Replaces any slot with the given itemvoid
Replaces any empty/air slot with the given itemint
Returns the amount of items that fit in a column@Nullable GUIItem
getItem
(int slot) Returns the item at the specific slot.int
getNextSpace
(@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 titleint
getWidth()
Returns the amount of items that fit in a rowboolean
Get whether the given player has the inventory currently openboolean
Ignore it.boolean
Copy over everything from another instance to this instance.void
Opens the GUI for the playerboolean
removeCloseListener
(Consumer<Player> callback) Removes a close listener from the gui.void
setHeight
(int height) Resizes the inventory and tries to keep the contentvoid
Set an item at a specific slotvoid
Set the title of the GUI.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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, setItem
Methods 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:GUI
Opens the GUI for the player -
closeAll
public void closeAll()Description copied from interface:GUI
Closes this GUI for any player -
setTitle
Description copied from interface:GUI
Set the title of the GUI. Keep in mind that not every type supports this -
getTitle
Description copied from interface:GUI
Returns the set 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 interfaceGUI
- 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 interfaceGUI
- Returns:
- Something you probably don't need
-
getPlayers
Description copied from interface:GUI
Returns the player for whom the GUI is currently open- Specified by:
getPlayers
in interfaceGUI
- Returns:
- The players for who the GUI has been opened
-
hasOpen
Description copied from interface:GUI
Get whether the given player has the inventory currently open -
addCloseListener
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 interfaceGUI
- Parameters:
callback
- the listener that is being added- Returns:
- if the listener was added successfully
-
removeCloseListener
Description copied from interface:GUI
Removes a close listener from the gui.- Specified by:
removeCloseListener
in interfaceGUI
- 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 interfaceClickableGUI
- 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 interfaceClickableGUI
- Returns:
- The width of the GUI
-
setItem
Description copied from interface:ClickableGUI
Set an item at a specific slot- Specified by:
setItem
in interfaceClickableGUI
- Parameters:
item
- The item to be setslot
- The target slot
-
getItem
Description copied from interface:ClickableGUI
Returns the item at the specific slot. May return null if there's none- Specified by:
getItem
in 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:GUI
Resets its content -
fill
Description copied from interface:ClickableGUI
Replaces any slot with the given item- Specified by:
fill
in interfaceClickableGUI
- Parameters:
item
- The given item
-
fillSpace
Description copied from interface:ClickableGUI
Replaces any empty/air slot with the given item- Specified by:
fillSpace
in interfaceClickableGUI
- Parameters:
item
- The given item
-
getNextSpace
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 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:
addItem
in 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 tofalse
if you don't want that- Returns:
true
if it was successful.false
if it got cancelled due toforceRecreate
being false
-