Class PaginatingGUIContentsProvider
java.lang.Object
me.eddie.inventoryguiapi.gui.contents.PaginatingGUIContentsProvider
- All Implemented Interfaces:
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.
-
Nested Class Summary
Nested classes/interfaces inherited from interface me.eddie.inventoryguiapi.gui.contents.GUIContentsProvider
GUIContentsProvider.GUIContentsResponse -
Field Summary
Fields inherited from interface me.eddie.inventoryguiapi.gui.contents.GUIContentsProvider
MAX_JAVA_TITLE_LENGTH -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract voidgenBaseTitle(org.bukkit.entity.Player viewer, GUISession session, Callback<String> callback) Calculate the title to display for this GUI.voidgenContents(org.bukkit.entity.Player viewer, int page, GUISession session, Callback<GUIContentsProvider.GUIContentsResponse> callback) Calculate the GUIElements to display on this page and if another exists.abstract voidgenContents(org.bukkit.entity.Player viewer, GUISession session, Callback<List<GUIElement>> callback) Calculate the GUIElements to display in this GUI.voidgenTitle(org.bukkit.entity.Player viewer, int page, GUISession session, Callback<String> callback) Calculate the title to display for a given page.abstract booleanWhether or not to show the page count in the title of the inventory.abstract booleanWhether or not to show the page number in the title of the inventory.
-
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 calledsession- The GUISession being viewedcallback- The callback to pass the response to. If the callback isn't called then the GUI will not work properly. Use theCallback.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 calledsession- The GUISession being viewedcallback- The callback to pass the response to. If the callback isn't called then the GUI will not work properly. Use theCallback.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:GUIContentsProviderCalculate 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:
genContentsin interfaceGUIContentsProvider- 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 calledpage- The page to retrieve the contents for. Page 1 is the first page.session- The GUISession being viewedcallback- The callback to pass the response to. If the callback isn't called then the GUI will not work properly. Use theCallback.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:GUIContentsProviderCalculate 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:
genTitlein interfaceGUIContentsProvider- 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 calledpage- The page to retrieve the contents for. Page 1 is the first page.session- The GUISession being viewedcallback- The callback to pass the response to. If the callback isn't called then the GUI will not work properly. Use theCallback.call(Object)method of the callback.
-