Interface Gui

All Known Subinterfaces:
PagedGui<C>, ScrollGui<C>, TabGui
All Known Implementing Classes:
AbstractGui, AbstractPagedGui, AbstractScrollGui, AbstractTabGui

public interface Gui
A Gui is a container for width * height SlotElements.
Each SlotElement can either be an Item, a reference to a Inventory's or another Gui's slot index.
A Gui is not an Inventory, nor does it access one. It just contains SlotElements and their positions.
In order to create an Inventory which is visible to players, you will need to use a Window.
See Also:
  • Method Details

    • normal

      @NotNull static Gui.Builder.Normal normal()
      Creates a new Gui Builder for a normal Gui.
      Returns:
      The new Gui Builder.
    • normal

      @NotNull static @NotNull Gui normal(@NotNull @NotNull Consumer<@NotNull Gui.Builder.Normal> consumer)
      Creates a new normal Gui after configuring a Gui Builder with the given Consumer.
      Parameters:
      consumer - The Consumer to configure the Gui Builder.
      Returns:
      The created Gui.
    • empty

      @NotNull static @NotNull Gui empty(int width, int height)
      Creates a new empty Gui.
      Parameters:
      width - The width of the Gui.
      height - The height of the Gui.
      Returns:
      The created Gui.
    • of

      @NotNull static @NotNull Gui of(@NotNull @NotNull Structure structure)
      Creates a new empty Gui.
      Parameters:
      structure - The Structure of the Gui.
      Returns:
      The created Gui.
    • getSize

      int getSize()
      Gets the size of the Gui.
      Returns:
      The size of the gui.
    • getWidth

      int getWidth()
      Gets the width of the Gui
      Returns:
      The width of the Gui
    • getHeight

      int getHeight()
      Gets the height of the Gui
      Returns:
      The height of the Gui
    • setSlotElement

      void setSlotElement(int x, int y, @Nullable @Nullable SlotElement slotElement)
      Sets the SlotElement on these coordinates. If you need to set an Item, please use setItem(int, int, Item) instead.
      Parameters:
      x - The x coordinate
      y - The y coordinate
      slotElement - The SlotElement to be placed there.
    • setSlotElement

      void setSlotElement(int index, @Nullable @Nullable SlotElement slotElement)
      Sets the SlotElement on these coordinates. If you need to set an Item, please use setItem(int, Item) instead.
      Parameters:
      index - The slot index
      slotElement - The SlotElement to be placed there.
    • addSlotElements

      void addSlotElements(@NotNull @NotNull SlotElement... slotElements)
      Adds SlotElements to the Gui.
      Parameters:
      slotElements - The SlotElements to add.
    • getSlotElement

      @Nullable @Nullable SlotElement getSlotElement(int x, int y)
      Gets the SlotElement on these coordinates.
      Parameters:
      x - The x coordinate
      y - The y coordinate
      Returns:
      The SlotElement placed there
    • getSlotElement

      @Nullable @Nullable SlotElement getSlotElement(int index)
      Gets the SlotElement placed on that slot.
      Parameters:
      index - The slot index
      Returns:
      The SlotElement placed on that slot
    • hasSlotElement

      boolean hasSlotElement(int x, int y)
      Gets if there is a SlotElement on these coordinates.
      Parameters:
      x - The x coordinate
      y - The y coordinate
      Returns:
      If there is a SlotElement placed there
    • hasSlotElement

      boolean hasSlotElement(int index)
      Gets if there is a SlotElement placed on that slot.
      Parameters:
      index - The slot index
      Returns:
      If there is a SlotElement placed there
    • getSlotElements

      @Nullable @Nullable SlotElement @NotNull [] getSlotElements()
      Gets all SlotElements of this Gui in an Array.
      Returns:
      All SlotElements of this Gui
    • setItem

      void setItem(int x, int y, @Nullable @Nullable Item item)
      Sets the Item on these coordinates.
      Parameters:
      x - The x coordinate
      y - The y coordinate
      item - The Item that should be placed on these coordinates or null to remove the Item that is currently there.
    • setItem

      void setItem(int index, @Nullable @Nullable Item item)
      Sets the Item on that slot
      Parameters:
      index - The slot index
      item - The Item that should be placed on that slot or null to remove the Item that is currently there.
    • addItems

      void addItems(@NotNull @NotNull Item... items)
      Adds Items to the gui.
      Parameters:
      items - The Items that should be added to the gui
    • getItem

      @Nullable @Nullable Item getItem(int x, int y)
      Gets the Item on these coordinates.
      Parameters:
      x - The x coordinate
      y - The y coordinate
      Returns:
      The Item which is placed on that slot or null if there isn't one
    • getItem

      @Nullable @Nullable Item getItem(int index)
      Gets the Item placed on that slot.
      Parameters:
      index - The slot index
      Returns:
      The Item which is placed on that slot or null if there isn't one
    • getBackground

      @Nullable @Nullable ItemProvider getBackground()
      Gets the ItemProvider that will be used if nothing else is placed on a slot.
      Returns:
      The ItemProvider
    • setBackground

      void setBackground(@Nullable @Nullable ItemProvider itemProvider)
      Sets the ItemProvider that will be used if nothing else is placed on a slot.
      Parameters:
      itemProvider - The ItemProvider
    • remove

      void remove(int x, int y)
      Removes an Item by its coordinates.
      Parameters:
      x - The x coordinate
      y - The y coordinate
    • remove

      void remove(int index)
      Remove the Item which are placed on these slots.
      Parameters:
      index - The slot index of the Items that should be removed
    • applyStructure

      void applyStructure(@NotNull @NotNull Structure structure)
      Applies the given Structure to the Gui.
      Parameters:
      structure - The structure
    • findAllWindows

      @NotNull @NotNull List<@NotNull Window> findAllWindows()
      Finds all Windows that show this Gui.
      Returns:
      The list of Window that show this Gui
    • findAllCurrentViewers

      @NotNull @NotNull Set<@NotNull org.bukkit.entity.Player> findAllCurrentViewers()
      Finds all Players that are currently seeing this Window.
      Returns:
      The list of Players that are currently seeing this Window
    • closeForAllViewers

      void closeForAllViewers()
      Closes the open Inventory for all viewers of Windows where this Gui is displayed.

      If the Windows are not marked as "retain", they will be removed from the WindowManager automatically.

    • playAnimation

      void playAnimation(@NotNull @NotNull Animation animation, @Nullable @Nullable Predicate<@NotNull SlotElement> filter)
      Plays an Animation.
      Parameters:
      animation - The Animation to play.
      filter - The filter that selects which SlotElements should be animated.
    • cancelAnimation

      void cancelAnimation()
      Cancels the running Animation if there is one.
    • setFrozen

      void setFrozen(boolean frozen)
      Freezes or unfreezes the Gui. A frozen Gui will not allow any clicks.
      Parameters:
      frozen - If the Gui should be frozen or not.
    • isFrozen

      boolean isFrozen()
      Gets if the Gui is frozen.
      Returns:
      If the Gui is frozen.
    • setIgnoreObscuredInventorySlots

      void setIgnoreObscuredInventorySlots(boolean ignoreObscuredInventorySlots)
      Configures whether it is possible to shift-click items into and cursor collect items from all Inventory slots of partially obscured embedded Inventories.

      Defaults to true.

      Parameters:
      ignoreObscuredInventorySlots - Whether obscured Inventory slots should be ignored when shift-clicking and collecting to the cursor.
    • isIgnoreObscuredInventorySlots

      boolean isIgnoreObscuredInventorySlots()
      Gets whether it is possible to shift-click items into and cursor collect items from all Inventory slots of partially obscured embedded Inventories.
      Returns:
      Whether obscured Inventory slots are ignored when shift-clicking and collecting to the cursor.
    • fill

      void fill(int start, int end, @Nullable @Nullable Item item, boolean replaceExisting)
      Fills the Gui with Items.
      Parameters:
      start - The start index of the fill (inclusive)
      end - The end index of the fill (exclusive)
      item - The Item that should be used or null to remove an existing item.
      replaceExisting - If existing Items should be replaced.
    • fill

      void fill(@Nullable @Nullable Item item, boolean replaceExisting)
      Fills the entire Gui with Items.
      Parameters:
      item - The Item that should be used or null to remove an existing item.
      replaceExisting - If existing Items should be replaced.
    • fillRow

      void fillRow(int row, @Nullable @Nullable Item item, boolean replaceExisting)
      Fills one row with a specific Item
      Parameters:
      row - The row
      item - The Item that should be used or null to remove an existing item.
      replaceExisting - If existing Items should be replaced.
    • fillColumn

      void fillColumn(int column, @Nullable @Nullable Item item, boolean replaceExisting)
      Fills one column with a specific Item
      Parameters:
      column - The column
      item - The Item that should be used or null to remove an existing item.
      replaceExisting - If existing Items should be replaced.
    • fillBorders

      void fillBorders(@Nullable @Nullable Item item, boolean replaceExisting)
      Fills the borders of this Gui with a specific Item
      Parameters:
      item - The Item that should be used or null to remove an existing item.
      replaceExisting - If existing Items should be replaced.
    • fillRectangle

      void fillRectangle(int x, int y, int width, int height, @Nullable @Nullable Item item, boolean replaceExisting)
      Fills a rectangle in this Gui with a specific Item
      Parameters:
      x - The x coordinate where the rectangle should start.
      y - The y coordinate where the rectangle should start.
      width - The width of the rectangle.
      height - The height of the rectangle
      item - The Item that should be used or null to remove an existing item.
      replaceExisting - If existing Items should be replaced.
    • fillRectangle

      void fillRectangle(int x, int y, @NotNull @NotNull Gui gui, boolean replaceExisting)
      Fills a rectangle with another Gui in this Gui.
      Parameters:
      x - The x coordinate where the rectangle should start
      y - The y coordinate where the rectangle should start
      gui - The Gui to be put into this Gui
      replaceExisting - If existing SlotElements should be replaced.
    • fillRectangle

      void fillRectangle(int x, int y, int width, @NotNull @NotNull Inventory inventory, boolean replaceExisting)
      Fills a rectangle with a Inventory in this Gui.
      Parameters:
      x - The x coordinate where the rectangle should start
      y - The y coordinate where the rectangle should start
      width - The line length of the rectangle.
      inventory - The Inventory to be put into this Gui.
      replaceExisting - If existing SlotElements should be replaced.
    • fillRectangle

      void fillRectangle(int x, int y, int width, @NotNull @NotNull Inventory inventory, @Nullable @Nullable ItemProvider background, boolean replaceExisting)
      Fills a rectangle with a Inventory in this Gui.
      Parameters:
      x - The x coordinate where the rectangle should start
      y - The y coordinate where the rectangle should start
      width - The line length of the rectangle.
      inventory - The Inventory to be put into this Gui.
      background - The ItemProvider for empty slots of the Inventory
      replaceExisting - If existing SlotElements should be replaced.