Class Gui
java.lang.Object
com.github.cyberryan1.cybercore.spigot.gui.Gui
This is what is mainly used by others to create GUIs, edit their contents, and open them to players
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds the item to the GUIorg.bukkit.inventory.ItemStack
Gets the background item that is being used in the GUIorg.bukkit.inventory.Inventory
getItem
(int slot) Gets the item at a specified slot in the GUIgetName()
Gets the name of the GUIint
getSize()
Gets the size (rows) of the GUIvoid
openInventory
(org.bukkit.entity.Player player) Opens the inventory to the player providedvoid
setCloseEvent
(GuiCloseEvent closeEvent) Sets what is executed when the GUI is closedvoid
Sets the name of the GUIvoid
updateItem
(GuiItem newItem) Updates the slot to the item provided (should only be done for live updates)
-
Constructor Details
-
Gui
Creates a gui with a given name and size (rows)- Parameters:
name
- The name of the GUIsize
- The amount of rows within the GUI (max of 6 rows)
-
Gui
Creates a gui with a given name, size (rows), and a background item- Parameters:
name
- The name of the GUIsize
- The amount of rows within the GUI (max of 6 rows)backgroundItem
- The item used by default in all slots, unless replaced
-
-
Method Details
-
getName
Gets the name of the GUI- Returns:
- The name of the GUI
-
getSize
public int getSize()Gets the size (rows) of the GUI- Returns:
- The amount of rows in the GUI
-
getItem
Gets the item at a specified slot in the GUI- Parameters:
slot
- The slot in the GUI- Returns:
- Item at the passed slot
-
getBackgroundItem
public org.bukkit.inventory.ItemStack getBackgroundItem()Gets the background item that is being used in the GUI- Returns:
- Background item used in the GUI
-
getInventory
public org.bukkit.inventory.Inventory getInventory()- Returns:
- The
Inventory
of the GUI
-
getCloseEvent
- Returns:
- What's executed when the GUI is closed
-
setName
Sets the name of the GUI- Parameters:
name
- New name of the GUI
-
addItem
Adds the item to the GUI- Parameters:
item
- The item to add- Throws:
ArrayIndexOutOfBoundsException
- If the slot is out of bounds
-
updateItem
Updates the slot to the item provided (should only be done for live updates)- Parameters:
newItem
- New item- Throws:
ArrayIndexOutOfBoundsException
- If the slot is out of bounds
-
setCloseEvent
Sets what is executed when the GUI is closed- Parameters:
closeEvent
- Action to execute when the GUI is closed
-
openInventory
public void openInventory(org.bukkit.entity.Player player) Opens the inventory to the player provided- Parameters:
player
-Player
to open the inventory to
-