Class AbstractDoubleWindow

java.lang.Object
xyz.xenondevs.invui.window.AbstractWindow
xyz.xenondevs.invui.window.AbstractDoubleWindow
All Implemented Interfaces:
GuiParent, Window
Direct Known Subclasses:
AbstractMergedWindow, AbstractSplitWindow

public abstract class AbstractDoubleWindow extends AbstractWindow
A Window that uses both top and player Inventory.

Only in very rare circumstances should this class be used directly. Instead, use Window.split() or Window.merged() to create such a Window.

  • Field Details

    • upperInventory

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

    • AbstractDoubleWindow

      public AbstractDoubleWindow(org.bukkit.entity.Player player, xyz.xenondevs.inventoryaccess.component.ComponentWrapper title, int size, org.bukkit.inventory.Inventory upperInventory, boolean closeable)
      Creates a new AbstractDoubleWindow.
      Parameters:
      player - The player that views the window.
      title - The title of the window.
      size - The size of the window.
      upperInventory - The upper 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
    • 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.
    • redrawItem

      protected void redrawItem(int index, SlotElement element, boolean setItem)
      Description copied from class: AbstractWindow
      Redraws the SlotElement at the given index.
      Overrides:
      redrawItem in class AbstractWindow
      Parameters:
      index - The slot index.
      element - The SlotElement at the index.
      setItem - Whether the SlotElement was newly set.
    • 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.
    • setUpperInvItem

      protected void setUpperInvItem(int slot, org.bukkit.inventory.ItemStack itemStack)
      Places an ItemStack into the upper Inventory.
      Parameters:
      slot - The slot in the upper Inventory.
      itemStack - The ItemStack to place.
    • setPlayerInvItem

      protected void setPlayerInvItem(int slot, org.bukkit.inventory.ItemStack itemStack)
      Places an ItemStack into the player Inventory.
      Parameters:
      slot - The slot in the player Inventory.
      itemStack - The ItemStack to place.
    • 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.
    • 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
    • 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.
    • 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.
    • getUpperInventory

      public org.bukkit.inventory.Inventory getUpperInventory()
      Gets the upper Inventory of the window.
      Returns:
      The upper Inventory of the window.
    • getPlayerInventory

      public org.bukkit.inventory.Inventory getPlayerInventory()
      Gets the player Inventory of the window.
      Returns:
      The player Inventory of the window.
    • getWhereClicked

      protected abstract Pair<AbstractGui,Integer> getWhereClicked(org.bukkit.event.inventory.InventoryClickEvent event)
      Gets the AbstractGui and the slot where the player clicked, based on the given InventoryClickEvent.
      Parameters:
      event - The InventoryClickEvent that was triggered.
      Returns:
      The AbstractGui and the slot where the player clicked.