Class ActionItem
java.lang.Object
me.eddie.inventoryguiapi.gui.elements.AbstractGUIElement
me.eddie.inventoryguiapi.gui.elements.ActionItem
- All Implemented Interfaces:
GUIElement
Represents a GUIElement that when clicked performs an action
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceRepresents the action that should happen when this action item is clicked -
Field Summary
Fields inherited from class me.eddie.inventoryguiapi.gui.elements.AbstractGUIElement
NO_DESIRED_SLOT -
Constructor Summary
ConstructorsConstructorDescriptionActionItem(int slot, org.bukkit.inventory.ItemStack display, ActionItem.ActionHandler actionHandler) Construct a new ActionItem with a desired slotActionItem(int slot, org.bukkit.inventory.ItemStack display, ActionItem.ActionHandler actionHandler, FormImage formImage) Construct a new ActionItem with a desired slotActionItem(org.bukkit.inventory.ItemStack display, ActionItem.ActionHandler actionHandler) Construct a new ActionItem with no desired slot -
Method Summary
Modifier and TypeMethodDescriptionbooleancanAutoInsertIntoSlot(org.bukkit.entity.Player Viewer, GUISession session) Whether or not viewers can use Minecraft's auto-insert (Shift click) feature with this slot.Get the ActionHandler that defines how this ActionItem behavesorg.bukkit.inventory.ItemStackgetDisplay(org.bukkit.entity.Player viewer, GUISession session) This method returns the item (Bukkit) to be displayed in the inventory slot for a player.org.bukkit.inventory.ItemStackgetFormImage(org.bukkit.entity.Player viewer, GUISession session) This method returns the Form Image (Bedrock) to be displayed in the GUI for a player.voidThis method defines the behaviour of this GUIElement.voidsetActionHandler(ActionItem.ActionHandler actionHandler) Set the ActionHandler that should define how this ActionItem behavesvoidsetDisplayItem(org.bukkit.inventory.ItemStack display) voidsetFormImage(FormImage formImage) Methods inherited from class me.eddie.inventoryguiapi.gui.elements.AbstractGUIElement
getDesiredDisplayPosition, hasDesiredDisplayPosition, setDesiredDisplayPosition, setHasDesiredDisplayPosition
-
Constructor Details
-
ActionItem
public ActionItem(int slot, org.bukkit.inventory.ItemStack display, ActionItem.ActionHandler actionHandler, FormImage formImage) Construct a new ActionItem with a desired slot- Parameters:
slot- The slot that this ActionItem should be placed intodisplay- The display ItemStackactionHandler- The action for when this is clickedformImage- Image to use in Bedrock Form GUI, in place of a texture of provided displayItem
-
ActionItem
public ActionItem(int slot, org.bukkit.inventory.ItemStack display, ActionItem.ActionHandler actionHandler) Construct a new ActionItem with a desired slot- Parameters:
slot- The slot that this ActionItem should be placed intodisplay- The display ItemStackactionHandler- The action for when this is clicked
-
ActionItem
Construct a new ActionItem with no desired slot- Parameters:
display- The display ItemStackactionHandler- The action for when this is clicked
-
-
Method Details
-
getActionHandler
Get the ActionHandler that defines how this ActionItem behaves- Returns:
- The ActionHandler
-
setActionHandler
Set the ActionHandler that should define how this ActionItem behaves- Parameters:
actionHandler- The ActionHandler
-
getDisplayItem
public org.bukkit.inventory.ItemStack getDisplayItem() -
setDisplayItem
public void setDisplayItem(org.bukkit.inventory.ItemStack display) -
getFormImage
Description copied from interface:GUIElementThis method returns the Form Image (Bedrock) to be displayed in the GUI for a player.- Parameters:
viewer- The player viewing the inventory. In the case of SharedGUI's the viewer should be ignored.session- The GUISession that this GUIElement is being used with- Returns:
- The form image type to display to the viewer
-
setFormImage
-
onEvent
Description copied from interface:GUIElementThis method defines the behaviour of this GUIElement. Implementations should handle the event appropriately for the element's behaviour (Including cancelling the bukkit event responsible for the GUIEvent when necessary). GUIElements will only ever receive events that interact with them, eg. click, place and pickup events. This happens in response to an Inventory event, so don't do anything during this call that the Bukkit API docs don't recommend doing at this time.- Parameters:
event- The GUIEvent to handle
-
getDisplay
public org.bukkit.inventory.ItemStack getDisplay(org.bukkit.entity.Player viewer, GUISession session) Description copied from interface:GUIElementThis method returns the item (Bukkit) to be displayed in the inventory slot for a player. A returned value of null or an item of type AIR denotes that this slot in the inventory should be empty.- Parameters:
viewer- The player viewing the inventory. In the case of SharedGUI's the viewer should be ignored.session- The GUISession that this GUIElement is being used with- Returns:
- The itemstack to display to the viewer
-
canAutoInsertIntoSlot
Description copied from interface:GUIElementWhether or not viewers can use Minecraft's auto-insert (Shift click) feature with this slot. If they can then shift-clicking will be able to target this slot. Shift click events won't be passed directly to the GUIElement though, they are instead turned into pickup and place events and those are passed to GUIElements as appropriate.- Parameters:
Viewer- The viewer trying to auto insert into the slotsession- The GUISession trying to auto insert into the slot- Returns:
- True if auto-insert is enabled and False if not
-