Package xyz.xenondevs.invui.window
Class AbstractDoubleWindow
java.lang.Object
xyz.xenondevs.invui.window.AbstractWindow
xyz.xenondevs.invui.window.AbstractDoubleWindow
- Direct Known Subclasses:
AbstractMergedWindow
,AbstractSplitWindow
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
.
-
Nested Class Summary
Nested classes/interfaces inherited from class xyz.xenondevs.invui.window.AbstractWindow
AbstractWindow.AbstractBuilder<W extends Window,
S extends Window.Builder<W, S>> Nested classes/interfaces inherited from interface xyz.xenondevs.invui.window.Window
Window.Builder<W extends Window,
S extends Window.Builder<W, S>> -
Field Summary
Modifier and TypeFieldDescriptionprotected org.bukkit.inventory.Inventory
The upper inventory of the window. -
Constructor Summary
ConstructorDescriptionAbstractDoubleWindow
(org.bukkit.entity.Player player, xyz.xenondevs.inventoryaccess.component.ComponentWrapper title, int size, org.bukkit.inventory.Inventory upperInventory, boolean closeable) Creates a newAbstractDoubleWindow
. -
Method Summary
Modifier and TypeMethodDescriptionorg.bukkit.inventory.Inventory[]
Gets theinventories
associated with thisWindow
.org.bukkit.inventory.Inventory
Gets the playerInventory
of the window.@Nullable org.bukkit.inventory.ItemStack @Nullable []
Gets the contents of theviewer's
inventory.org.bukkit.inventory.Inventory
Gets the upperInventory
of the window.protected abstract Pair
<AbstractGui, Integer> getWhereClicked
(org.bukkit.event.inventory.InventoryClickEvent event) Gets theAbstractGui
and the slot where the player clicked, based on the givenInventoryClickEvent
.void
handleClick
(org.bukkit.event.inventory.InventoryClickEvent event) Handles a click in theWindow
.protected void
Handles the closing of theWindow
.void
handleItemShift
(org.bukkit.event.inventory.InventoryClickEvent event) Handles an item-shift action in theWindow
.protected void
Handles the opening of theWindow
.void
handleViewerDeath
(org.bukkit.event.entity.PlayerDeathEvent event) Handles the death of the viewer of theWindow
.protected void
Initializes the items in theWindow
.protected void
redrawItem
(int index, SlotElement element, boolean setItem) Redraws theSlotElement
at the given index.protected void
setInvItem
(int slot, org.bukkit.inventory.ItemStack itemStack) Puts the givenItemStack
into the inventory at the given slot.protected void
setPlayerInvItem
(int slot, org.bukkit.inventory.ItemStack itemStack) Places anItemStack
into the playerInventory
.protected void
setUpperInvItem
(int slot, org.bukkit.inventory.ItemStack itemStack) Places anItemStack
into the upperInventory
.Methods inherited from class xyz.xenondevs.invui.window.AbstractWindow
addCloseHandler, addOpenHandler, addOutsideClickHandler, changeTitle, changeTitle, changeTitle, close, getContentInventories, getCurrentViewer, getGuiAt, getGuis, getInvSlotElements, getItemSlotElements, getLang, getSlotElement, getViewer, getViewerUUID, handleClickEvent, handleCloseEvent, handleCursorCollect, handleDragEvent, handleInventoryUpdate, handleItemProviderUpdate, handleOpenEvent, isCloseable, isOpen, open, openInventory, redrawItem, removeCloseHandler, removeOutsideClickHandler, setCloseable, setCloseHandlers, setOpenHandlers, setOutsideClickHandlers
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface xyz.xenondevs.invui.gui.GuiParent
handleSlotElementUpdate
-
Field Details
-
upperInventory
protected org.bukkit.inventory.Inventory upperInventoryThe 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 newAbstractDoubleWindow
.- 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 theWindow
.- Specified by:
initItems
in classAbstractWindow
-
getPlayerItems
@Nullable public @Nullable org.bukkit.inventory.ItemStack @Nullable [] getPlayerItems()Description copied from interface:Window
Gets the contents of theviewer's
inventory. This method will always return the actual inventory contents and will not be affected by double windows placing gui items in thePlayer's
inventory.- Returns:
- The contents of the
viewer's
inventory, or null if theWindow
isn't open
.
-
redrawItem
Description copied from class:AbstractWindow
Redraws theSlotElement
at the given index.- Overrides:
redrawItem
in classAbstractWindow
- Parameters:
index
- The slot index.element
- TheSlotElement
at the index.setItem
- Whether theSlotElement
was newly set.
-
setInvItem
protected void setInvItem(int slot, org.bukkit.inventory.ItemStack itemStack) Description copied from class:AbstractWindow
Puts the givenItemStack
into the inventory at the given slot.- Specified by:
setInvItem
in classAbstractWindow
- 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 anItemStack
into the upperInventory
.- Parameters:
slot
- The slot in the upperInventory
.itemStack
- TheItemStack
to place.
-
setPlayerInvItem
protected void setPlayerInvItem(int slot, org.bukkit.inventory.ItemStack itemStack) Places anItemStack
into the playerInventory
.- Parameters:
slot
- The slot in the playerInventory
.itemStack
- TheItemStack
to place.
-
handleViewerDeath
public void handleViewerDeath(org.bukkit.event.entity.PlayerDeathEvent event) Description copied from class:AbstractWindow
Handles the death of the viewer of theWindow
.- Specified by:
handleViewerDeath
in classAbstractWindow
- Parameters:
event
- ThePlayerDeathEvent
that occurred.
-
handleOpened
protected void handleOpened()Description copied from class:AbstractWindow
Handles the opening of theWindow
.- Specified by:
handleOpened
in classAbstractWindow
-
handleClosed
protected void handleClosed()Description copied from class:AbstractWindow
Handles the closing of theWindow
.- Specified by:
handleClosed
in classAbstractWindow
-
handleClick
public void handleClick(org.bukkit.event.inventory.InventoryClickEvent event) Description copied from class:AbstractWindow
Handles a click in theWindow
.- Specified by:
handleClick
in classAbstractWindow
- Parameters:
event
- TheInventoryClickEvent
that occurred.
-
handleItemShift
public void handleItemShift(org.bukkit.event.inventory.InventoryClickEvent event) Description copied from class:AbstractWindow
Handles an item-shift action in theWindow
.- Specified by:
handleItemShift
in classAbstractWindow
- Parameters:
event
- TheInventoryClickEvent
that occurred.
-
getInventories
public org.bukkit.inventory.Inventory[] getInventories()Description copied from class:AbstractWindow
Gets theinventories
associated with thisWindow
.- Specified by:
getInventories
in classAbstractWindow
- Returns:
- The inventories associated with this window.
-
getUpperInventory
public org.bukkit.inventory.Inventory getUpperInventory()Gets the upperInventory
of the window.- Returns:
- The upper
Inventory
of the window.
-
getPlayerInventory
public org.bukkit.inventory.Inventory getPlayerInventory()Gets the playerInventory
of the window.- Returns:
- The player
Inventory
of the window.
-
getWhereClicked
protected abstract Pair<AbstractGui,Integer> getWhereClicked(org.bukkit.event.inventory.InventoryClickEvent event) Gets theAbstractGui
and the slot where the player clicked, based on the givenInventoryClickEvent
.- Parameters:
event
- TheInventoryClickEvent
that was triggered.- Returns:
- The
AbstractGui
and the slot where the player clicked.
-