Package xyz.xenondevs.invui.window
Class AbstractWindow
java.lang.Object
xyz.xenondevs.invui.window.AbstractWindow
- Direct Known Subclasses:
AbstractDoubleWindow,AbstractSingleWindow
The abstract base class of all
Window implementations.
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
Nested ClassesModifier and TypeClassDescriptionstatic classAbstractWindow.AbstractBuilder<W extends Window,S extends Window.Builder<W, S>> Builder for aAbstractWindow.Nested classes/interfaces inherited from interface xyz.xenondevs.invui.window.Window
Window.Builder<W extends Window,S extends Window.Builder<W, S>> -
Constructor Summary
ConstructorsConstructorDescriptionAbstractWindow(org.bukkit.entity.Player viewer, xyz.xenondevs.inventoryaccess.component.ComponentWrapper title, int size, boolean closeable) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCloseHandler(@NotNull Runnable closeHandler) Adds a close handler that will be called when this window gets closed.voidaddOpenHandler(@NotNull Runnable openHandler) Adds an open handler that will be called when this window gets opened.voidaddOutsideClickHandler(@NotNull Consumer<@NotNull org.bukkit.event.inventory.InventoryClickEvent> outsideClickHandler) Adds an outside click handler that will be called when a player clicks outside the inventory.voidchangeTitle(@NotNull String title) Changes the title of theInventory.voidchangeTitle(@NotNull net.md_5.bungee.api.chat.BaseComponent[] title) Changes the title of theInventory.voidchangeTitle(@NotNull xyz.xenondevs.inventoryaccess.component.ComponentWrapper title) Changes the title of theInventory.voidclose()Closes the underlyingInventoryfor its viewer.Gets the contentinventoriesassociated with thisWindow.@Nullable org.bukkit.entity.PlayerGets the currentPlayerthat is viewing thisWindowor null of there isn't one.protected abstract Pair<AbstractGui, Integer> getGuiAt(int index) Gets theAbstractGuiat the given index.protected abstract AbstractGui[]getGuis()protected abstract org.bukkit.inventory.Inventory[]Gets theinventoriesassociated with thisWindow.protected Map<Integer, SlotElement> getInvSlotElements(Inventory inventory) protected Map<Integer, SlotElement> getItemSlotElements(Item item) @NotNull StringgetLang()protected abstract SlotElementgetSlotElement(int index) Gets theSlotElementat the given index.@NotNull org.bukkit.entity.PlayerGets the viewer of thisWindow@NotNull UUIDGets the viewer'sUUIDprotected abstract voidhandleClick(org.bukkit.event.inventory.InventoryClickEvent event) Handles a click in theWindow.voidhandleClickEvent(org.bukkit.event.inventory.InventoryClickEvent event) protected abstract voidHandles the closing of theWindow.voidhandleCloseEvent(boolean forceClose) voidhandleCursorCollect(org.bukkit.event.inventory.InventoryClickEvent event) voidhandleDragEvent(org.bukkit.event.inventory.InventoryDragEvent event) voidhandleInventoryUpdate(Inventory inventory) voidhandleItemProviderUpdate(Item item) protected abstract voidhandleItemShift(org.bukkit.event.inventory.InventoryClickEvent event) Handles an item-shift action in theWindow.protected abstract voidHandles the opening of theWindow.voidhandleOpenEvent(org.bukkit.event.inventory.InventoryOpenEvent event) abstract voidhandleViewerDeath(org.bukkit.event.entity.PlayerDeathEvent event) Handles the death of the viewer of theWindow.protected abstract voidInitializes the items in theWindow.booleanGets if the player is able to close theInventory.booleanisOpen()Gets if the viewer is currently viewing thisWindow.voidopen()Shows the window to the player.protected voidopenInventory(@NotNull org.bukkit.entity.Player viewer) protected voidredrawItem(int index) Redraws the currentSlotElementat the given slot index.protected voidredrawItem(int index, SlotElement element, boolean setItem) Redraws theSlotElementat the given index.voidremoveCloseHandler(@NotNull Runnable closeHandler) Removes a close handler that has been added previously.voidremoveOutsideClickHandler(@NotNull Consumer<@NotNull org.bukkit.event.inventory.InventoryClickEvent> outsideClickHandler) Removes an outside click handler that has been added previously.voidsetCloseable(boolean closeable) Sets if the player should be able to close theInventory.voidsetCloseHandlers(@Nullable List<@NotNull Runnable> closeHandlers) Replaces the currently registered close handlers with the given list.protected abstract voidsetInvItem(int slot, org.bukkit.inventory.ItemStack itemStack) Puts the givenItemStackinto the inventory at the given slot.voidsetOpenHandlers(@Nullable List<@NotNull Runnable> openHandlers) Replaces the currently registered open handlers with the given list.voidsetOutsideClickHandlers(@Nullable List<@NotNull Consumer<@NotNull org.bukkit.event.inventory.InventoryClickEvent>> outsideClickHandlers) Replaces the currently registered outside click handlers with the given list.Methods 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
handleSlotElementUpdateMethods inherited from interface xyz.xenondevs.invui.window.Window
getPlayerItems
-
Constructor Details
-
AbstractWindow
public AbstractWindow(org.bukkit.entity.Player viewer, xyz.xenondevs.inventoryaccess.component.ComponentWrapper title, int size, boolean closeable)
-
-
Method Details
-
redrawItem
protected void redrawItem(int index) Redraws the currentSlotElementat the given slot index.- Parameters:
index- The slot index.
-
redrawItem
Redraws theSlotElementat the given index.- Parameters:
index- The slot index.element- TheSlotElementat the index.setItem- Whether theSlotElementwas newly set.
-
handleDragEvent
public void handleDragEvent(org.bukkit.event.inventory.InventoryDragEvent event) -
handleClickEvent
public void handleClickEvent(org.bukkit.event.inventory.InventoryClickEvent event) -
handleCursorCollect
public void handleCursorCollect(org.bukkit.event.inventory.InventoryClickEvent event) -
handleItemProviderUpdate
-
handleInventoryUpdate
-
getItemSlotElements
-
getInvSlotElements
-
open
public void open()Description copied from interface:WindowShows the window to the player. -
openInventory
protected void openInventory(@NotNull @NotNull org.bukkit.entity.Player viewer) -
handleOpenEvent
public void handleOpenEvent(org.bukkit.event.inventory.InventoryOpenEvent event) -
close
public void close()Description copied from interface:WindowCloses the underlyingInventoryfor its viewer. -
handleCloseEvent
public void handleCloseEvent(boolean forceClose) -
changeTitle
public void changeTitle(@NotNull @NotNull xyz.xenondevs.inventoryaccess.component.ComponentWrapper title) Description copied from interface:WindowChanges the title of theInventory.- Specified by:
changeTitlein interfaceWindow- Parameters:
title- The new title
-
changeTitle
public void changeTitle(@NotNull @NotNull net.md_5.bungee.api.chat.BaseComponent[] title) Description copied from interface:WindowChanges the title of theInventory.- Specified by:
changeTitlein interfaceWindow- Parameters:
title- The new title
-
changeTitle
Description copied from interface:WindowChanges the title of theInventory.- Specified by:
changeTitlein interfaceWindow- Parameters:
title- The new title
-
setOpenHandlers
Description copied from interface:WindowReplaces the currently registered open handlers with the given list.- Specified by:
setOpenHandlersin interfaceWindow- Parameters:
openHandlers- The new open handlers
-
addOpenHandler
Description copied from interface:WindowAdds an open handler that will be called when this window gets opened.- Specified by:
addOpenHandlerin interfaceWindow- Parameters:
openHandler- The close handler to add
-
setCloseHandlers
Description copied from interface:WindowReplaces the currently registered close handlers with the given list.- Specified by:
setCloseHandlersin interfaceWindow- Parameters:
closeHandlers- The new close handlers
-
addCloseHandler
Description copied from interface:WindowAdds a close handler that will be called when this window gets closed.- Specified by:
addCloseHandlerin interfaceWindow- Parameters:
closeHandler- The close handler to add
-
removeCloseHandler
Description copied from interface:WindowRemoves a close handler that has been added previously.- Specified by:
removeCloseHandlerin interfaceWindow- Parameters:
closeHandler- The close handler to remove
-
setOutsideClickHandlers
public void setOutsideClickHandlers(@Nullable @Nullable List<@NotNull Consumer<@NotNull org.bukkit.event.inventory.InventoryClickEvent>> outsideClickHandlers) Description copied from interface:WindowReplaces the currently registered outside click handlers with the given list.- Specified by:
setOutsideClickHandlersin interfaceWindow- Parameters:
outsideClickHandlers- The new outside click handlers
-
addOutsideClickHandler
public void addOutsideClickHandler(@NotNull @NotNull Consumer<@NotNull org.bukkit.event.inventory.InventoryClickEvent> outsideClickHandler) Description copied from interface:WindowAdds an outside click handler that will be called when a player clicks outside the inventory.- Specified by:
addOutsideClickHandlerin interfaceWindow- Parameters:
outsideClickHandler- The outside click handler to add
-
removeOutsideClickHandler
public void removeOutsideClickHandler(@NotNull @NotNull Consumer<@NotNull org.bukkit.event.inventory.InventoryClickEvent> outsideClickHandler) Description copied from interface:WindowRemoves an outside click handler that has been added previously.- Specified by:
removeOutsideClickHandlerin interfaceWindow- Parameters:
outsideClickHandler- The outside click handler to remove
-
getCurrentViewer
@Nullable public @Nullable org.bukkit.entity.Player getCurrentViewer()Description copied from interface:WindowGets the currentPlayerthat is viewing thisWindowor null of there isn't one.- Specified by:
getCurrentViewerin interfaceWindow- Returns:
- The current viewer of this
Window(can be null)
-
getViewer
@NotNull public @NotNull org.bukkit.entity.Player getViewer()Description copied from interface:WindowGets the viewer of thisWindow -
getLang
-
getViewerUUID
Description copied from interface:WindowGets the viewer'sUUID- Specified by:
getViewerUUIDin interfaceWindow- Returns:
- The viewer's
UUID
-
isCloseable
public boolean isCloseable()Description copied from interface:WindowGets if the player is able to close theInventory.- Specified by:
isCloseablein interfaceWindow- Returns:
- If the player is able to close the
Inventory.
-
setCloseable
public void setCloseable(boolean closeable) Description copied from interface:WindowSets if the player should be able to close theInventory.- Specified by:
setCloseablein interfaceWindow- Parameters:
closeable- If the player should be able to close theInventory.
-
isOpen
public boolean isOpen()Description copied from interface:WindowGets if the viewer is currently viewing thisWindow. -
setInvItem
protected abstract void setInvItem(int slot, org.bukkit.inventory.ItemStack itemStack) Puts the givenItemStackinto the inventory at the given slot.- Parameters:
slot- The slot to put the item into.itemStack- The item to put into the inventory.
-
getSlotElement
Gets theSlotElementat the given index.- Parameters:
index- The index of the slot.- Returns:
- The
SlotElementat the given index.
-
getGuiAt
Gets theAbstractGuiat the given index.- Parameters:
index- The index of the slot.- Returns:
- The
AbstractGuiit's slot at that slot.
-
getGuis
- Returns:
- The guis displayed with this window.
-
getInventories
protected abstract org.bukkit.inventory.Inventory[] getInventories()Gets theinventoriesassociated with thisWindow.- Returns:
- The inventories associated with this window.
-
getContentInventories
Gets the contentinventoriesassociated with thisWindow. These are not UI inventories, but actual inventories contained inside theGui, such asVirtualInventory- Returns:
- The content inventories associated with this window.
-
initItems
protected abstract void initItems()Initializes the items in theWindow. -
handleOpened
protected abstract void handleOpened()Handles the opening of theWindow. -
handleClosed
protected abstract void handleClosed()Handles the closing of theWindow. -
handleClick
protected abstract void handleClick(org.bukkit.event.inventory.InventoryClickEvent event) Handles a click in theWindow.- Parameters:
event- TheInventoryClickEventthat occurred.
-
handleItemShift
protected abstract void handleItemShift(org.bukkit.event.inventory.InventoryClickEvent event) Handles an item-shift action in theWindow.- Parameters:
event- TheInventoryClickEventthat occurred.
-
handleViewerDeath
public abstract void handleViewerDeath(org.bukkit.event.entity.PlayerDeathEvent event) Handles the death of the viewer of theWindow.- Parameters:
event- ThePlayerDeathEventthat occurred.
-