Interface ItemBuilder
ItemStacks.-
Method Summary
Modifier and TypeMethodDescriptionAdds an empty line to the lore.addEnchant(Enchantment ench, int lvl, boolean ignoreLevelRestriction) Adds the given enchantment to the item.Adds a line to the lore.Adds multiple lines to the lore.Adds multiple lines to the lore.addLoreNLable(String line) Adds a line to the lore, splitting it into multiple lines at new line characters.addLoreNLable(List<String> loreLines) Adds multiple lines to the lore, splitting each at new line characters.intamount()Gets the current amount of the item.amount(int amount) Changes the amount of the item.build()Builds the item.Clears the lore of the item.cloned()Clones the item used by this builder.computeLoreComponents(UnaryOperator<String> lineOperator) Computes all lore lines using the given operator.Dyes the item with the given team's color.Dyes the item with the given color.Sets an empty display name for the item.intenchantLevel(Enchantment ench) Get the level of the given enchantment on the item.friendlyDescription(String description, ChatColor lineColor) Sets the name and lore of the item with auto-wrapping.@Nullable ItemMetaGets the internal item meta used by this builder.glowing()Makes the item glowing like it has an enchantment.booleanhasLore()Get whether this item has any lore line.booleanhasName()Checks whether the item has a custom display name.Hides all attributes of the item (like attack damage, armor, etc.).booleanChecks whether the item is metaless (like air).Changes the lore of the item.Changes the lore of the item.intGet the amount of lines the lore has.Sets a maximum stack amount possible for the item (1.20.5+ only).name()Gets the current name of the item.Changes the display name of the item.static ItemBuilderCreates a new item builder for the given item.static ItemBuilderCreates a new item builder for the given material.static ItemBuilderCreates a new item builder for the given material and amount.replaceLore(int line, String replacement) Attempts to replace a line in the lore.Makes the item unbreakable.
-
Method Details
-
name
Changes the display name of the item.- Parameters:
name- The new name- Returns:
- this builder
-
emptyName
-
name
-
hasName
boolean hasName()Checks whether the item has a custom display name.- Returns:
trueif it has a display name, otherwisefalse
-
amount
Changes the amount of the item.- Parameters:
amount- The new amount- Returns:
- this builder
-
amount
int amount()Gets the current amount of the item.- Returns:
- the amount
-
lore
Changes the lore of the item.- Parameters:
lore- The new lore- Returns:
- this builder
-
lore
Changes the lore of the item.- Parameters:
lore- The new lore- Returns:
- this builder
-
addLore
Adds a line to the lore.- Parameters:
line- The line to add- Returns:
- this builder
-
addLoreNLable
Adds a line to the lore, splitting it into multiple lines at new line characters.- Parameters:
line- The line(s) to add- Returns:
- this builder
-
addLore
Adds multiple lines to the lore.- Parameters:
loreLines- The lines to add- Returns:
- this builder
-
addLore
Adds multiple lines to the lore.- Parameters:
loreLines- The lines to add- Returns:
- this builder
-
addLoreNLable
Adds multiple lines to the lore, splitting each at new line characters.- Parameters:
loreLines- The lines to add- Returns:
- this builder
-
addEmptyLore
-
replaceLore
Attempts to replace a line in the lore.Nothing happens if line is less than 0, or greater than/equal to
loreLines().- Parameters:
line- The line / entry to replace, starting at 0replacement- The new value of the line- Returns:
- this builder
-
computeLoreComponents
Computes all lore lines using the given operator.Depending on the server variant used, the operator might get called for each line straight or only the contents of text components for each component in every line.
- Parameters:
lineOperator- The operator for each text component or line- Returns:
- this builder
-
clearLore
-
hasLore
boolean hasLore()Get whether this item has any lore line.- Returns:
trueif it has lore, otherwisefalse
-
loreLines
int loreLines()Get the amount of lines the lore has.- Returns:
- Amount of lines / entries in the lore
-
friendlyDescription
Sets the name and lore of the item with auto-wrapping.The description is split into multiple lines at new line characters and wrapped at 40 - 50 characters, if necessary.
Each line is colored with the given line color. The first line is being set as the display name of the item (
name(String)) and the rest as lore lines (lore(List)).- Parameters:
description- The description to set as name and lorelineColor- The color for each line- Returns:
- this builder
-
addEnchant
Adds the given enchantment to the item.- Parameters:
ench- The enchantmentlvl- The levelignoreLevelRestriction- Whether to ignore level restrictions- Returns:
- this builder
-
enchantLevel
Get the level of the given enchantment on the item.- Parameters:
ench- The enchantment- Returns:
- the level, or
0if the item does not have the enchantment
-
dye
Dyes the item with the given color.Only works for dyeable items (like leather armor, wool, etc.).
- Parameters:
color- The dye color- Returns:
- this builder
-
dye
Dyes the item with the given team's color.Only works for dyeable items (like leather armor, wool, etc.). Uses
Team.getDyeColor().- Parameters:
team- The team- Returns:
- this builder
-
hideAttributes
ItemBuilder hideAttributes()Hides all attributes of the item (like attack damage, armor, etc.).- Returns:
- this builder
-
glowing
ItemBuilder glowing()Makes the item glowing like it has an enchantment.- Returns:
- this builder
- See Also:
-
unbreakable
-
maxStackLimit
ItemBuilder maxStackLimit()Sets a maximum stack amount possible for the item (1.20.5+ only).- Returns:
- this builder
-
cloned
-
build
-
getInternalMeta
Gets the internal item meta used by this builder.- Returns:
- the item meta, may be
nullif the item has no meta at all (air)
-
isMetaless
boolean isMetaless()Checks whether the item is metaless (like air).- Returns:
trueif metaless, otherwisefalse
-
of
Creates a new item builder for the given item.Modifies the given item instance unless
cloned()is called.- Parameters:
item- The item- Returns:
- the item builder
-
of
Creates a new item builder for the given material.- Parameters:
mat- The material- Returns:
- the item builder
-
of
Creates a new item builder for the given material and amount.- Parameters:
mat- The materialamount- The amount- Returns:
- the item builder
-