Class PaginatingGUIContentsProvider

java.lang.Object
me.eddie.inventoryguiapi.gui.contents.PaginatingGUIContentsProvider
All Implemented Interfaces:
GUIContentsProvider

public abstract class PaginatingGUIContentsProvider extends Object implements GUIContentsProvider
An extension of GUIContentsProvider that will handle paginating a provided list of GUIElements. To use this, extend the class Determines what contents to show viewers and the title of each page. Once the inventory for a given page has been opened the title won't be able to be changed without closing and re-opening the inventory, this is due to a limitation in the Bukkit API and/or Minecraft.
  • Constructor Details

    • PaginatingGUIContentsProvider

      public PaginatingGUIContentsProvider()
  • Method Details

    • genContents

      public abstract void genContents(org.bukkit.entity.Player viewer, GUISession session, Callback<List<GUIElement>> callback)
      Calculate the GUIElements to display in this GUI. Once calculated the result (a List of GUIElements) should be passed to the provided callback. If the callback isn't called then the GUI will not work properly.
      Parameters:
      viewer - The viewer of this inventory. In the case of a GUI with multiple viewers (SharedInventoryGUI) this will be whatever viewer caused this method to be called
      session - The GUISession being viewed
      callback - The callback to pass the response to. If the callback isn't called then the GUI will not work properly. Use the Callback.call(Object) method of the callback.
    • genBaseTitle

      public abstract void genBaseTitle(org.bukkit.entity.Player viewer, GUISession session, Callback<String> callback)
      Calculate the title to display for this GUI. The title may then be extended with the page number. Once calculated the result (a String) should be passed to the provided callback. If the callback isn't called then the GUI will not work properly.
      Parameters:
      viewer - The viewer of this inventory. In the case of a GUI with multiple viewers (SharedInventoryGUI) this will be whatever viewer caused this method to be called
      session - The GUISession being viewed
      callback - The callback to pass the response to. If the callback isn't called then the GUI will not work properly. Use the Callback.call(Object) method of the callback.
    • showPageNumberInTitle

      public abstract boolean showPageNumberInTitle()
      Whether or not to show the page number in the title of the inventory.
      Returns:
      True if the page number should be shown in the inventory title, False otherwise
    • showPageCountInTitle

      public abstract boolean showPageCountInTitle()
      Whether or not to show the page count in the title of the inventory.
      Returns:
      True if the page count should be shown in the inventory title, False otherwise
    • genContents

      public void genContents(org.bukkit.entity.Player viewer, int page, GUISession session, Callback<GUIContentsProvider.GUIContentsResponse> callback)
      Description copied from interface: GUIContentsProvider
      Calculate the GUIElements to display on this page and if another exists. Once calculated the result (a GUIContentsResponse) should be passed to the provided callback. If the callback isn't called then the GUI will not work properly.
      Specified by:
      genContents in interface GUIContentsProvider
      Parameters:
      viewer - The viewer of this inventory. In the case of a GUI with multiple viewers (SharedInventoryGUI) this will be whatever viewer caused this method to be called
      page - The page to retrieve the contents for. Page 1 is the first page.
      session - The GUISession being viewed
      callback - The callback to pass the response to. If the callback isn't called then the GUI will not work properly. Use the Callback.call(Object) method of the callback.
    • genTitle

      public void genTitle(org.bukkit.entity.Player viewer, int page, GUISession session, Callback<String> callback)
      Description copied from interface: GUIContentsProvider
      Calculate the title to display for a given page. Once calculated the result (a String) should be passed to the provided callback. If the callback isn't called then the GUI will not work properly.
      Specified by:
      genTitle in interface GUIContentsProvider
      Parameters:
      viewer - The viewer of this inventory. In the case of a GUI with multiple viewers (SharedInventoryGUI) this will be whatever viewer caused this method to be called
      page - The page to retrieve the contents for. Page 1 is the first page.
      session - The GUISession being viewed
      callback - The callback to pass the response to. If the callback isn't called then the GUI will not work properly. Use the Callback.call(Object) method of the callback.