java.lang.Object
io.github.somesourcecode.someguiapi.scene.Node
io.github.somesourcecode.someguiapi.scene.GuiItem

public class GuiItem extends Node
Represents an item in a GUI. Width and height are always 1.

GuiItems are used to represent singular items in a GUI and provide handlers for click events.

  • Constructor Details

    • GuiItem

      public GuiItem(org.bukkit.Material material)
      Constructs a new GuiItem with the specified material.
      Parameters:
      material - the material of the item
    • GuiItem

      public GuiItem(org.bukkit.Material material, net.kyori.adventure.text.Component title)
      Constructs a new GuiItem with the specified material and title.
      Parameters:
      material - the material of the item
      title - the title of the item
    • GuiItem

      public GuiItem(org.bukkit.Material material, net.kyori.adventure.text.Component title, Lore lore)
      Constructs a new GuiItem with the specified material, title, and lore.
      Parameters:
      material - the material of the item
      title - the title of the item
      lore - the lore of the item
  • Method Details

    • asItemStack

      public org.bukkit.inventory.ItemStack asItemStack()
      Returns the ItemStack representation of this item.
      Returns:
      the item stack
    • getMaterial

      public org.bukkit.Material getMaterial()
      Returns the material of this item.
      Returns:
      the material
    • setMaterial

      public void setMaterial(org.bukkit.Material material)
      Sets the material of this item.
      Parameters:
      material - the new material
    • getIndex

      public int getIndex()
      Returns the index of this item.
      Returns:
      the index
    • setIndex

      public void setIndex(int index)
      Sets the index of this item.
      Parameters:
      index - the new index
    • isGlow

      public boolean isGlow()
      Returns whether this item should have a glow effect. The glow effect is the effect applied to enchanted items.
      Returns:
      whether this item should glow
    • setGlow

      public void setGlow(boolean glow)
      Sets whether this item should have a glow effect. The glow effect is the effect applied to enchanted items.
      Parameters:
      glow - whether this item should glow
    • getTitle

      public net.kyori.adventure.text.Component getTitle()
      Returns the title of this item.
      Returns:
      the title
    • setTitle

      public void setTitle(net.kyori.adventure.text.Component title)
      Sets the title of this item.
      Parameters:
      title - the new title
    • setTitle

      public void setTitle(String title)
      Sets the title of this item. This method is a shorthand for setTitle(Component).
      Parameters:
      title - the new title
    • getLore

      public Lore getLore()
      Returns the lore of this item.
      Returns:
      the lore
    • setLore

      public void setLore(Lore lore)
      Sets the lore of this item.
      Parameters:
      lore - the new lore
    • getWidth

      public int getWidth()
      Description copied from class: Node
      Returns the width of the node.
      Specified by:
      getWidth in class Node
      Returns:
      the width of the node
    • getHeight

      public int getHeight()
      Description copied from class: Node
      Returns the height of the node.
      Specified by:
      getHeight in class Node
      Returns:
      the height of the node
    • isClipping

      public boolean isClipping()
      Description copied from class: Node
      Returns whether the node is clipping its children. If a node is clipping its children, children that are outside the bounds of the node will not be rendered.
      Overrides:
      isClipping in class Node
      Returns:
      whether the node is clipping its children
    • pixelAt

      public org.bukkit.inventory.ItemStack pixelAt(int x, int y)
      Returns an ItemStack representing the pixel at the given coordinates. The coordinates are relative to this parent's bounds.

      NOTE: This method implementation will always return the ItemStack constructed by asItemStack() if the given coordinates are within the bounds; null otherwise.

      Specified by:
      pixelAt in class Node
      Parameters:
      x - the x coordinate
      y - the y coordinate
      Returns:
      the ItemStack at the given coordinates, or null if there is no pixel at the given coordinates
    • nodeAt

      public Node nodeAt(int x, int y)
      Returns the node at the given coordinates. The coordinates are relative to this parent's bounds.

      NOTE: This method implementation will always return this item if the given coordinates are within the bounds of this item; null otherwise.

      Specified by:
      nodeAt in class Node
      Parameters:
      x - the x coordinate
      y - the y coordinate
      Returns:
      the node at the given coordinates, or null if there is no node at the given coordinates
    • create

      public static GuiItem.Builder create(org.bukkit.Material material)
      Constructs a new empty GuiItem builder with the given material.
      Parameters:
      material - the material of the item
      Returns:
      the builder