Class GUI
java.lang.Object
me.eddie.inventoryguiapi.gui.guis.GUI
- All Implemented Interfaces:
InventoryGUI
- Direct Known Subclasses:
SharedGUI
Default implementation of a GUI
The state of the GUI (GUIState) is local to each session, and when a session ends (GUI closes) is lost
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected List<GUIActionListener>static final intprotected GUIContentsProviderprotected GUIPopulatorprotected GUIPresenterprotected org.bukkit.event.inventory.InventoryTypeprotected booleanprotected int -
Constructor Summary
ConstructorsConstructorDescriptionGUI(org.bukkit.event.inventory.InventoryType inventoryType, int size, boolean isDynamicSize, GUIContentsProvider contentsProvider, GUIPopulator guiPopulator, GUIPresenter guiPresenter, GUIActionListener... guiActionListeners) Create a new GUIGUI(org.bukkit.event.inventory.InventoryType inventoryType, int size, boolean isDynamicSize, GUIContentsProvider contentsProvider, GUIActionListener... guiActionListeners) Create a new GUI -
Method Summary
Modifier and TypeMethodDescriptionprotected GUISessioncreateNewSession(org.bukkit.entity.Player player, int page) protected <T> voidfireEvent(GUIEvent guiEvent, GUIElement guiElement, T receivedEvent) protected voidGet the ContentsProvider associated with calculating what GUIElements to display in this GUIGet the GUIPopulator associated with calculating the layout of GUIElements to display in this GUIGet the GUIPresenter associated with displaying this GUIorg.bukkit.event.inventory.InventoryTypeGet the inventory type used by this GUI to display items to viewersintGet the maximum size that this GUI can be before extra elements will flow onto new pages.protected voidhandleAutoInsertAsIndividualActions(org.bukkit.entity.Player viewer, InventoryState inventoryState, GUISession session, org.bukkit.inventory.Inventory destInv, org.bukkit.event.inventory.InventoryClickEvent shiftClickEvent) voidhandleBedrockResponse(GUISession session, org.bukkit.entity.Player player, int clickedButtonId) Handle a Bedrock form responsevoidhandleBukkitEvent(org.bukkit.event.Event event, GUISession session) Handle the given Bukkit event, for example a ClickEventbooleanWhether or not this GUI should re-scale it's size to wrap it's current contents or if it should always be the maximum sizevoidopen(org.bukkit.entity.Player player) Shows the player provided the GUI, will show page 1.voidopen(org.bukkit.entity.Player player, int page) Shows the player provided the GUI, and starts with the player viewing the given pagevoidupdateContentsAndView(org.bukkit.entity.Player player) Recalculates the GUIElements to show the player (and what their display itemstacks are) and will update what the player sees - if they are viewing this GUI.protected voidupdateContentsAndView(org.bukkit.entity.Player player, GUISession session) voidupdateView(org.bukkit.entity.Player player) Will update what the viewer(s) see to match the GUI's state - if they are viewing this GUI.protected voidupdateView(org.bukkit.entity.Player player, GUISession session)
-
Field Details
-
AUTO_SET_SIZE
public static final int AUTO_SET_SIZE- See Also:
-
contentsProvider
-
guiPopulator
-
actionListeners
-
guiPresenter
-
inventoryType
protected org.bukkit.event.inventory.InventoryType inventoryType -
maxSize
protected int maxSize -
isDynamicSize
protected boolean isDynamicSize
-
-
Constructor Details
-
GUI
public GUI(org.bukkit.event.inventory.InventoryType inventoryType, int size, boolean isDynamicSize, GUIContentsProvider contentsProvider, GUIPopulator guiPopulator, GUIPresenter guiPresenter, GUIActionListener... guiActionListeners) Create a new GUI- Parameters:
inventoryType- The type of inventory to use in the created GUIsize- The size (maximum if dynamic) to make the created GUI. Non-default sizes only supported with CHEST inventory type (Minecraft limitation)isDynamicSize- True if inventory should resize to wrap it's contentscontentsProvider- The contents provider that dictates what this GUI should be showing to viewers of itguiPopulator- The GUIPopulator to use to position the GUIElements within the inventory to displayguiPresenter- The GUIPresenter to use to present the computed inventory to the playerguiActionListeners- Any ActionListeners that you want to specify. These receive GUIEvents before GUIElements do so that you can further customise the GUI's behaviour. They also receive GUIOpenEvent, GUICloseEvent and GUIUpdateEvent which GUIElements do not
-
GUI
public GUI(org.bukkit.event.inventory.InventoryType inventoryType, int size, boolean isDynamicSize, GUIContentsProvider contentsProvider, GUIActionListener... guiActionListeners) Create a new GUI- Parameters:
inventoryType- The type of inventory to use in the created GUIsize- The size (maximum if dynamic) to make the created GUI. Non-default sizes only supported with CHEST inventory type (Minecraft limitation)isDynamicSize- True if inventory should resize to wrap it's contentscontentsProvider- The contents provider that dictates what this GUI should be showing to viewers of itguiActionListeners- Any ActionListeners that you want to specify. These receive GUIEvents before GUIElements do so that you can further customise the GUI's behaviour
-
-
Method Details
-
open
public void open(org.bukkit.entity.Player player, int page) Description copied from interface:InventoryGUIShows the player provided the GUI, and starts with the player viewing the given page- Specified by:
openin interfaceInventoryGUI- Parameters:
player- The player who should be shown the GUIpage- The page to open the GUI on
-
fireEventThroughActionListeners
-
open
public void open(org.bukkit.entity.Player player) Description copied from interface:InventoryGUIShows the player provided the GUI, will show page 1. This method is the same as calling open(Player, 1)- Specified by:
openin interfaceInventoryGUI- Parameters:
player- The player who should be shown the GUI
-
createNewSession
-
updateContentsAndView
-
updateView
-
updateView
public void updateView(org.bukkit.entity.Player player) Description copied from interface:InventoryGUIWill update what the viewer(s) see to match the GUI's state - if they are viewing this GUI. If the given player is not viewing this GUI then this method will silently fail- Specified by:
updateViewin interfaceInventoryGUI- Parameters:
player- Viewer
-
updateContentsAndView
public void updateContentsAndView(org.bukkit.entity.Player player) Description copied from interface:InventoryGUIRecalculates the GUIElements to show the player (and what their display itemstacks are) and will update what the player sees - if they are viewing this GUI. If the given player is not viewing this GUI then this method will silently fail- Specified by:
updateContentsAndViewin interfaceInventoryGUI- Parameters:
player- The player to use to recalculate the GUIElements being displayed
-
handleBukkitEvent
Description copied from interface:InventoryGUIHandle the given Bukkit event, for example a ClickEvent- Specified by:
handleBukkitEventin interfaceInventoryGUI- Parameters:
event- The event to handlesession- The GUI Session that should respond to the event
-
handleAutoInsertAsIndividualActions
protected void handleAutoInsertAsIndividualActions(org.bukkit.entity.Player viewer, InventoryState inventoryState, GUISession session, org.bukkit.inventory.Inventory destInv, org.bukkit.event.inventory.InventoryClickEvent shiftClickEvent) -
fireEvent
-
handleBedrockResponse
public void handleBedrockResponse(GUISession session, org.bukkit.entity.Player player, int clickedButtonId) Description copied from interface:InventoryGUIHandle a Bedrock form response- Specified by:
handleBedrockResponsein interfaceInventoryGUI- Parameters:
session- The GUI Session that should respond to the eventplayer- Player that opened the dialogclickedButtonId- ID of clicked button, -1 if no button was clicked
-
getContentsProvider
Get the ContentsProvider associated with calculating what GUIElements to display in this GUI- Returns:
- The ContentsProvider
-
getGuiPopulator
Get the GUIPopulator associated with calculating the layout of GUIElements to display in this GUI- Returns:
- The GUIPopulator
-
getGuiPresenter
Get the GUIPresenter associated with displaying this GUI- Returns:
- The GUIPresenter
-
getInventoryType
public org.bukkit.event.inventory.InventoryType getInventoryType()Description copied from interface:InventoryGUIGet the inventory type used by this GUI to display items to viewers- Specified by:
getInventoryTypein interfaceInventoryGUI- Returns:
- The InventoryType
-
getMaximumGUISize
public int getMaximumGUISize()Description copied from interface:InventoryGUIGet the maximum size that this GUI can be before extra elements will flow onto new pages. Note, this size has to be compatible with the possible sizes of the InventoryType specified. Eg. for chests it has to be a multiple of 9.- Specified by:
getMaximumGUISizein interfaceInventoryGUI- Returns:
- The maximum size that this GUI can be.
-
isGUISizeDynamic
public boolean isGUISizeDynamic()Description copied from interface:InventoryGUIWhether or not this GUI should re-scale it's size to wrap it's current contents or if it should always be the maximum size- Specified by:
isGUISizeDynamicin interfaceInventoryGUI- Returns:
- True if the GUI should re-scale to wrap it's current contents, False otherwise
-