Package redempt.redlib.inventorygui
Class ItemButton
java.lang.Object
redempt.redlib.inventorygui.ItemButton
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionItemButton(org.bukkit.inventory.ItemStack item) Create a new ItemButton with the given ItemStack as the icon -
Method Summary
Modifier and TypeMethodDescriptionstatic ItemButtoncreate(org.bukkit.inventory.ItemStack item, BiConsumer<org.bukkit.event.inventory.InventoryClickEvent, ItemButton> listener) Create an ItemButton from the given ItemStack and listener.static ItemButtoncreate(org.bukkit.inventory.ItemStack item, Consumer<org.bukkit.event.inventory.InventoryClickEvent> listener) Create an ItemButton from the given ItemStack and listener.org.bukkit.inventory.ItemStackgetItem()Get the ItemStack representing the icon for this buttonprotected intgetSlot()abstract voidonClick(org.bukkit.event.inventory.InventoryClickEvent e) voidsetItem(org.bukkit.inventory.ItemStack item) Update the item of this button.protected voidsetSlot(int slot)
-
Field Details
-
item
protected org.bukkit.inventory.ItemStack item
-
-
Constructor Details
-
ItemButton
public ItemButton(org.bukkit.inventory.ItemStack item) Create a new ItemButton with the given ItemStack as the icon- Parameters:
item- The ItemStack to be used as the icon
-
-
Method Details
-
create
public static ItemButton create(org.bukkit.inventory.ItemStack item, Consumer<org.bukkit.event.inventory.InventoryClickEvent> listener) Create an ItemButton from the given ItemStack and listener. Useful if you, like most people, would rather use lambdas than the anonymous class definition.- Parameters:
item- The ItemStack to be used as this button's iconlistener- The listener which will be called whenever this button is clicked- Returns:
- The ItemButton, which can be added to an InventoryGUI
-
create
public static ItemButton create(org.bukkit.inventory.ItemStack item, BiConsumer<org.bukkit.event.inventory.InventoryClickEvent, ItemButton> listener) Create an ItemButton from the given ItemStack and listener. Useful if you, like most people, would rather use lambdas than the anonymous class definition.- Parameters:
item- The ItemStack to be used as this button's iconlistener- The listener which will be called whenever this button is clicked and accepts the event and button- Returns:
- The ItemButton, which can be added to an InventoryGUI
-
getItem
public org.bukkit.inventory.ItemStack getItem()Get the ItemStack representing the icon for this button- Returns:
- The ItemStack
-
getSlot
protected int getSlot() -
setSlot
protected void setSlot(int slot) -
setItem
public void setItem(org.bukkit.inventory.ItemStack item) Update the item of this button. Does not refresh the InventoryGUI; you must callInventoryGUI.update()for this change to be reflected in the GUI.- Parameters:
item- The item to become the icon for this button
-
onClick
public abstract void onClick(org.bukkit.event.inventory.InventoryClickEvent e)
-