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
FieldsModifier and TypeFieldDescriptionprotected org.bukkit.inventory.InventoryThe upper inventory of the window. -
Constructor Summary
ConstructorsConstructorDescriptionAbstractDoubleWindow(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 theinventoriesassociated with thisWindow.org.bukkit.inventory.InventoryGets the playerInventoryof the window.@Nullable org.bukkit.inventory.ItemStack @Nullable []Gets the contents of theviewer'sinventory.org.bukkit.inventory.InventoryGets the upperInventoryof the window.protected abstract Pair<AbstractGui, Integer> getWhereClicked(org.bukkit.event.inventory.InventoryClickEvent event) Gets theAbstractGuiand the slot where the player clicked, based on the givenInventoryClickEvent.voidhandleClick(org.bukkit.event.inventory.InventoryClickEvent event) Handles a click in theWindow.protected voidHandles the closing of theWindow.voidhandleItemShift(org.bukkit.event.inventory.InventoryClickEvent event) Handles an item-shift action in theWindow.protected voidHandles the opening of theWindow.voidhandleViewerDeath(org.bukkit.event.entity.PlayerDeathEvent event) Handles the death of the viewer of theWindow.protected voidInitializes the items in theWindow.protected voidredrawItem(int index, SlotElement element, boolean setItem) Redraws theSlotElementat the given index.protected voidsetInvItem(int slot, org.bukkit.inventory.ItemStack itemStack) Puts the givenItemStackinto the inventory at the given slot.protected voidsetPlayerInvItem(int slot, org.bukkit.inventory.ItemStack itemStack) Places anItemStackinto the playerInventory.protected voidsetUpperInvItem(int slot, org.bukkit.inventory.ItemStack itemStack) Places anItemStackinto 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, setOutsideClickHandlersMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:AbstractWindowInitializes the items in theWindow.- Specified by:
initItemsin classAbstractWindow
-
getPlayerItems
@Nullable public @Nullable org.bukkit.inventory.ItemStack @Nullable [] getPlayerItems()Description copied from interface:WindowGets the contents of theviewer'sinventory. This method will always return the actual inventory contents and will not be affected by double windows placing gui items in thePlayer'sinventory.- Returns:
- The contents of the
viewer'sinventory, or null if theWindowisn't open.
-
redrawItem
Description copied from class:AbstractWindowRedraws theSlotElementat the given index.- Overrides:
redrawItemin classAbstractWindow- Parameters:
index- The slot index.element- TheSlotElementat the index.setItem- Whether theSlotElementwas newly set.
-
setInvItem
protected void setInvItem(int slot, org.bukkit.inventory.ItemStack itemStack) Description copied from class:AbstractWindowPuts the givenItemStackinto the inventory at the given slot.- Specified by:
setInvItemin 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 anItemStackinto the upperInventory.- Parameters:
slot- The slot in the upperInventory.itemStack- TheItemStackto place.
-
setPlayerInvItem
protected void setPlayerInvItem(int slot, org.bukkit.inventory.ItemStack itemStack) Places anItemStackinto the playerInventory.- Parameters:
slot- The slot in the playerInventory.itemStack- TheItemStackto place.
-
handleViewerDeath
public void handleViewerDeath(org.bukkit.event.entity.PlayerDeathEvent event) Description copied from class:AbstractWindowHandles the death of the viewer of theWindow.- Specified by:
handleViewerDeathin classAbstractWindow- Parameters:
event- ThePlayerDeathEventthat occurred.
-
handleOpened
protected void handleOpened()Description copied from class:AbstractWindowHandles the opening of theWindow.- Specified by:
handleOpenedin classAbstractWindow
-
handleClosed
protected void handleClosed()Description copied from class:AbstractWindowHandles the closing of theWindow.- Specified by:
handleClosedin classAbstractWindow
-
handleClick
public void handleClick(org.bukkit.event.inventory.InventoryClickEvent event) Description copied from class:AbstractWindowHandles a click in theWindow.- Specified by:
handleClickin classAbstractWindow- Parameters:
event- TheInventoryClickEventthat occurred.
-
handleItemShift
public void handleItemShift(org.bukkit.event.inventory.InventoryClickEvent event) Description copied from class:AbstractWindowHandles an item-shift action in theWindow.- Specified by:
handleItemShiftin classAbstractWindow- Parameters:
event- TheInventoryClickEventthat occurred.
-
getInventories
public org.bukkit.inventory.Inventory[] getInventories()Description copied from class:AbstractWindowGets theinventoriesassociated with thisWindow.- Specified by:
getInventoriesin classAbstractWindow- Returns:
- The inventories associated with this window.
-
getUpperInventory
public org.bukkit.inventory.Inventory getUpperInventory()Gets the upperInventoryof the window.- Returns:
- The upper
Inventoryof the window.
-
getPlayerInventory
public org.bukkit.inventory.Inventory getPlayerInventory()Gets the playerInventoryof the window.- Returns:
- The player
Inventoryof the window.
-
getWhereClicked
protected abstract Pair<AbstractGui,Integer> getWhereClicked(org.bukkit.event.inventory.InventoryClickEvent event) Gets theAbstractGuiand the slot where the player clicked, based on the givenInventoryClickEvent.- Parameters:
event- TheInventoryClickEventthat was triggered.- Returns:
- The
AbstractGuiand the slot where the player clicked.
-