@NonnullByDefault public abstract class Gui extends Object implements TerminableConsumer
| Modifier and Type | Field and Description |
|---|---|
static MetadataKey<Gui> |
OPEN_GUI_KEY |
| Constructor and Description |
|---|
Gui(Player player,
int lines,
String title) |
| Modifier and Type | Method and Description |
|---|---|
void |
addItem(Item item) |
void |
addItems(Iterable<Item> items) |
<T extends AutoCloseable> |
bind(T terminable)
Binds with the given terminable.
|
void |
clearItems() |
void |
close() |
void |
fillWith(Item item) |
Function<Player,Gui> |
getFallbackGui() |
int |
getFirstEmpty() |
Optional<Slot> |
getFirstEmptySlot() |
Inventory |
getHandle()
Gets the delegate Bukkit inventory
|
String |
getInitialTitle()
Gets the initial title which was set when this GUI was made
|
static int |
getMenuSize(int count)
Utility method to get the number of lines needed for x items
|
static int |
getMenuSize(int count,
int itemsPerLine)
Utility method to get the number of lines needed for x items
|
Player |
getPlayer()
Gets the player viewing this Gui
|
Slot |
getSlot(int slot) |
boolean |
isFirstDraw() |
boolean |
isValid()
Returns true unless this GUI has been invalidated, through being closed, or the player leaving.
|
void |
open() |
abstract void |
redraw()
Places items on the GUI.
|
void |
removeItem(int slot) |
void |
removeItems(int... slots) |
void |
removeItems(Iterable<Integer> slots) |
void |
setFallbackGui(Function<Player,Gui> fallbackGui) |
void |
setItem(int slot,
Item item) |
void |
setItems(Item item,
int... slots) |
void |
setItems(Iterable<Integer> slots,
Item item) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitbindModulepublic static final MetadataKey<Gui> OPEN_GUI_KEY
public static int getMenuSize(int count)
count - the number of itemspublic static int getMenuSize(int count,
int itemsPerLine)
count - the number of itemsitemsPerLine - the number of items per linepublic abstract void redraw()
isFirstDraw() to determine if this is the first time redraw has been called.public Player getPlayer()
public Inventory getHandle()
public String getInitialTitle()
@Nonnull public <T extends AutoCloseable> T bind(@Nonnull T terminable)
TerminableConsumerbind in interface TerminableConsumerT - the terminable typeterminable - the terminable to bind withpublic boolean isFirstDraw()
public Slot getSlot(int slot)
public void setItem(int slot,
Item item)
public void setItems(Item item, int... slots)
public int getFirstEmpty()
public void addItem(Item item)
public void fillWith(Item item)
public void removeItem(int slot)
public void removeItems(int... slots)
public void clearItems()
public void open()
public void close()
public boolean isValid()
Copyright © 2020. All rights reserved.