Package xyz.xenondevs.invui.window
Class AbstractSingleWindow
java.lang.Object
xyz.xenondevs.invui.window.AbstractWindow
xyz.xenondevs.invui.window.AbstractSingleWindow
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()
.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
AbstractSingleWindow.AbstractBuilder<W extends Window,
S extends Window.Builder.Single<W, S>> Builder for aAbstractSingleWindow
.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
TheInventory
of the window. -
Constructor Summary
ConstructorDescriptionAbstractSingleWindow
(org.bukkit.entity.Player viewer, xyz.xenondevs.inventoryaccess.component.ComponentWrapper title, AbstractGui gui, org.bukkit.inventory.Inventory inventory, boolean closeable) Creates a newAbstractSingleWindow
. -
Method Summary
Modifier and TypeMethodDescriptionGets the contentinventories
associated with thisWindow
.getGui()
Gets theGui
used for thisAbstractSingleWindow
.protected Pair
<AbstractGui, Integer> getGuiAt
(int index) Gets theAbstractGui
at the given index.getGuis()
org.bukkit.inventory.Inventory[]
Gets theinventories
associated with thisWindow
.@Nullable org.bukkit.inventory.ItemStack @Nullable []
Gets the contents of theviewer's
inventory.protected SlotElement
getSlotElement
(int index) Gets theSlotElement
at the given index.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
handleSlotElementUpdate
(Gui child, int slotIndex) Called by the childGui
to report an update of aSlotElement
.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
setInvItem
(int slot, org.bukkit.inventory.ItemStack itemStack) Puts the givenItemStack
into the inventory at the given slot.Methods inherited from class xyz.xenondevs.invui.window.AbstractWindow
addCloseHandler, addOpenHandler, addOutsideClickHandler, changeTitle, changeTitle, changeTitle, close, getCurrentViewer, getInvSlotElements, getItemSlotElements, getLang, getViewer, getViewerUUID, handleClickEvent, handleCloseEvent, handleCursorCollect, handleDragEvent, handleInventoryUpdate, handleItemProviderUpdate, handleOpenEvent, isCloseable, isOpen, open, openInventory, redrawItem, redrawItem, removeCloseHandler, removeOutsideClickHandler, setCloseable, setCloseHandlers, setOpenHandlers, setOutsideClickHandlers
-
Field Details
-
inventory
protected org.bukkit.inventory.Inventory inventoryTheInventory
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 newAbstractSingleWindow
.- 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 theWindow
.- Specified by:
initItems
in classAbstractWindow
-
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.
-
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
-
handleSlotElementUpdate
Description copied from interface:GuiParent
Called by the childGui
to report an update of aSlotElement
.- Parameters:
child
- The childGui
whoseSlotElement
has changedslotIndex
- The slot index of the changedSlotElement
in the childGui
-
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.
-
getContentInventories
Description copied from class:AbstractWindow
Gets the contentinventories
associated with thisWindow
. These are not UI inventories, but actual inventories contained inside theGui
, such asVirtualInventory
- Specified by:
getContentInventories
in classAbstractWindow
- Returns:
- The content inventories associated with this window.
-
getGuiAt
Description copied from class:AbstractWindow
Gets theAbstractGui
at the given index.- Specified by:
getGuiAt
in classAbstractWindow
- Parameters:
index
- The index of the slot.- Returns:
- The
AbstractGui
it's slot at that slot.
-
getSlotElement
Description copied from class:AbstractWindow
Gets theSlotElement
at the given index.- Specified by:
getSlotElement
in classAbstractWindow
- 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 theWindow
.- Specified by:
handleViewerDeath
in classAbstractWindow
- Parameters:
event
- ThePlayerDeathEvent
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.
-
getGuis
Description copied from class:AbstractWindow
- Specified by:
getGuis
in classAbstractWindow
- Returns:
- The guis displayed with this window.
-
getGui
Gets theGui
used for thisAbstractSingleWindow
.- Returns:
- The
Gui
used for thisAbstractSingleWindow
.
-
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
.
-