Package com.shanebeestudios.snippets.gui
Class GUI
java.lang.Object
com.shanebeestudios.snippets.gui.GUI
- All Implemented Interfaces:
Listener
,InventoryHolder
Create custom GUIs
Make sure to set the plugin (this is used for event listeners) see
Make sure to set the plugin (this is used for event listeners) see
setPlugin(Plugin)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Data involved when clicking a GUI slot -
Method Summary
Modifier and TypeMethodDescriptionstatic GUI
chestBuilder
(int rows, @Nullable String title) Create a chest GUI builderstatic GUI
customBuilder
(InventoryType type, @Nullable String title) Create a custom GUI builder using any inventory typeFill the GUI with an itemfill
(@NotNull ItemStack itemStack, Consumer<GUI.InventoryData> data) Fill the GUI with an item to run a function when clickedformatSlot
(int slot, @NotNull ItemStack itemStack, Consumer<GUI.InventoryData> data) Format a slot in the GUI to run a functionformatSlots
(int[] slots, @NotNull ItemStack itemStack, Consumer<GUI.InventoryData> data) Format multiple slots in the GUI to run a function@NotNull Inventory
Get the inventory from this GUILock a slotOpen this GUI to a playerstatic void
Set the plugin used for listening to events.
-
Method Details
-
setPlugin
Set the plugin used for listening to events.- Parameters:
plugin
- Instance of your plugin
-
chestBuilder
Create a chest GUI builder- Parameters:
rows
- Number of rows for the chest (must be between 1 and 6)title
- Title of your GUI- Returns:
- Instance of GUI builder
-
customBuilder
Create a custom GUI builder using any inventory type- Parameters:
type
- Type of GUI to createtitle
- Title of your GUI- Returns:
- Instance of GUI builder
-
formatSlot
public GUI formatSlot(int slot, @NotNull @NotNull ItemStack itemStack, Consumer<GUI.InventoryData> data) Format a slot in the GUI to run a function- Parameters:
slot
- Slot to setitemStack
- ItemStack to appear in slotdata
- Consumer to run when clicked with data from event- Returns:
- Instance of GUI builder
-
formatSlots
public GUI formatSlots(int[] slots, @NotNull @NotNull ItemStack itemStack, Consumer<GUI.InventoryData> data) Format multiple slots in the GUI to run a function- Parameters:
slots
- Slots to setitemStack
- ItemStack to appear in slotdata
- Consumer to run when clicked with data from event- Returns:
- Instance of GUI builder
-
lockSlot
Lock a slot- Parameters:
slot
- Slot to lockitemStack
- ItemStack to appear in slot- Returns:
- Instance of GUI builder
-
fill
Fill the GUI with an item to run a function when clicked- Parameters:
itemStack
- ItemStack to appear in all slotsdata
- Consumer to run when clicked with data from event- Returns:
- Instance of GUI builder
-
fill
Fill the GUI with an item- Parameters:
itemStack
- ItemStack to appear in all slots- Returns:
- Instance of GUI builder
-
getInventory
Get the inventory from this GUI- Specified by:
getInventory
in interfaceInventoryHolder
- Returns:
- Inventory from this GUI
-
open
Open this GUI to a player- Parameters:
player
- Player to open GUI for- Returns:
- Instance of GUI builder
-