Class AbstractScrollGui<C>

java.lang.Object
xyz.xenondevs.invui.gui.AbstractGui
xyz.xenondevs.invui.gui.AbstractScrollGui<C>
Type Parameters:
C - The content type.
All Implemented Interfaces:
Gui, GuiParent, ScrollGui<C>

public abstract class AbstractScrollGui<C> extends AbstractGui implements ScrollGui<C>
A scrollable Gui

Only in very rare circumstances should this class be used directly. Instead, use the static factory or builder functions from the ScrollGui interface, such as ScrollGui.items(), ScrollGui.guis() or ScrollGui.inventories() to create a new ScrollGui.

See Also:
  • ScrollItemsGuiImpl
  • ScrollNestedGuiImpl
  • Field Details

    • content

      protected List<C> content
      The content of the gui, to be displayed on the lines.
    • elements

      protected List<SlotElement> elements
      The baked SlotElements, containing the content.
  • Constructor Details

    • AbstractScrollGui

      public AbstractScrollGui(int width, int height, boolean infiniteLines, int... contentListSlots)
      Creates a new AbstractScrollGui.
      Parameters:
      width - The width of the gui.
      height - The height of the gui.
      infiniteLines - Whether the gui has infinite lines.
      contentListSlots - The slots to be used for lines.
    • AbstractScrollGui

      public AbstractScrollGui(int width, int height, boolean infiniteLines, Structure structure)
      Creates a new AbstractScrollGui.
      Parameters:
      width - The width of the gui.
      height - The height of the gui.
      infiniteLines - Whether the gui has infinite lines.
      structure - The structure of the gui.
  • Method Details

    • getLineLength

      public int getLineLength()
      Gets the (longest) scroll line length used in this AbstractScrollGui.
      Returns:
      The line length.
    • getCurrentLine

      public int getCurrentLine()
      Description copied from interface: ScrollGui
      Gets the current line of this ScrollGui.
      Specified by:
      getCurrentLine in interface ScrollGui<C>
      Returns:
      The current line of this ScrollGui.
    • setCurrentLine

      public void setCurrentLine(int line)
      Description copied from interface: ScrollGui
      Sets the current line of this ScrollGui.
      Specified by:
      setCurrentLine in interface ScrollGui<C>
      Parameters:
      line - The line to set.
    • canScroll

      public boolean canScroll(int lines)
      Description copied from interface: ScrollGui
      Checks if it is possible to scroll the specified amount of lines.
      Specified by:
      canScroll in interface ScrollGui<C>
      Parameters:
      lines - The amount of lines to check.
      Returns:
      Whether it is possible to scroll the specified amount of lines.
    • scroll

      public void scroll(int lines)
      Description copied from interface: ScrollGui
      Scrolls the specified amount of lines.
      Specified by:
      scroll in interface ScrollGui<C>
      Parameters:
      lines - The amount of lines to scroll.
    • getMaxLine

      public int getMaxLine()
      Description copied from interface: ScrollGui
      Gets the max line index of this ScrollGui.
      Specified by:
      getMaxLine in interface ScrollGui<C>
      Returns:
      The max line index of this ScrollGui.
    • setContent

      public void setContent(@Nullable @Nullable List<C> content)
      Description copied from interface: ScrollGui
      Sets the content of this ScrollGui for all lines.
      Specified by:
      setContent in interface ScrollGui<C>
      Parameters:
      content - The content to set.
    • update

      protected void update()
      Updates the gui, by first correcting the current line and then updating all relevant items.
    • setScrollHandlers

      public void setScrollHandlers(@NotNull @NotNull List<@NotNull BiConsumer<Integer,Integer>> scrollHandlers)
      Description copied from interface: ScrollGui
      Replaces the currently registered scroll handlers with the specified ones.
      Specified by:
      setScrollHandlers in interface ScrollGui<C>
      Parameters:
      scrollHandlers - The new scroll handlers.
    • addScrollHandler

      public void addScrollHandler(@NotNull @NotNull BiConsumer<Integer,Integer> scrollHandler)
      Description copied from interface: ScrollGui
      Adds a scroll handler to this ScrollGui.
      Specified by:
      addScrollHandler in interface ScrollGui<C>
      Parameters:
      scrollHandler - The scroll handler to add.
    • removeScrollHandler

      public void removeScrollHandler(@NotNull @NotNull BiConsumer<Integer,Integer> scrollHandler)
      Description copied from interface: ScrollGui
      Removes the specified scroll handler from this ScrollGui.
      Specified by:
      removeScrollHandler in interface ScrollGui<C>
      Parameters:
      scrollHandler - The scroll handler to remove.