Class ItemBuilder
java.lang.Object
tech.guilhermekaua.spigotboot.core.utils.ItemBuilder
A utility class that helps to create and modify ItemStacks.
-
Constructor Summary
ConstructorsConstructorDescriptionItemBuilder(String url) Creates a new ItemBuilder with a skull item from the given URL.ItemBuilder(org.bukkit.inventory.ItemStack item) Creates a new ItemBuilder with the given ItemStack.ItemBuilder(org.bukkit.Material type) Creates a new ItemBuilder with the given Material type.ItemBuilder(org.bukkit.Material type, int data) Creates a new ItemBuilder with the given Material type and data value.ItemBuilder(org.bukkit.Material type, org.bukkit.Color color) Creates a new ItemBuilder with a leather armor item of the given color. -
Method Summary
Modifier and TypeMethodDescriptionAdds a string to the lore of the ItemStack at the given index.Adds some strings to the lore of the ItemStack.changeItemMeta(Consumer<org.bukkit.inventory.meta.ItemMeta> consumer) Changes the ItemMeta of the ItemStack using the given Consumer function.deleteLoreLine(int index) Deletes a string from the lore of the ItemStack at the given index.intFinds the index of a string in the lore of the ItemStack that contains the given substring.getLore()Returns the lore of the ItemStack as a list of strings.placeholder(String placeholder, String value) Replaces a placeholder in the lore of the ItemStack with a given value.setGlow(boolean glow) setItem(org.bukkit.inventory.ItemStack item) Replaces a string in the lore of the ItemStack at the given index.Sets the lore of the ItemStack.Sets the lore of the ItemStack.Sets the display name of the ItemStack.org.bukkit.inventory.ItemStackwrap()Returns the ItemStack that this builder is working on.
-
Constructor Details
-
ItemBuilder
public ItemBuilder(org.bukkit.inventory.ItemStack item) Creates a new ItemBuilder with the given ItemStack.- Parameters:
item- the ItemStack to use
-
ItemBuilder
public ItemBuilder(org.bukkit.Material type) Creates a new ItemBuilder with the given Material type.- Parameters:
type- the Material type to use
-
ItemBuilder
public ItemBuilder(org.bukkit.Material type, int data) Creates a new ItemBuilder with the given Material type and data value.- Parameters:
type- the Material type to usedata- the data value to use
-
ItemBuilder
Creates a new ItemBuilder with a skull item from the given URL.- Parameters:
url- the URL to get the skull item from
-
ItemBuilder
public ItemBuilder(org.bukkit.Material type, org.bukkit.Color color) Creates a new ItemBuilder with a leather armor item of the given color.- Parameters:
type- the Material type to usecolor- the Color to use
-
-
Method Details
-
setItem
-
setGlow
-
changeItemMeta
Changes the ItemMeta of the ItemStack using the given Consumer function.- Parameters:
consumer- the Consumer function to apply to the ItemMeta- Returns:
- this ItemBuilder instance for chaining
-
setName
Sets the display name of the ItemStack.- Parameters:
name- the display name to use- Returns:
- this ItemBuilder instance for chaining
-
addLore
Adds some strings to the lore of the ItemStack.- Parameters:
lore- an array of strings to add to the lore- Returns:
- this ItemBuilder instance for chaining
-
addLore
Adds a string to the lore of the ItemStack at the given index.- Parameters:
index- the index to insert the string atlore- the string to add to the lore- Returns:
- this ItemBuilder instance for chaining
-
setLore
Replaces a string in the lore of the ItemStack at the given index.- Parameters:
index- the index to replace the string atlore- the string to replace in the lore- Returns:
- this ItemBuilder instance for chaining
-
deleteLoreLine
Deletes a string from the lore of the ItemStack at the given index.- Parameters:
index- the index to delete the string from- Returns:
- this ItemBuilder instance for chaining
-
findLore
Finds the index of a string in the lore of the ItemStack that contains the given substring.- Parameters:
lore- the substring to look for in the lore- Returns:
- the index of the string that contains the substring, or -1 if not found
-
getLore
Returns the lore of the ItemStack as a list of strings.- Returns:
- the lore of the ItemStack, or null if none
-
setLore
Sets the lore of the ItemStack.- Parameters:
lore- an array of strings to use as the lore- Returns:
- this ItemBuilder instance for chaining
-
setLore
Sets the lore of the ItemStack.- Parameters:
lore- a list of strings to use as the lore- Returns:
- this ItemBuilder instance for chaining
-
placeholder
Replaces a placeholder in the lore of the ItemStack with a given value.- Parameters:
placeholder- the placeholder to replacevalue- the value to replace with- Returns:
- this ItemBuilder instance for chaining
-
wrap
public org.bukkit.inventory.ItemStack wrap()Returns the ItemStack that this builder is working on.- Returns:
- the ItemStack instance
-