Interface GUIElement

All Known Implementing Classes:
AbstractGUIElement, ActionItem, InputSlot, LabelItem

public interface GUIElement
Represents an element in a GUI and defines it's behaviour.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    canAutoInsertIntoSlot(org.bukkit.entity.Player viewer, GUISession session)
    Whether or not viewers can use Minecraft's auto-insert (Shift click) feature with this slot.
    int
    Return the desired display position of this GUI Element in the inventory.
    org.bukkit.inventory.ItemStack
    getDisplay(org.bukkit.entity.Player viewer, GUISession session)
    This method returns the item (Bukkit) to be displayed in the inventory slot for a player.
    getFormImage(org.bukkit.entity.Player viewer, GUISession session)
    This method returns the Form Image (Bedrock) to be displayed in the GUI for a player.
    boolean
    Returns true if this element has a specific place it wants to be placed in a GUI or false if it doesn't matter.
    void
    This method defines the behaviour of this GUIElement.
  • Method Details

    • hasDesiredDisplayPosition

      boolean hasDesiredDisplayPosition()
      Returns true if this element has a specific place it wants to be placed in a GUI or false if it doesn't matter. (Insertion order is then used)
      Returns:
      True if element has desired display position, False otherwise
    • getDesiredDisplayPosition

      int getDesiredDisplayPosition()
      Return the desired display position of this GUI Element in the inventory. If hasDesiredDisplayPosition() is false this is ignored, otherwise it is used when calculating an inventory to be displayed. The slot number returned should be greater than or equal to 0 and less than the maximum size of the inventory it's being inserted into
      Returns:
      The desired display position of the GUIElement
    • onEvent

      void onEvent(GUIEvent event)
      This 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

      org.bukkit.inventory.ItemStack getDisplay(org.bukkit.entity.Player viewer, GUISession session)
      This 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
    • getFormImage

      FormImage getFormImage(org.bukkit.entity.Player viewer, GUISession session)
      This 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
    • canAutoInsertIntoSlot

      boolean canAutoInsertIntoSlot(org.bukkit.entity.Player viewer, GUISession session)
      Whether 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 slot
      session - The GUISession trying to auto insert into the slot
      Returns:
      True if auto-insert is enabled and False if not