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.
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionGuiItem(org.bukkit.Material material) Constructs a new GuiItem with the specified material.GuiItem(org.bukkit.Material material, net.kyori.adventure.text.Component title) Constructs a new GuiItem with the specified material and title.Constructs a new GuiItem with the specified material, title, and lore. -
Method Summary
Modifier and TypeMethodDescriptionorg.bukkit.inventory.ItemStackReturns theItemStackrepresentation of this item.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.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 have a glow effect.nodeAt(int x, int y) Returns the node at the given coordinates.org.bukkit.inventory.ItemStackpixelAt(int x, int y) Returns anItemStackrepresenting the pixel at the given coordinates.voidsetGlow(boolean glow) Sets whether this item should have a glow effect.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.voidSets the title 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
getLayoutX, getLayoutY, getOnClick, getOnHotBarClick, getOnLeftClick, getOnRightClick, getOnShiftClick, getParent, getTranslateX, getTranslateY, isVisible, relocate, setClipping, setLayoutX, setLayoutY, setOnClick, setOnHotBarClick, setOnLeftClick, setOnRightClick, setOnShiftClick, setParent, setTranslateX, setTranslateY, setVisible
-
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 itemtitle- the title of the item
-
GuiItem
Constructs a new GuiItem with the specified material, title, and lore.- Parameters:
material- the material of the itemtitle- the title of the itemlore- the lore of the item
-
-
Method Details
-
asItemStack
public org.bukkit.inventory.ItemStack asItemStack()Returns theItemStackrepresentation 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
Sets the title of this item. This method is a shorthand forsetTitle(Component).- Parameters:
title- the new title
-
getLore
Returns the lore of this item.- Returns:
- the lore
-
setLore
Sets the lore of this item.- Parameters:
lore- the new lore
-
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
-
pixelAt
public org.bukkit.inventory.ItemStack pixelAt(int x, int y) Returns anItemStackrepresenting 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. -
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 material.- Parameters:
material- the material of the item- Returns:
- the builder
-