Class Window

java.lang.Object
Kyu.GuiAPI_Redone.Window.Openable
Kyu.GuiAPI_Redone.Window.Window
All Implemented Interfaces:
org.bukkit.inventory.InventoryHolder
Direct Known Subclasses:
ChestWindow

public abstract class Window extends Openable implements org.bukkit.inventory.InventoryHolder
  • Constructor Details

    • Window

      public Window(GUI gui, String title)
      Creates a new window to be used in a gui
      Parameters:
      gui - The GUI to use
      title - The title of the Window (will be color translated)
  • Method Details

    • clearItems

      public void clearItems()
      Clears the inventory of all items
    • addItem

      public void addItem(GuiItem item)
      Add a GuiItem to the Inventory, it will find the nearest free slot and place it there
      Parameters:
      item - The item to add
    • setItem

      public void setItem(GuiItem item, int slot)
      Same as addItem(GuiItem) but accepts a Slot

      If the slot is used, it will override the item

      Parameters:
      item - The item to add
      slot - The slot to place it in
      Throws:
      SlotOufOfBoundsException - if the slot is less than 0 or greater than the inventory size
    • set

      protected abstract void set(GuiItem item, int slot)
    • removeItem

      public void removeItem(int slot)
      Removes the item from the provided slot
      Parameters:
      slot - Slot to remove the item from
    • getInventory

      public org.bukkit.inventory.Inventory getInventory()
      Specified by:
      getInventory in interface org.bukkit.inventory.InventoryHolder
      Returns:
      The inventory of the window that will be shown to the player when using GUI.openWindow(Window)
    • getItems

      public Map<Integer,GuiItem> getItems()
      Returns:
      A list of GuiItem placed in the Inventory
    • getItem

      public GuiItem getItem(int slot)
      Get a GuiItem from a specific slot
      Parameters:
      slot - the slot to get the item from
      Returns:
      the GuiItem from that slot or Null if slot is empty
    • getTitle

      public String getTitle()
      Returns:
      Title of the Window
    • refreshInventory

      public void refreshInventory()
      Refreshes the Inventory
    • setInventory

      protected void setInventory(org.bukkit.inventory.Inventory inv)
    • getNextFreeSlot

      protected int getNextFreeSlot()