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.

Since:
1.0.0
  • Constructor Details

    • GuiItem

      public GuiItem()
      Constructs a new GuiItem with an empty pixel.
      Since:
      2.0.0
    • GuiItem

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

    • 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
    • getMaterial

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

      public void setMaterial(org.bukkit.Material material)
      Sets the material of this item.
      Parameters:
      material - the material
      Since:
      1.0.0
    • getTitle

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

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

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

      public void setLore(Lore lore)
      Sets the lore of this item.
      Parameters:
      lore - the lore
      Since:
      2.0.0
    • getIndex

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

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

      public boolean isGlow()
      Returns whether this item should glow.
      Returns:
      whether this item should glow
      Since:
      1.0.0
    • setGlow

      public void setGlow(boolean glow)
      Sets whether this item should glow.
      Parameters:
      glow - whether this item should glow
      Since:
      1.0.0
    • getPixel

      public Pixel getPixel()
      Returns the pixel representation of this item.
      Returns:
      the rendered ItemStack
      Since:
      2.0.0
    • renderPixelAt

      public Pixel renderPixelAt(int x, int y)
      Returns a Pixel that should be rendered at the given coordinates. The coordinates are relative to this parent's bounds.

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

      Specified by:
      renderPixelAt in class Node
      Parameters:
      x - the x coordinate
      y - the y coordinate
      Returns:
      the pixel 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(Pixel pixel)
      Constructs a new empty GuiItem builder with the given pixel.
      Parameters:
      pixel - the pixel of the item
      Returns:
      the builder
      Since:
      2.0.0
    • 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
      Since:
      1.0.0