java.lang.Object
com.github.cyberryan1.cybercore.spigot.gui.Gui

public class Gui extends Object
This is what is mainly used by others to create GUIs, edit their contents, and open them to players
  • Constructor Details

    • Gui

      public Gui(String name, int size)
      Creates a gui with a given name and size (rows)
      Parameters:
      name - The name of the GUI
      size - The amount of rows within the GUI (max of 6 rows)
    • Gui

      public Gui(String name, int size, org.bukkit.inventory.ItemStack backgroundItem)
      Creates a gui with a given name, size (rows), and a background item
      Parameters:
      name - The name of the GUI
      size - 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

      public String 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

      public GuiItem getItem(int slot)
      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

      public GuiCloseEvent getCloseEvent()
      Returns:
      What's executed when the GUI is closed
    • setName

      public void setName(String name)
      Sets the name of the GUI
      Parameters:
      name - New name of the GUI
    • addItem

      public void addItem(GuiItem item)
      Adds the item to the GUI
      Parameters:
      item - The item to add
      Throws:
      ArrayIndexOutOfBoundsException - If the slot is out of bounds
    • updateItem

      public void updateItem(GuiItem newItem)
      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

      public void setCloseEvent(GuiCloseEvent closeEvent)
      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