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:
  • Method Details

    • single

      @NotNull static Window.Builder.Normal.Single single()
      Creates a new Window 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)
      Creates a new normal single Window after configuring a Window Builder with the given Consumer.
      Parameters:
      consumer - The Consumer to configure the Window Builder.
      Returns:
      The new Window.
    • split

      @NotNull static Window.Builder.Normal.Split split()
      Creates a new Window 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)
      Creates a new normal split Window after configuring a Window Builder with the given Consumer.
      Parameters:
      consumer - The Consumer to configure the Window Builder.
      Returns:
      The new Window.
    • merged

      @NotNull static Window.Builder.Normal.Merged merged()
      Creates a new Window 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)
      Creates a new normal merged Window after configuring a Window Builder with the given Consumer.
      Parameters:
      consumer - The Consumer to configure the Window 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 the Inventory.
      Returns:
      If the player is able to close the Inventory.
    • setCloseable

      void setCloseable(boolean closeable)
      Sets if the player should be able to close the Inventory.
      Parameters:
      closeable - If the player should be able to close the Inventory.
    • close

      void close()
      Closes the underlying Inventory for its viewer.
    • isOpen

      boolean isOpen()
      Gets if the viewer is currently viewing this Window.
      Returns:
      If the Window is currently open.
    • changeTitle

      void changeTitle(@NotNull @NotNull xyz.xenondevs.inventoryaccess.component.ComponentWrapper title)
      Changes the title of the Inventory.
      Parameters:
      title - The new title
    • changeTitle

      void changeTitle(@NotNull @NotNull net.md_5.bungee.api.chat.BaseComponent[] title)
      Changes the title of the Inventory.
      Parameters:
      title - The new title
    • changeTitle

      void changeTitle(@NotNull @NotNull String title)
      Changes the title of the Inventory.
      Parameters:
      title - The new title
    • getViewer

      @NotNull @NotNull org.bukkit.entity.Player getViewer()
      Gets the viewer of this Window
      Returns:
      The viewer of this window.
    • getCurrentViewer

      @Nullable @Nullable org.bukkit.entity.Player getCurrentViewer()
      Gets the current Player that is viewing this Window or null of there isn't one.
      Returns:
      The current viewer of this Window (can be null)
    • getViewerUUID

      @NotNull @NotNull UUID getViewerUUID()
      Gets the viewer's UUID
      Returns:
      The viewer's UUID
    • getPlayerItems

      @Nullable @Nullable org.bukkit.inventory.ItemStack @Nullable [] getPlayerItems()
      Gets the contents of the viewer's inventory. This method will always return the actual inventory contents and will not be affected by double windows placing gui items in the Player's inventory.
      Returns:
      The contents of the viewer's inventory, or null if the Window isn't open.
    • setOpenHandlers

      void setOpenHandlers(@Nullable @Nullable List<@NotNull Runnable> openHandlers)
      Replaces the currently registered open handlers with the given list.
      Parameters:
      openHandlers - The new open handlers
    • addOpenHandler

      void addOpenHandler(@NotNull @NotNull Runnable openHandler)
      Adds an open handler that will be called when this window gets opened.
      Parameters:
      openHandler - The close handler to add
    • setCloseHandlers

      void setCloseHandlers(@Nullable @Nullable List<@NotNull Runnable> closeHandlers)
      Replaces the currently registered close handlers with the given list.
      Parameters:
      closeHandlers - The new close handlers
    • addCloseHandler

      void addCloseHandler(@NotNull @NotNull Runnable closeHandler)
      Adds a close handler that will be called when this window gets closed.
      Parameters:
      closeHandler - The close handler to add
    • removeCloseHandler

      void removeCloseHandler(@NotNull @NotNull Runnable closeHandler)
      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