Class GUIBuilder
java.lang.Object
me.eddie.inventoryguiapi.gui.guis.GUIBuilder
Builder for the constructing an instance of one of the default GUI implementations
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumEnum that defines how a GUI's GUIState should be handled -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new GUIBuilder, used for building a new InventoryGUI that uses the default GUI implementation -
Method Summary
Modifier and TypeMethodDescriptionactionListeners(GUIActionListener... actionListeners) Specify action listeners for this GUI.bedrockContents(String title, List<GUIElement> elements, boolean paginate, boolean showPageNum, boolean showPageCount) Specify what GUIElements this GUI should display and the title of the GUI if Bedrock Forms-based.build()contents(String title, List<GUIElement> elements, boolean paginate, boolean showPageNum, boolean showPageCount) Specify what GUIElements this GUI should display and the title of the GUI.contentsProvider(GUIContentsProvider contentsProvider) Specify the GUIContentsProvider this GUI should use.dynamicallyResizeToWrapContent(boolean resize) Set whether or not this inventory should automatically re-size to wrap it's contents.guiStateBehaviour(GUIBuilder.GUIStateBehaviour behaviour) Define how the GUIState should be handled.inventoryContents(String title, List<GUIElement> elements, boolean paginate, boolean showPageNum, boolean showPageCount) Specify what GUIElements this GUI should display and the title of the GUI if Inventory-based.inventoryType(org.bukkit.event.inventory.InventoryType inventoryType) Sets the type of the inventory the GUI displays.paginatingContentsProvider(PaginatingGUIContentsProvider contentsProvider) Specify the PaginatingGUIContentsProvider this GUI should use.populator(GUIPopulator populator) Specify a custom GUIPopulator to use with this GUI.presenter(GUIPresenter presenter) Specify a custom GUIPresenter to use with this GUI A GUIPresenter takes the calculated InventoryState that the GUI should currently be displaying and displays it to the end-user.size(int size) Set the size this GUI should be for each page.
-
Constructor Details
-
GUIBuilder
public GUIBuilder()Create a new GUIBuilder, used for building a new InventoryGUI that uses the default GUI implementation
-
-
Method Details
-
guiStateBehaviour
Define how the GUIState should be handled. A value ofGUIBuilder.GUIStateBehaviour.LOCAL_TO_SESSIONwill mean the defaultGUIimplementation is used, with this implementation the GUIState is lost when the session ends (GUI closes). A value ofGUIBuilder.GUIStateBehaviour.BOUND_TO_GUIwill mean the defaultSharedGUIimplementation is used, with this implementation the GUIState is bound to the GUI and is persistent. This means all viewers will see the same GUIState and it persists beyond the GUI closing.- Parameters:
behaviour- How the GUIState should behave- Returns:
- Returns self
-
presenter
Specify a custom GUIPresenter to use with this GUI A GUIPresenter takes the calculated InventoryState that the GUI should currently be displaying and displays it to the end-user. A custom GUIPresenter will allow you to customize how your GUI is viewed. For almost all use cases it is recommended to use the default GUIPresenter (Don't call this method)- Parameters:
presenter- The custom GUIPresenter to use, or null (or not specified) if you want the default one- Returns:
- Returns self
-
populator
Specify a custom GUIPopulator to use with this GUI. A GUIPopulator calculates the final position that each element should be in within the displayed GUI before it is rendered. Specify a custom GUIPopulator to make your GUI use a complex custom layout. (Simple layout changes can be done by manipulating the desired slots of GUIElements)- Parameters:
populator- The custom GUIPopulator to use, or null (Or not specified) if you want the default one- Returns:
- Returns self
-
actionListeners
Specify action listeners for this GUI. ActionListeners receive GUI events (Eg. open, close, place item) before GUIElements do (But after they're fired through the Bukkit event system). These are ideal for adding GUI specific event handling. For example you may want to, when a GUI closes, save what is input into an InputSlot.- Parameters:
actionListeners- The ActionListeners that should listen to actions with this GUI- Returns:
- Returns self
-
size
Set the size this GUI should be for each page. With a dynamically re-sizing GUI this is the maximum size- Parameters:
size- The size or maximum size of this GUI- Returns:
- Returns self
-
dynamicallyResizeToWrapContent
Set whether or not this inventory should automatically re-size to wrap it's contents. (Up to the maximum size). When automatic re-sizing is enabled, the size specified to the builder is treated as the maximum size of a GUI page.- Parameters:
resize- True if GUI should dynamically resize- Returns:
- Returns self
-
inventoryType
Sets the type of the inventory the GUI displays. This must be type CHEST if you wish to have a dynamically sized GUI- Parameters:
inventoryType- The type of inventory- Returns:
- Returns self
-
contents
public GUIBuilder contents(String title, List<GUIElement> elements, boolean paginate, boolean showPageNum, boolean showPageCount) Specify what GUIElements this GUI should display and the title of the GUI. This is useful for static GUIs. For GUIs that need to show different GUIElements to different viewers, or that need GUISession information to determine which GUIElements to display a GUIContentsProvider should be used instead.- Parameters:
title- The title of the GUIelements- The list of elements to displaypaginate- Whether or not to automatically split these GUIElements into pagesshowPageNum- Whether or not to show the page number in the title, ignored if paginate is FalseshowPageCount- Whether or not to show the page count in the title, ignored if paginate is False- Returns:
- Returns self
-
inventoryContents
public GUIBuilder inventoryContents(String title, List<GUIElement> elements, boolean paginate, boolean showPageNum, boolean showPageCount) Specify what GUIElements this GUI should display and the title of the GUI if Inventory-based.- Parameters:
title- The title of the GUIelements- The list of elements to displaypaginate- Whether or not to automatically split these GUIElements into pagesshowPageNum- Whether or not to show the page number in the title, ignored if paginate is FalseshowPageCount- Whether or not to show the page count in the title, ignored if paginate is False- Returns:
- Returns self
-
bedrockContents
public GUIBuilder bedrockContents(String title, List<GUIElement> elements, boolean paginate, boolean showPageNum, boolean showPageCount) Specify what GUIElements this GUI should display and the title of the GUI if Bedrock Forms-based.- Parameters:
title- The title of the GUIelements- The list of elements to displaypaginate- Whether or not to automatically split these GUIElements into pagesshowPageNum- Whether or not to show the page number in the title, ignored if paginate is FalseshowPageCount- Whether or not to show the page count in the title, ignored if paginate is False- Returns:
- Returns self
-
paginatingContentsProvider
Specify the PaginatingGUIContentsProvider this GUI should use. A contents provider defines what GUIElements should be displayed on each GUI page and for which viewer. This method is the same as callingcontentsProvider(GUIContentsProvider)with a PaginatingContentsProvider PaginatingContentsProvider is an abstract class that handles splitting a list of GUIElements into pages to display. This is useful if you have a list of GUIElemenets to display and want them automatically sorted into pages for you. To use PaginatingContentsProvider, extend the class and implement the methods marked as abstract.- Parameters:
contentsProvider- The PaginatingContentsProvider for this GUI- Returns:
- Returns self
-
contentsProvider
Specify the GUIContentsProvider this GUI should use. A contents provider defines what GUIElements should be displayed on each GUI page and for which viewer.- Parameters:
contentsProvider- The ContentsProvider for this GUI- Returns:
- Returns self
-
build
-