public class Gui extends Object implements org.bukkit.inventory.InventoryHolder
| Modifier and Type | Class and Description |
|---|---|
static class |
Gui.State
The gui state
|
| Constructor and Description |
|---|
Gui(org.bukkit.plugin.Plugin plugin,
int rows,
String title)
Constructs a new GUI
|
| Modifier and Type | Method and Description |
|---|---|
void |
addPane(Pane pane)
Adds a pane to this gui
|
protected HumanEntityCache |
getHumanEntityCache()
Gets the human entity cache used for this gui
|
org.bukkit.inventory.Inventory |
getInventory() |
static org.bukkit.inventory.Inventory |
getInventory(org.bukkit.inventory.InventoryView view,
int rawSlot) |
Collection<GuiItem> |
getItems()
Gets all the items in all underlying panes
|
Consumer<org.bukkit.event.inventory.InventoryClickEvent> |
getOnBottomClick()
Gets the bottom click event assigned to this gui, or null if there is no bottom click assigned.
|
Consumer<org.bukkit.event.inventory.InventoryCloseEvent> |
getOnClose()
Gets the on close event assigned to this gui, or null if no close event is assigned.
|
Consumer<org.bukkit.event.inventory.InventoryClickEvent> |
getOnGlobalClick()
Gets the global click event assigned to this gui, or null if there is no global click assigned.
|
Consumer<org.bukkit.event.inventory.InventoryClickEvent> |
getOnOutsideClick()
Gets the outside click event assigned to this gui, or null if there is no outside click assigned.
|
Consumer<org.bukkit.event.inventory.InventoryClickEvent> |
getOnTopClick()
Gets the top click event assigned to this gui, or null if there is no top click assigned.
|
List<Pane> |
getPanes()
Gets all the panes in this gui, this includes child panes from other panes
|
int |
getRows()
Returns the amount of rows this gui currently has
|
Gui.State |
getState()
Gets the state of this gui
|
String |
getTitle()
Returns the title of this gui
|
static Gui |
load(org.bukkit.plugin.Plugin plugin,
Object instance,
InputStream inputStream)
Loads a Gui from a given input stream
|
static Pane |
loadPane(Object instance,
Node node)
Loads a pane by the given instance and node
|
static void |
registerPane(String name,
BiFunction<Object,Element,Pane> biFunction)
Registers a name that can be used inside an XML file to add custom panes
|
static void |
registerProperty(String attributeName,
Function<String,Object> function)
Registers a property that can be used inside an XML file to add additional new properties.
|
void |
setOnBottomClick(Consumer<org.bukkit.event.inventory.InventoryClickEvent> onBottomClick)
Set the consumer that should be called whenever the inventory is clicked in.
|
void |
setOnClose(Consumer<org.bukkit.event.inventory.InventoryCloseEvent> onClose)
Set the consumer that should be called whenever this gui is closed.
|
void |
setOnGlobalClick(Consumer<org.bukkit.event.inventory.InventoryClickEvent> onGlobalClick)
Set the consumer that should be called whenever this gui or inventory is clicked in.
|
void |
setOnLocalClick(Consumer<org.bukkit.event.inventory.InventoryClickEvent> onLocalClick)
Deprecated.
|
void |
setOnOutsideClick(Consumer<org.bukkit.event.inventory.InventoryClickEvent> onOutsideClick)
Set the consumer that should be called whenever a player clicks outside the gui.
|
void |
setOnTopClick(Consumer<org.bukkit.event.inventory.InventoryClickEvent> onTopClick)
Set the consumer that should be called whenever this gui is clicked in.
|
void |
setRows(int rows)
Sets the amount of rows for this inventory.
|
void |
setState(Gui.State state)
Calling this method will set the state of this gui.
|
void |
setTitle(String title)
Sets the title for this inventory.
|
void |
show(org.bukkit.entity.HumanEntity humanEntity)
Shows a gui to a player
|
void |
update()
Update the gui for everyone
|
public Gui(@NotNull
org.bukkit.plugin.Plugin plugin,
int rows,
@NotNull
String title)
plugin - the main plugin.rows - the amount of rows this gui should contain, in range 1..6.title - the title/name of this gui.public void addPane(@NotNull
Pane pane)
pane - the pane to addpublic void show(@NotNull
org.bukkit.entity.HumanEntity humanEntity)
humanEntity - the human entity to show the gui topublic void setRows(int rows)
rows - the amount of rows in range 1..6.@NotNull @Contract(pure=true) public List<Pane> getPanes()
public void setTitle(@NotNull
String title)
title - the title@NotNull @Contract(pure=true) public Collection<GuiItem> getItems()
public void update()
public void setState(@NotNull
Gui.State state)
state - the new gui state@NotNull @Contract(pure=true) public Gui.State getState()
@NotNull @Contract(pure=true) protected HumanEntityCache getHumanEntityCache()
HumanEntityCache@Nullable @Contract(value="_, _, null -> fail") public static Gui load(@NotNull org.bukkit.plugin.Plugin plugin, @NotNull Object instance, @NotNull InputStream inputStream)
plugin - the main plugininstance - the class instance for all reflection lookupsinputStream - the filepublic void setOnTopClick(@NotNull
Consumer<org.bukkit.event.inventory.InventoryClickEvent> onTopClick)
onTopClick - the consumer that gets called@Nullable @Contract(pure=true) public Consumer<org.bukkit.event.inventory.InventoryClickEvent> getOnTopClick()
public void setOnBottomClick(@NotNull
Consumer<org.bukkit.event.inventory.InventoryClickEvent> onBottomClick)
onBottomClick - the consumer that gets called@Nullable @Contract(pure=true) public Consumer<org.bukkit.event.inventory.InventoryClickEvent> getOnBottomClick()
public void setOnGlobalClick(@NotNull
Consumer<org.bukkit.event.inventory.InventoryClickEvent> onGlobalClick)
onGlobalClick - the consumer that gets called@Nullable @Contract(pure=true) public Consumer<org.bukkit.event.inventory.InventoryClickEvent> getOnGlobalClick()
public void setOnOutsideClick(@NotNull
Consumer<org.bukkit.event.inventory.InventoryClickEvent> onOutsideClick)
onOutsideClick - the consumer that gets called@Nullable @Contract(pure=true) public Consumer<org.bukkit.event.inventory.InventoryClickEvent> getOnOutsideClick()
@Deprecated public void setOnLocalClick(@NotNull Consumer<org.bukkit.event.inventory.InventoryClickEvent> onLocalClick)
setOnTopClick(Consumer)onLocalClick - the consumer that gets calledpublic void setOnClose(@NotNull
Consumer<org.bukkit.event.inventory.InventoryCloseEvent> onClose)
onClose - the consumer that gets called@Nullable @Contract(pure=true) public Consumer<org.bukkit.event.inventory.InventoryCloseEvent> getOnClose()
public int getRows()
@NotNull @Contract(pure=true) public String getTitle()
@NotNull public org.bukkit.inventory.Inventory getInventory()
getInventory in interface org.bukkit.inventory.InventoryHolderpublic static org.bukkit.inventory.Inventory getInventory(org.bukkit.inventory.InventoryView view,
int rawSlot)
public static void registerProperty(@NotNull
String attributeName,
@NotNull
Function<String,Object> function)
attributeName - the name of the property. This is the same name you'll be using to specify the property
type in the XML file.function - how the property should be processed. This converts the raw text input from the XML node value
into the correct object type.IllegalArgumentException - when a property with this name is already registered.public static void registerPane(@NotNull
String name,
@NotNull
BiFunction<Object,Element,Pane> biFunction)
name - the name of the pane to be used in the XML filebiFunction - how the pane loading should be processedIllegalArgumentException - when a pane with this name is already registeredCopyright © 2019. All rights reserved.