java.lang.Object
com.github.stefvanschie.inventoryframework.pane.Pane
com.github.stefvanschie.inventoryframework.pane.component.PagingButtons

public class PagingButtons extends Pane
An interface for interacting with PaginatedPanes. This gives two buttons for navigating backwards and forwards through the pages of the PaginatedPane. The backward button will be displayed at (0, 0) of this pane and the forward button will be displayed at (length - 1, 0) of this pane. If the paginated pane is at the first page or the last page, the backwards respectively the forward button will not show. This does not display the PaginatedPane itself, but is merely an interface for interacting with it.
Since:
0.10.14
  • Constructor Details

    • PagingButtons

      public PagingButtons(@NotNull @NotNull Slot slot, int length, @NotNull @NotNull Pane.Priority priority, @NotNull @NotNull PaginatedPane pages, @NotNull @NotNull Plugin plugin)
      Creates a new PagingButtons instance, which controls the provided PaginatedPane. The backward and forward item will be an arrow. If the length provided is less than 2, this will throw an IllegalArgumentException.
      Parameters:
      slot - the position of this interface
      length - the length of this interface
      priority - the priority of this interface
      pages - the pages to interact with
      plugin - the plugin that will be the owner of this interface's items
      Throws:
      IllegalArgumentException - if the length is less than 2
      Since:
      0.10.14
    • PagingButtons

      public PagingButtons(@NotNull @NotNull Slot slot, int length, @NotNull @NotNull Pane.Priority priority, @NotNull @NotNull PaginatedPane pages)
      Creates a new PagingButtons instance, which controls the provided PaginatedPane. The backward and forward item will be an arrow. If the length provided is less than 2, this will throw an IllegalArgumentException.
      Parameters:
      slot - the position of this interface
      length - the length of this interface
      priority - the priority of this interface
      pages - the pages to interact with
      Throws:
      IllegalArgumentException - if the length is less than 2
      Since:
      0.10.14
    • PagingButtons

      public PagingButtons(@NotNull @NotNull Slot slot, int length, @NotNull @NotNull PaginatedPane pages, @NotNull @NotNull Plugin plugin)
      Creates a new PagingButtons instance, which controls the provided PaginatedPane. The backward and forward item will be an arrow. If the length provided is less than 2, this will throw an IllegalArgumentException.
      Parameters:
      slot - the position of this interface
      length - the length of this interface
      pages - the pages to interact with
      plugin - the plugin that will be the owner of this interface's items
      Throws:
      IllegalArgumentException - if the length is less than 2
      Since:
      0.10.14
    • PagingButtons

      public PagingButtons(@NotNull @NotNull Slot slot, int length, @NotNull @NotNull PaginatedPane pages)
      Creates a new PagingButtons instance, which controls the provided PaginatedPane. The backward and forward item will be an arrow. If the length provided is less than 2, this will throw an IllegalArgumentException.
      Parameters:
      slot - the position of this interface
      length - the length of this interface
      pages - the pages to interact with
      Throws:
      IllegalArgumentException - if the length is less than 2
      Since:
      0.10.14
    • PagingButtons

      public PagingButtons(int length, @NotNull @NotNull Pane.Priority priority, @NotNull @NotNull PaginatedPane pages, @NotNull @NotNull Plugin plugin)
      Creates a new PagingButtons instance, which controls the provided PaginatedPane. The backward and forward item will be an arrow. If the length provided is less than 2, this will throw an IllegalArgumentException.
      Parameters:
      length - the length of this interface
      priority - the priority of this interface
      pages - the pages to interact with
      plugin - the plugin that will be the owner of this interface's items
      Throws:
      IllegalArgumentException - if the length is less than 2
      Since:
      0.10.14
    • PagingButtons

      public PagingButtons(int length, @NotNull @NotNull Pane.Priority priority, @NotNull @NotNull PaginatedPane pages)
      Creates a new PagingButtons instance, which controls the provided PaginatedPane. The backward and forward item will be an arrow. If the length provided is less than 2, this will throw an IllegalArgumentException.
      Parameters:
      length - the length of this interface
      priority - the priority of this interface
      pages - the pages to interact with
      Throws:
      IllegalArgumentException - if the length is less than 2
      Since:
      0.10.14
    • PagingButtons

      public PagingButtons(int length, @NotNull @NotNull PaginatedPane pages, @NotNull @NotNull Plugin plugin)
      Creates a new PagingButtons instance, which controls the provided PaginatedPane. The backward and forward item will be an arrow. If the length provided is less than 2, this will throw an IllegalArgumentException.
      Parameters:
      length - the length of this interface
      pages - the pages to interact with
      plugin - the plugin that will be the owner of this interface's items
      Throws:
      IllegalArgumentException - if the length is less than 2
      Since:
      0.10.14
    • PagingButtons

      public PagingButtons(int length, @NotNull @NotNull PaginatedPane pages)
      Creates a new PagingButtons instance, which controls the provided PaginatedPane. The backward and forward item will be an arrow. If the length provided is less than 2, this will throw an IllegalArgumentException.
      Parameters:
      length - the length of this interface
      pages - the pages to interact with
      Throws:
      IllegalArgumentException - if the length is less than 2
      Since:
      0.10.14
  • Method Details

    • click

      public boolean click(@NotNull @NotNull Gui gui, @NotNull @NotNull InventoryComponent inventoryComponent, @NotNull @NotNull InventoryClickEvent event, int slot, int paneOffsetX, int paneOffsetY, int maxLength, int maxHeight)
      Description copied from class: Pane
      Called whenever there is being clicked on this pane
      Specified by:
      click in class Pane
      Parameters:
      gui - the gui in which was clicked
      inventoryComponent - the inventory component in which this pane resides
      event - the event that occurred while clicking on this item
      slot - the slot that was clicked in
      paneOffsetX - the pane's offset on the x axis
      paneOffsetY - the pane's offset on the y axis
      maxLength - the maximum length of the pane
      maxHeight - the maximum height of the pane
      Returns:
      whether the item was found or not
    • display

      public void display(@NotNull @NotNull InventoryComponent inventoryComponent, int paneOffsetX, int paneOffsetY, int maxLength, int maxHeight)
      Description copied from class: Pane
      Has to set all the items in the right spot inside the inventory
      Specified by:
      display in class Pane
      Parameters:
      inventoryComponent - the inventory component in which the items should be displayed
      paneOffsetX - the pane's offset on the x axis
      paneOffsetY - the pane's offset on the y axis
      maxLength - the maximum length of the pane
      maxHeight - the maximum height of the pane
    • copy

      @NotNull @Contract(pure=true) public @NotNull PagingButtons copy()
      Makes a copy of this pane and returns it. This makes a deep copy of the pane. This entails that the underlying panes and/or items will be copied as well. The returned pane will never be reference equal to the current pane. This does not make a copy of the PaginatedPane that is being controlled by this interface.
      Overrides:
      copy in class Pane
      Returns:
      a copy of this pane
    • getItems

      @NotNull @Contract(pure=true) public @NotNull Collection<GuiItem> getItems()
      Description copied from class: Pane
      Gets all the items in this pane and all underlying panes. The returned collection is not guaranteed to be mutable or to be a view of the underlying data. (So changes to the gui are not guaranteed to be visible in the returned value.)
      Specified by:
      getItems in class Pane
      Returns:
      all items
    • setBackwardButton

      public void setBackwardButton(@NotNull @NotNull GuiItem item)
      Sets the item to be used for navigating backwards. If an event is attached to the item, this event will be called after the page has been changed.
      Parameters:
      item - the new backward item
      Since:
      0.10.14
    • setForwardButton

      public void setForwardButton(@NotNull @NotNull GuiItem item)
      Sets the item to be used for navigating forwards. If an event is attached to the item, this event will be called after the page has been changed.
      Parameters:
      item - the new forward item
      Since:
      0.10.14
    • getPanes

      @NotNull @Contract(pure=true) public @NotNull Collection<Pane> getPanes()
      Description copied from class: Pane
      Gets all the panes in this panes, including any child panes from other panes. The returned collection is not guaranteed to be mutable or to be a view of the underlying data. (So changes to the gui are not guaranteed to be visible in the returned value.)
      Specified by:
      getPanes in class Pane
      Returns:
      all panes
    • clear

      public void clear()
      This is a no-op.
      Specified by:
      clear in class Pane
      Since:
      0.10.14
    • load

      @NotNull @Contract(pure=true) public static @NotNull PagingButtons load(@NotNull @NotNull Object instance, @NotNull @NotNull Element element, @NotNull @NotNull Plugin plugin)
      Loads a paging buttons pane from an XML element.
      Parameters:
      instance - the instance class
      element - the element
      plugin - the plugin that will be the owner of the underlying items
      Returns:
      the paging buttons pane
      Since:
      0.10.14