Class SpigotInventoryUI
java.lang.Object
io.github.projectunified.craftux.spigot.SpigotInventoryUI
- All Implemented Interfaces:
org.bukkit.inventory.InventoryHolder
The inventory UI for Spigot
-
Constructor Summary
ConstructorsConstructorDescriptionSpigotInventoryUI(UUID viewerId, String title, int size) Create a new Chest inventory UISpigotInventoryUI(UUID viewerId, String title, org.bukkit.event.inventory.InventoryType type) Create a new Chest inventory UISpigotInventoryUI(UUID viewerId, Function<org.bukkit.inventory.InventoryHolder, org.bukkit.inventory.Inventory> inventoryFunction) Create a new inventory UI -
Method Summary
Modifier and TypeMethodDescriptionprotected ActionItemCreate an action item.Get the default button.org.bukkit.inventory.InventorygetMask()Get the maskGet the viewer's UUIDprotected booleanonClick(org.bukkit.event.inventory.InventoryClickEvent event) Called when the inventory is clicked.protected voidonClose(org.bukkit.event.inventory.InventoryCloseEvent event) Called when the inventory is closed.protected voidonDrag(org.bukkit.event.inventory.InventoryDragEvent event) Called when the inventory is dragged.protected voidonOpen(org.bukkit.event.inventory.InventoryOpenEvent event) Called when the inventory is opened.voidopen()Open the inventory for the viewervoidopen(org.bukkit.entity.Player player) Open the inventory for the playervoidsetDefaultButton(Button defaultButton) Set the default button.voidSet the maskvoidsetMoveItemOnBottom(boolean moveItemOnBottom) Whether to allow moving items in the bottom inventory (player inventory)voidupdate()Update the inventory
-
Constructor Details
-
SpigotInventoryUI
public SpigotInventoryUI(UUID viewerId, Function<org.bukkit.inventory.InventoryHolder, org.bukkit.inventory.Inventory> inventoryFunction) Create a new inventory UI- Parameters:
viewerId- the viewer's UUIDinventoryFunction- the function to create the inventory
-
SpigotInventoryUI
Create a new Chest inventory UI- Parameters:
viewerId- the viewer's UUIDtitle- the title of the inventorysize- the size of the inventory (must be a multiple of 9)
-
SpigotInventoryUI
public SpigotInventoryUI(UUID viewerId, String title, org.bukkit.event.inventory.InventoryType type) Create a new Chest inventory UI- Parameters:
viewerId- the viewer's UUIDtitle- the title of the inventorytype- the type of the inventory
-
-
Method Details
-
getInventory
public org.bukkit.inventory.Inventory getInventory()- Specified by:
getInventoryin interfaceorg.bukkit.inventory.InventoryHolder
-
open
public void open(org.bukkit.entity.Player player) Open the inventory for the player- Parameters:
player- the player
-
open
public void open()Open the inventory for the viewer -
getViewerId
Get the viewer's UUID- Returns:
- the viewer's UUID
-
getMask
Get the mask- Returns:
- the mask
-
setMask
Set the mask- Parameters:
mask- the mask
-
getDefaultButton
Get the default button. This button is used when an item is not explicitly defined in the mask.- Returns:
- the default button
-
setDefaultButton
Set the default button. This button is used when an item is not explicitly defined in the mask.- Parameters:
defaultButton- the default button
-
setMoveItemOnBottom
public void setMoveItemOnBottom(boolean moveItemOnBottom) Whether to allow moving items in the bottom inventory (player inventory)- Parameters:
moveItemOnBottom- true to allow moving items in the bottom inventory
-
update
public void update()Update the inventory -
createActionItem
Create an action item. Override this to add default logic to the item.- Returns:
- the action item
-
onOpen
protected void onOpen(org.bukkit.event.inventory.InventoryOpenEvent event) Called when the inventory is opened. Override to add custom behavior.- Parameters:
event- the event
-
onClick
protected boolean onClick(org.bukkit.event.inventory.InventoryClickEvent event) Called when the inventory is clicked. Override to add custom behavior.- Parameters:
event- the event- Returns:
- true if the action in the inventory can be performed
-
onClose
protected void onClose(org.bukkit.event.inventory.InventoryCloseEvent event) Called when the inventory is closed. Override to add custom behavior.- Parameters:
event- the event
-
onDrag
protected void onDrag(org.bukkit.event.inventory.InventoryDragEvent event) Called when the inventory is dragged. Override to add custom behavior.- Parameters:
event- the event
-