Class AbstractSingleWindow

java.lang.Object
xyz.xenondevs.invui.window.AbstractWindow
xyz.xenondevs.invui.window.AbstractSingleWindow
All Implemented Interfaces:
GuiParent, Window

public abstract class AbstractSingleWindow extends AbstractWindow
A Window that just uses the top Inventory.

Only in very rare circumstances should this class be used directly. Instead, use the static builder functions in the Window interfaces to create a new Window, such as Window.single().

  • Field Details

    • inventory

      protected org.bukkit.inventory.Inventory inventory
      The Inventory of the window.
  • Constructor Details

    • AbstractSingleWindow

      public AbstractSingleWindow(org.bukkit.entity.Player viewer, xyz.xenondevs.inventoryaccess.component.ComponentWrapper title, AbstractGui gui, org.bukkit.inventory.Inventory inventory, boolean closeable)
      Creates a new AbstractSingleWindow.
      Parameters:
      viewer - The player that views the window.
      title - The title of the window.
      gui - The gui of the window.
      inventory - The inventory of the window.
      closeable - Whether the window is closeable.
  • Method Details

    • initItems

      protected void initItems()
      Description copied from class: AbstractWindow
      Initializes the items in the Window.
      Specified by:
      initItems in class AbstractWindow
    • setInvItem

      protected void setInvItem(int slot, org.bukkit.inventory.ItemStack itemStack)
      Description copied from class: AbstractWindow
      Puts the given ItemStack into the inventory at the given slot.
      Specified by:
      setInvItem in class AbstractWindow
      Parameters:
      slot - The slot to put the item into.
      itemStack - The item to put into the inventory.
    • handleOpened

      protected void handleOpened()
      Description copied from class: AbstractWindow
      Handles the opening of the Window.
      Specified by:
      handleOpened in class AbstractWindow
    • handleClosed

      protected void handleClosed()
      Description copied from class: AbstractWindow
      Handles the closing of the Window.
      Specified by:
      handleClosed in class AbstractWindow
    • handleSlotElementUpdate

      public void handleSlotElementUpdate(Gui child, int slotIndex)
      Description copied from interface: GuiParent
      Called by the child Gui to report an update of a SlotElement.
      Parameters:
      child - The child Gui whose SlotElement has changed
      slotIndex - The slot index of the changed SlotElement in the child Gui
    • handleClick

      public void handleClick(org.bukkit.event.inventory.InventoryClickEvent event)
      Description copied from class: AbstractWindow
      Handles a click in the Window.
      Specified by:
      handleClick in class AbstractWindow
      Parameters:
      event - The InventoryClickEvent that occurred.
    • handleItemShift

      public void handleItemShift(org.bukkit.event.inventory.InventoryClickEvent event)
      Description copied from class: AbstractWindow
      Handles an item-shift action in the Window.
      Specified by:
      handleItemShift in class AbstractWindow
      Parameters:
      event - The InventoryClickEvent that occurred.
    • getContentInventories

      protected List<Inventory> getContentInventories()
      Description copied from class: AbstractWindow
      Gets the content inventories associated with this Window. These are not UI inventories, but actual inventories contained inside the Gui, such as VirtualInventory
      Specified by:
      getContentInventories in class AbstractWindow
      Returns:
      The content inventories associated with this window.
    • getGuiAt

      protected Pair<AbstractGui,Integer> getGuiAt(int index)
      Description copied from class: AbstractWindow
      Gets the AbstractGui at the given index.
      Specified by:
      getGuiAt in class AbstractWindow
      Parameters:
      index - The index of the slot.
      Returns:
      The AbstractGui it's slot at that slot.
    • getSlotElement

      protected SlotElement getSlotElement(int index)
      Description copied from class: AbstractWindow
      Gets the SlotElement at the given index.
      Specified by:
      getSlotElement in class AbstractWindow
      Parameters:
      index - The index of the slot.
      Returns:
      The SlotElement at the given index.
    • handleViewerDeath

      public void handleViewerDeath(org.bukkit.event.entity.PlayerDeathEvent event)
      Description copied from class: AbstractWindow
      Handles the death of the viewer of the Window.
      Specified by:
      handleViewerDeath in class AbstractWindow
      Parameters:
      event - The PlayerDeathEvent that occurred.
    • getInventories

      public org.bukkit.inventory.Inventory[] getInventories()
      Description copied from class: AbstractWindow
      Gets the inventories associated with this Window.
      Specified by:
      getInventories in class AbstractWindow
      Returns:
      The inventories associated with this window.
    • getGuis

      public AbstractGui[] getGuis()
      Description copied from class: AbstractWindow
      Gets the guis displayed with this Window, does not contain the guis embedded in other guis.
      Specified by:
      getGuis in class AbstractWindow
      Returns:
      The guis displayed with this window.
    • getGui

      public AbstractGui getGui()
      Gets the Gui used for this AbstractSingleWindow.
      Returns:
      The Gui used for this AbstractSingleWindow.
    • getPlayerItems

      @Nullable public @Nullable org.bukkit.inventory.ItemStack @Nullable [] getPlayerItems()
      Description copied from interface: Window
      Gets the contents of the viewer's inventory. This method will always return the actual inventory contents and will not be affected by double windows placing gui items in the Player's inventory.
      Returns:
      The contents of the viewer's inventory, or null if the Window isn't open.