Package xyz.xenondevs.invui.window
Interface Window
- All Known Subinterfaces:
AnvilWindow,CartographyWindow
- All Known Implementing Classes:
AbstractDoubleWindow,AbstractMergedWindow,AbstractSingleWindow,AbstractSplitWindow,AbstractWindow
public interface Window
A Window is the way to show a player a
Gui. Windows can only have one viewer.
To create a new Window, use the builder factory methods single(),
split() and merged().- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceWindow.Builder<W extends Window,S extends Window.Builder<W, S>> AWindowbuilder. -
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.@Nullable org.bukkit.entity.PlayerGets the currentPlayerthat is viewing thisWindowor null of there isn't one.@Nullable org.bukkit.inventory.ItemStack @Nullable []Gets the contents of theviewer'sinventory.@NotNull org.bukkit.entity.PlayerGets the viewer of thisWindow@NotNull UUIDGets the viewer'sUUIDbooleanGets if the player is able to close theInventory.booleanisOpen()Gets if the viewer is currently viewing thisWindow.static Window.Builder.Normal.Mergedmerged()Creates a newWindow Builderfor a normal merged window.static @NotNull Windowmerged(@NotNull Consumer<@NotNull Window.Builder.Normal.Merged> consumer) voidopen()Shows the window to the player.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.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.static Window.Builder.Normal.Singlesingle()Creates a newWindow Builderfor a normal single window.static @NotNull Windowsingle(@NotNull Consumer<@NotNull Window.Builder.Normal.Single> consumer) static Window.Builder.Normal.Splitsplit()Creates a newWindow Builderfor a normal split window.static @NotNull Windowsplit(@NotNull Consumer<@NotNull Window.Builder.Normal.Split> consumer)
-
Method Details
-
single
Creates a newWindow Builderfor a normal single window.- Returns:
- The new
Window Builder.
-
single
@NotNull static @NotNull Window single(@NotNull @NotNull Consumer<@NotNull Window.Builder.Normal.Single> consumer) - Parameters:
consumer- TheConsumerto configure theWindow Builder.- Returns:
- The new
Window.
-
split
Creates a newWindow Builderfor a normal split window.- Returns:
- The new
Window Builder.
-
split
@NotNull static @NotNull Window split(@NotNull @NotNull Consumer<@NotNull Window.Builder.Normal.Split> consumer) - Parameters:
consumer- TheConsumerto configure theWindow Builder.- Returns:
- The new
Window.
-
merged
Creates a newWindow Builderfor a normal merged window.- Returns:
- The new
Window Builder.
-
merged
@NotNull static @NotNull Window merged(@NotNull @NotNull Consumer<@NotNull Window.Builder.Normal.Merged> consumer) - Parameters:
consumer- TheConsumerto configure theWindow Builder.- Returns:
- The new
Window.
-
open
void open()Shows the window to the player. -
isCloseable
boolean isCloseable()Gets if the player is able to close theInventory.- Returns:
- If the player is able to close the
Inventory.
-
setCloseable
void setCloseable(boolean closeable) Sets if the player should be able to close theInventory.- Parameters:
closeable- If the player should be able to close theInventory.
-
close
void close()Closes the underlyingInventoryfor its viewer. -
isOpen
boolean isOpen()Gets if the viewer is currently viewing thisWindow.- Returns:
- If the
Windowis currently open.
-
changeTitle
void changeTitle(@NotNull @NotNull xyz.xenondevs.inventoryaccess.component.ComponentWrapper title) Changes the title of theInventory.- Parameters:
title- The new title
-
changeTitle
void changeTitle(@NotNull @NotNull net.md_5.bungee.api.chat.BaseComponent[] title) Changes the title of theInventory.- Parameters:
title- The new title
-
changeTitle
Changes the title of theInventory.- Parameters:
title- The new title
-
getViewer
@NotNull @NotNull org.bukkit.entity.Player getViewer()Gets the viewer of thisWindow- Returns:
- The viewer of this window.
-
getCurrentViewer
@Nullable @Nullable org.bukkit.entity.Player getCurrentViewer()Gets the currentPlayerthat is viewing thisWindowor null of there isn't one.- Returns:
- The current viewer of this
Window(can be null)
-
getViewerUUID
Gets the viewer'sUUID- Returns:
- The viewer's
UUID
-
getPlayerItems
@Nullable @Nullable org.bukkit.inventory.ItemStack @Nullable [] getPlayerItems()Gets 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.
-
setOpenHandlers
Replaces the currently registered open handlers with the given list.- Parameters:
openHandlers- The new open handlers
-
addOpenHandler
Adds an open handler that will be called when this window gets opened.- Parameters:
openHandler- The close handler to add
-
setCloseHandlers
Replaces the currently registered close handlers with the given list.- Parameters:
closeHandlers- The new close handlers
-
addCloseHandler
Adds a close handler that will be called when this window gets closed.- Parameters:
closeHandler- The close handler to add
-
removeCloseHandler
Removes a close handler that has been added previously.- Parameters:
closeHandler- The close handler to remove
-
setOutsideClickHandlers
void setOutsideClickHandlers(@Nullable @Nullable List<@NotNull Consumer<@NotNull org.bukkit.event.inventory.InventoryClickEvent>> outsideClickHandlers) Replaces the currently registered outside click handlers with the given list.- Parameters:
outsideClickHandlers- The new outside click handlers
-
addOutsideClickHandler
void addOutsideClickHandler(@NotNull @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.- Parameters:
outsideClickHandler- The outside click handler to add
-
removeOutsideClickHandler
void removeOutsideClickHandler(@NotNull @NotNull Consumer<@NotNull org.bukkit.event.inventory.InventoryClickEvent> outsideClickHandler) Removes an outside click handler that has been added previously.- Parameters:
outsideClickHandler- The outside click handler to remove
-