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
Modifier and TypeInterfaceDescriptionstatic interface
Window.Builder<W extends Window,
S extends Window.Builder<W, S>> AWindow
builder. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addCloseHandler
(@NotNull Runnable closeHandler) Adds a close handler that will be called when this window gets closed.void
addOpenHandler
(@NotNull Runnable openHandler) Adds an open handler that will be called when this window gets opened.void
addOutsideClickHandler
(@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.void
changeTitle
(@NotNull String title) Changes the title of theInventory
.void
changeTitle
(@NotNull net.md_5.bungee.api.chat.BaseComponent[] title) Changes the title of theInventory
.void
changeTitle
(@NotNull xyz.xenondevs.inventoryaccess.component.ComponentWrapper title) Changes the title of theInventory
.void
close()
Closes the underlyingInventory
for its viewer.@Nullable org.bukkit.entity.Player
Gets the currentPlayer
that is viewing thisWindow
or null of there isn't one.@Nullable org.bukkit.inventory.ItemStack @Nullable []
Gets the contents of theviewer's
inventory.@NotNull org.bukkit.entity.Player
Gets the viewer of thisWindow
@NotNull UUID
Gets the viewer'sUUID
boolean
Gets if the player is able to close theInventory
.boolean
isOpen()
Gets if the viewer is currently viewing thisWindow
.static Window.Builder.Normal.Merged
merged()
Creates a newWindow Builder
for a normal merged window.static @NotNull Window
merged
(@NotNull Consumer<@NotNull Window.Builder.Normal.Merged> consumer) void
open()
Shows the window to the player.void
removeCloseHandler
(@NotNull Runnable closeHandler) Removes a close handler that has been added previously.void
removeOutsideClickHandler
(@NotNull Consumer<@NotNull org.bukkit.event.inventory.InventoryClickEvent> outsideClickHandler) Removes an outside click handler that has been added previously.void
setCloseable
(boolean closeable) Sets if the player should be able to close theInventory
.void
setCloseHandlers
(@Nullable List<@NotNull Runnable> closeHandlers) Replaces the currently registered close handlers with the given list.void
setOpenHandlers
(@Nullable List<@NotNull Runnable> openHandlers) Replaces the currently registered open handlers with the given list.void
setOutsideClickHandlers
(@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.Single
single()
Creates a newWindow Builder
for a normal single window.static @NotNull Window
single
(@NotNull Consumer<@NotNull Window.Builder.Normal.Single> consumer) static Window.Builder.Normal.Split
split()
Creates a newWindow Builder
for a normal split window.static @NotNull Window
split
(@NotNull Consumer<@NotNull Window.Builder.Normal.Split> consumer)
-
Method Details
-
single
Creates a newWindow Builder
for 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
- TheConsumer
to configure theWindow Builder
.- Returns:
- The new
Window
.
-
split
Creates a newWindow Builder
for 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
- TheConsumer
to configure theWindow Builder
.- Returns:
- The new
Window
.
-
merged
Creates a newWindow Builder
for 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
- TheConsumer
to 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 underlyingInventory
for its viewer. -
isOpen
boolean isOpen()Gets if the viewer is currently viewing thisWindow
.- Returns:
- If the
Window
is 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 currentPlayer
that is viewing thisWindow
or 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'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
.
-
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
-