Class GuiItem
java.lang.Object
io.github.somesourcecode.someguiapi.scene.Node
io.github.somesourcecode.someguiapi.scene.GuiItem
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
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic GuiItem.BuilderConstructs a new empty GuiItem builder with the given pixel.static GuiItem.Buildercreate(org.bukkit.Material material) Constructs a new empty GuiItem builder with the given material.intReturns the height of the node.intgetIndex()Returns the index of this item.getLore()Returns the lore of this item.org.bukkit.MaterialReturns the material of this item.getPixel()Returns the pixel representation of this item.net.kyori.adventure.text.ComponentgetTitle()Returns the title of this item.intgetWidth()Returns the width of the node.booleanReturns whether the node is clipping its children.booleanisGlow()Returns whether this item should glow.nodeAt(int x, int y) Returns the node at the given coordinates.renderPixelAt(int x, int y) Returns aPixelthat should be rendered at the given coordinates.voidsetGlow(boolean glow) Sets whether this item should glow.voidsetIndex(int index) Sets the index of this item.voidSets the lore of this item.voidsetMaterial(org.bukkit.Material material) Sets the material of this item.voidsetTitle(net.kyori.adventure.text.Component title) Sets the title of this item.Methods inherited from class io.github.somesourcecode.someguiapi.scene.Node
getId, getLayoutX, getLayoutY, getOnClick, getOnHotBarClick, getOnLeftClick, getOnRightClick, getOnShiftClick, getParent, getScene, getTranslateX, getTranslateY, isVisible, lookup, lookupAll, lookupAll, relocate, requestParentLayout, setClipping, setId, setLayoutX, setLayoutY, setOnClick, setOnHotBarClick, setOnLeftClick, setOnRightClick, setOnShiftClick, setTranslateX, setTranslateY, setVisible
-
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:NodeReturns the width of the node. -
getHeight
public int getHeight()Description copied from class:NodeReturns the height of the node. -
isClipping
public boolean isClipping()Description copied from class:NodeReturns 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:
isClippingin classNode- 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
Returns the lore of this item.- Returns:
- the lore
- Since:
- 2.0.0
-
setLore
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
Returns the pixel representation of this item.- Returns:
- the rendered ItemStack
- Since:
- 2.0.0
-
renderPixelAt
Returns aPixelthat 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:
renderPixelAtin classNode- Parameters:
x- the x coordinatey- the y coordinate- Returns:
- the pixel at the given coordinates, or null if there is no pixel at the given coordinates
-
nodeAt
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.
-
create
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
Constructs a new empty GuiItem builder with the given material.- Parameters:
material- the material of the item- Returns:
- the builder
- Since:
- 1.0.0
-