Class GUIElementFactory
java.lang.Object
me.eddie.inventoryguiapi.gui.elements.GUIElementFactory
Some helpful methods for creating common GUIElements
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ActionItemcreateActionItem(int desiredSlot, org.bukkit.inventory.ItemStack displayItem, ActionItem.ActionHandler actionHandler) Create an ActionItem - A GUIElement that when clicked performs an actionstatic ActionItemcreateActionItem(int desiredSlot, org.bukkit.inventory.ItemStack displayItem, ActionItem.ActionHandler actionHandler, FormImage formImage) Create an ActionItem - A GUIElement that when clicked performs an actionstatic ActionItemcreateActionItem(int desiredSlot, org.bukkit.inventory.ItemStack displayItem, Callback<org.bukkit.entity.Player> onClick) Create an ActionItem - A GUIElement that when clicked performs an actionstatic ActionItemcreateActionItem(int desiredSlot, org.bukkit.inventory.ItemStack displayItem, Callback<org.bukkit.entity.Player> onClick, FormImage formImage) Create an ActionItem - A GUIElement that when clicked performs an actionstatic ActionItemcreateActionItem(org.bukkit.inventory.ItemStack displayItem, ActionItem.ActionHandler actionHandler) Create an ActionItem - A GUIElement that when clicked performs an action.static ActionItemcreateActionItem(org.bukkit.inventory.ItemStack displayItem, Callback<org.bukkit.entity.Player> onClick) Create an ActionItem - A GUIElement that when clicked performs an action.static InputSlotcreateInputSlot(String uniqueInputSlotID, int desiredSlot, InputSlot.ActionHandler actionHandler) Create an InputSlot - A GUIElement that accepts user input UseInputSlot.setCurrentItem(me.eddie.inventoryguiapi.gui.session.GUISession, ItemStack)to change the item currently input post-creation.static InputSlotcreateInputSlot(String uniqueInputSlotID, InputSlot.ActionHandler actionHandler) Create an InputSlot - A GUIElement that accepts user input This InputSlot will have no preference for which slot it should be displayed in.static LabelItemcreateLabelItem(int desiredSlot, org.bukkit.inventory.ItemStack displayItem) Create a LabelItem - A GUIElement that displays textstatic LabelItemcreateLabelItem(org.bukkit.inventory.ItemStack displayItem) Create a LabelItem - A GUIElement that displays text This LabelItem will have no preference for which slot it should be displayed in.static org.bukkit.inventory.ItemStackformatItem(org.bukkit.inventory.ItemStack base, String displayName, String... lore) Will take a given ItemStack and change it's lore and display name.
-
Constructor Details
-
GUIElementFactory
public GUIElementFactory()
-
-
Method Details
-
formatItem
public static org.bukkit.inventory.ItemStack formatItem(org.bukkit.inventory.ItemStack base, String displayName, String... lore) Will take a given ItemStack and change it's lore and display name. The edited ItemStack is then returned. This is a convenience method that saves you from the work of manipulating ItemMeta.- Parameters:
base- The base ItemStack to modifydisplayName- The display name to set, can be colored (Using Bukkit's ChatColor)lore- The lore to set, canbe colored (Using Bukkit'S ChatColor)- Returns:
- The formatted item
-
createInputSlot
public static InputSlot createInputSlot(String uniqueInputSlotID, InputSlot.ActionHandler actionHandler) Create an InputSlot - A GUIElement that accepts user input This InputSlot will have no preference for which slot it should be displayed in. If you wish to specify a slot, usecreateInputSlot(String, int, InputSlot.ActionHandler)UseInputSlot.setCurrentItem(me.eddie.inventoryguiapi.gui.session.GUISession, ItemStack)to change the item currently input post-creation. Note that this change will not be visible to viewers until their view has been updated. (If done within a ContentsProvider then the view is updated for you)- Parameters:
uniqueInputSlotID- The unique ID that references this input slot. This is used for tracking what item is input into slot throughout the GUISession.actionHandler- ActionHandler that lets you manipulate the behaviour of this input slot. Eg. prevent certain items being input into the slot (By cancelling GUIEvent and bukkit event within the handler)- Returns:
- The created InputSlot
-
createInputSlot
public static InputSlot createInputSlot(String uniqueInputSlotID, int desiredSlot, InputSlot.ActionHandler actionHandler) Create an InputSlot - A GUIElement that accepts user input UseInputSlot.setCurrentItem(me.eddie.inventoryguiapi.gui.session.GUISession, ItemStack)to change the item currently input post-creation. Note that this change will not be visible to viewers until their view has been updated. (If done within a ContentsProvider then the view is updated for you)- Parameters:
uniqueInputSlotID- The unique ID that references this input slot. This is used for tracking what item is input into slot throughout the GUISession.desiredSlot- The slot you wish for this GUIElement to be placed into in the GUI. UsecreateInputSlot(String, InputSlot.ActionHandler)if you do not care about the placement position of this item.actionHandler- ActionHandler that lets you manipulate the behaviour of this input slot. Eg. prevent certain items being input into the slot (By cancelling GUIEvent and bukkit event within the handler)- Returns:
- The created InputSlot
-
createActionItem
public static ActionItem createActionItem(org.bukkit.inventory.ItemStack displayItem, ActionItem.ActionHandler actionHandler) Create an ActionItem - A GUIElement that when clicked performs an action. This ActionItem will have no preference for which slot it should be displayed in. If you wish to specify a slot, usecreateActionItem(int, ItemStack, ActionItem.ActionHandler)- Parameters:
displayItem- The item to display in the slot that this GUIElement occupies.actionHandler- ActionHandler that defines what this ActionItem does when clicked. To re-calculate the contents to be displayed, call toInventoryGUI.updateContentsAndView(Player)- Returns:
- The created ActionItem
-
createActionItem
public static ActionItem createActionItem(org.bukkit.inventory.ItemStack displayItem, Callback<org.bukkit.entity.Player> onClick) Create an ActionItem - A GUIElement that when clicked performs an action. This ActionItem will have no preference for which slot it should be displayed in. If you wish to specify a slot, usecreateActionItem(int, ItemStack, ActionItem.ActionHandler)- Parameters:
displayItem- The item to display in the slot that this GUIElement occupies.onClick- Runnable that is ran when item clicked. To re-calculate the contents to be displayed, call toInventoryGUI.updateContentsAndView(Player)- Returns:
- The created ActionItem
-
createActionItem
public static ActionItem createActionItem(int desiredSlot, org.bukkit.inventory.ItemStack displayItem, Callback<org.bukkit.entity.Player> onClick) Create an ActionItem - A GUIElement that when clicked performs an action- Parameters:
desiredSlot- The slot you wish for this GUIElement to be placed into in the GUI. UsecreateActionItem(ItemStack, ActionItem.ActionHandler)if you do not care about the placement position of this item.displayItem- The item to display in the slot that this GUIElement occupies.onClick- Runnable that is ran when item clicked. To re-calculate the contents to be displayed, call toInventoryGUI.updateContentsAndView(Player)- Returns:
- The created ActionItem
-
createActionItem
public static ActionItem createActionItem(int desiredSlot, org.bukkit.inventory.ItemStack displayItem, Callback<org.bukkit.entity.Player> onClick, FormImage formImage) Create an ActionItem - A GUIElement that when clicked performs an action- Parameters:
desiredSlot- The slot you wish for this GUIElement to be placed into in the GUI. UsecreateActionItem(ItemStack, ActionItem.ActionHandler)if you do not care about the placement position of this item.displayItem- The item to display in the slot that this GUIElement occupies.onClick- Runnable that is ran when item clicked. To re-calculate the contents to be displayed, call toInventoryGUI.updateContentsAndView(Player)formImage- Image to use in Bedrock Form GUI, in place of a texture of provided displayItem- Returns:
- The created ActionItem
-
createActionItem
public static ActionItem createActionItem(int desiredSlot, org.bukkit.inventory.ItemStack displayItem, ActionItem.ActionHandler actionHandler) Create an ActionItem - A GUIElement that when clicked performs an action- Parameters:
desiredSlot- The slot you wish for this GUIElement to be placed into in the GUI. UsecreateActionItem(ItemStack, ActionItem.ActionHandler)if you do not care about the placement position of this item.displayItem- The item to display in the slot that this GUIElement occupies.actionHandler- ActionHandler that defines what this ActionItem does when clicked. To re-calculate the contents to be displayed, call toInventoryGUI.updateContentsAndView(Player)- Returns:
- The created ActionItem
-
createActionItem
public static ActionItem createActionItem(int desiredSlot, org.bukkit.inventory.ItemStack displayItem, ActionItem.ActionHandler actionHandler, FormImage formImage) Create an ActionItem - A GUIElement that when clicked performs an action- Parameters:
desiredSlot- The slot you wish for this GUIElement to be placed into in the GUI. UsecreateActionItem(ItemStack, ActionItem.ActionHandler)if you do not care about the placement position of this item.displayItem- The item to display in the slot that this GUIElement occupies.actionHandler- ActionHandler that defines what this ActionItem does when clicked. To re-calculate the contents to be displayed, call toInventoryGUI.updateContentsAndView(Player)formImage- Image to use in Bedrock Form GUI, in place of a texture of provided displayItem- Returns:
- The created ActionItem
-
createLabelItem
Create a LabelItem - A GUIElement that displays text This LabelItem will have no preference for which slot it should be displayed in. If you wish to specify a slot, usecreateLabelItem(int, ItemStack)- Parameters:
displayItem- The item to display in the slot that this GUIElement occupies.- Returns:
- The created LabelItem
-
createLabelItem
public static LabelItem createLabelItem(int desiredSlot, org.bukkit.inventory.ItemStack displayItem) Create a LabelItem - A GUIElement that displays text- Parameters:
desiredSlot- The slot you wish for this GUIElement to be placed into in the GUI. UsecreateActionItem(ItemStack, ActionItem.ActionHandler)if you do not care about the placement position of this item.displayItem- The item to display in the slot that this GUIElement occupies.- Returns:
- The created LabelItem
-