Class ItemBuilder
java.lang.Object
com.bencodez.advancedcore.api.item.ItemBuilder
Easily create itemstacks, without messing your hands.
Credit to NonameSL for creating this
Modified by Ben12345rocks
-
Constructor Summary
ConstructorsConstructorDescriptionItemBuilder(String material) Constructs an ItemBuilder from a material string.ItemBuilder(org.bukkit.configuration.ConfigurationSection data) Create ItemBuilder from a ConfigurationSectionItemBuilder(org.bukkit.inventory.ItemStack is) Create a new ItemBuilder over an existing itemstack.ItemBuilder(org.bukkit.Material m) Create a new ItemBuilder from scratch.ItemBuilder(org.bukkit.Material material, int amount) Create a new ItemBuilder from scratch. -
Method Summary
Modifier and TypeMethodDescriptionaddAttributeModifier(org.bukkit.attribute.Attribute att, org.bukkit.attribute.AttributeModifier modifier) Adds an attribute modifier to the item.addEnchant(org.bukkit.enchantments.Enchantment ench, int level) Add an enchant to the item.addEnchantments(HashMap<String, Integer> enchants) Add multiple enchants at once.addEnchantments(Map<org.bukkit.enchantments.Enchantment, Integer> enchantments) Add multiple enchants at once.addGlow()Adds a glow effect to the item.addItemFlag(String flag) Adds an item flag to the item.addLoreLine(String line) Add a lore line.addLoreLine(String line, int pos) Add a lore line.addPlaceholder(String toReplace, String replaceWith) Adds a single placeholder.addPlaceholder(HashMap<String, String> placeholders) Adds a placeholder mapping.addPotionEffect(org.bukkit.potion.PotionEffectType type, int duration, int amplifier, org.bukkit.Color color) Adds a potion effect to the item.clone()Clone the ItemBuilder into a new one.Creates configuration data from this ItemBuilder.Disables lore length checking.booleancom.google.common.collect.Multimap<org.bukkit.attribute.Attribute, org.bukkit.attribute.AttributeModifier> Gets the attribute modifiers multimap.Collection<org.bukkit.attribute.AttributeModifier> getAttributeModifiers(org.bukkit.attribute.Attribute att) Gets the attribute modifiers for a specific attribute.getConditionItemBuilder(org.bukkit.OfflinePlayer player) Gets a conditional ItemBuilder based on player conditions.getConfiguration(boolean deseralize) Gets the configuration map.getCustomData(String key) Gets custom data from persistent data container.getLore()Gets the lore of the item.intGets the lore length setting.getName()Gets the item name.getRewardsPath(org.bukkit.entity.Player player) Gets the rewards path for the player.getSkull()Deprecated.org.bukkit.OfflinePlayerGets the skull owner.org.bukkit.MaterialgetType()Gets the item material type.booleanChecks if the item has attributes.booleanChecks if the item has a custom display name.booleanChecks if the item has custom lore.booleanhasGetItemModel(org.bukkit.inventory.meta.ItemMeta meta) Checks if the ItemMeta has getItemModel method.booleanChecks if the item has item meta.org.bukkit.inventory.ItemStackparsePlaceholders(org.bukkit.OfflinePlayer player) Parses placeholders in the item for the player.removeEnchantment(org.bukkit.enchantments.Enchantment ench) Remove a certain enchant from the item.Removes all lore from the item.removeLoreLine(int index) Remove a lore line.removeLoreLine(String line) Remove a lore line.setAmount(int amount) Sets the amount of items.setAmountNone(int i) Sets the amount only if current amount is zero.setCustomData(String key, String value) Sets custom data in the persistent data container.setCustomModelData(int data) Sets the custom model data.setDurability(short dur) Deprecated.setDyeColor(org.bukkit.DyeColor color) Deprecated.setFireworkPower(int power) Sets the firework power.setHeadFromBase64(String value) Sets the skull head from base64 texture.voidsetHideTooltipCompat(org.bukkit.inventory.ItemStack item, boolean hide) Hides (or shows) the item tooltip.Sets infinity durability on the item by setting the durability to Short.MAX_VALUE.setLeatherArmorColor(org.bukkit.Color color) Sets the armor color of a leather armor piece.Re-sets the lore.Re-sets the lore.setLoreLength(int length) Sets the lore length for wrapping.Set the displayname of the item.setNameIfNotExist(String name) Sets the item name only if it doesn't already have a custom display name.setPlaceholders(HashMap<String, String> placeholders) Sets the placeholder mappings.setSkullOwner(String owner) Deprecated.setSkullOwner(org.bukkit.OfflinePlayer offlinePlayer) Sets the skull owner by offline player.setSlot(int slot) Sets the slot for the item in an inventory.setUnbreakable(boolean unbreakable) Sets whether the item is unbreakable.org.bukkit.inventory.ItemStackDeprecated.Use toItemStack(Player player)org.bukkit.inventory.ItemStacktoItemStack(org.bukkit.entity.Player player) Converts the ItemBuilder to an ItemStack with player-specific placeholders.org.bukkit.inventory.ItemStacktoItemStack(org.bukkit.OfflinePlayer player) Converts the ItemBuilder to an ItemStack with player-specific placeholders.toString()
-
Constructor Details
-
ItemBuilder
public ItemBuilder(org.bukkit.configuration.ConfigurationSection data) Create ItemBuilder from a ConfigurationSection- Parameters:
data- ConfigurationSection
-
ItemBuilder
public ItemBuilder(org.bukkit.inventory.ItemStack is) Create a new ItemBuilder over an existing itemstack.- Parameters:
is- The itemstack to create the ItemBuilder over.
-
ItemBuilder
public ItemBuilder(org.bukkit.Material m) Create a new ItemBuilder from scratch.- Parameters:
m- The material to create the ItemBuilder with.
-
ItemBuilder
public ItemBuilder(org.bukkit.Material material, int amount) Create a new ItemBuilder from scratch.- Parameters:
material- The material of the item.amount- The amount of the item.
-
ItemBuilder
Constructs an ItemBuilder from a material string.- Parameters:
material- the material name
-
-
Method Details
-
setHideTooltipCompat
public void setHideTooltipCompat(org.bukkit.inventory.ItemStack item, boolean hide) Hides (or shows) the item tooltip. On 1.20.5+ this uses the native ItemMeta#setHideTooltip method; on older versions it simply adds all available ItemFlags (so at least most tooltip lines are hidden).- Parameters:
item- the ItemStack to modifyhide- true to hide, false to show
-
addAttributeModifier
public ItemBuilder addAttributeModifier(org.bukkit.attribute.Attribute att, org.bukkit.attribute.AttributeModifier modifier) Adds an attribute modifier to the item.- Parameters:
att- the attributemodifier- the attribute modifier- Returns:
- this ItemBuilder
-
addEnchant
Add an enchant to the item.- Parameters:
ench- The enchant to addlevel- The level- Returns:
- ItemBuilder
-
addEnchantments
Add multiple enchants at once.- Parameters:
enchants- The enchants to add.- Returns:
- ItemBuilder
-
addEnchantments
Add multiple enchants at once.- Parameters:
enchantments- The enchants to add.- Returns:
- ItemBuilder
-
addGlow
Adds a glow effect to the item.- Returns:
- this ItemBuilder
-
addItemFlag
Adds an item flag to the item.- Parameters:
flag- the flag name- Returns:
- this ItemBuilder
-
addLoreLine
Add a lore line.- Parameters:
line- The lore line to add.- Returns:
- ItemBuilder
-
addLoreLine
Add a lore line.- Parameters:
line- The lore line to add.pos- The index of where to put it.- Returns:
- ItemBuilder
-
addPlaceholder
Adds a placeholder mapping.- Parameters:
placeholders- the map of placeholders- Returns:
- this ItemBuilder
-
addPlaceholder
Adds a single placeholder.- Parameters:
toReplace- the text to replacereplaceWith- the replacement text- Returns:
- this ItemBuilder
-
addPotionEffect
public ItemBuilder addPotionEffect(org.bukkit.potion.PotionEffectType type, int duration, int amplifier, org.bukkit.Color color) Adds a potion effect to the item.- Parameters:
type- the potion effect typeduration- the durationamplifier- the amplifiercolor- the potion color- Returns:
- this ItemBuilder
-
clone
Clone the ItemBuilder into a new one. -
createConfigurationData
Creates configuration data from this ItemBuilder.- Returns:
- the configuration data map
-
dontCheckLoreLength
Disables lore length checking.- Returns:
- this ItemBuilder
-
equals
-
getAttributeModifiers
public com.google.common.collect.Multimap<org.bukkit.attribute.Attribute,org.bukkit.attribute.AttributeModifier> getAttributeModifiers()Gets the attribute modifiers multimap.- Returns:
- the attribute modifiers
-
getAttributeModifiers
public Collection<org.bukkit.attribute.AttributeModifier> getAttributeModifiers(org.bukkit.attribute.Attribute att) Gets the attribute modifiers for a specific attribute.- Parameters:
att- the attribute- Returns:
- the collection of attribute modifiers
-
getConditionItemBuilder
Gets a conditional ItemBuilder based on player conditions.- Parameters:
player- the player- Returns:
- the conditional ItemBuilder or this if no conditions match
-
getConfiguration
Gets the configuration map.- Parameters:
deseralize- whether to deserialize the item- Returns:
- the configuration map
-
hasGetItemModel
public boolean hasGetItemModel(org.bukkit.inventory.meta.ItemMeta meta) Checks if the ItemMeta has getItemModel method.- Parameters:
meta- the item meta- Returns:
- true if the method exists, false otherwise
-
getCustomData
Gets custom data from persistent data container.- Parameters:
key- the data key- Returns:
- the custom data value
-
getLore
Gets the lore of the item.- Returns:
- the lore list
-
getLoreLength
public int getLoreLength()Gets the lore length setting.- Returns:
- the lore length
-
getName
Gets the item name.- Returns:
- the item name
-
getRewardsPath
Gets the rewards path for the player.- Parameters:
player- the player- Returns:
- the rewards path
-
getSkull
Deprecated.- Returns:
- the skull
-
getSkullOwner
public org.bukkit.OfflinePlayer getSkullOwner()Gets the skull owner.- Returns:
- the skull owner
-
getType
public org.bukkit.Material getType()Gets the item material type.- Returns:
- the material
-
hasAttributes
public boolean hasAttributes()Checks if the item has attributes.- Returns:
- true if the item has attributes, false otherwise
-
hasCustomDisplayName
public boolean hasCustomDisplayName()Checks if the item has a custom display name.- Returns:
- true if the item has a custom display name, false otherwise
-
hasCustomLore
public boolean hasCustomLore()Checks if the item has custom lore.- Returns:
- true if the item has lore, false otherwise
-
hasItemMeta
public boolean hasItemMeta()Checks if the item has item meta.- Returns:
- true if the item has meta, false otherwise
-
parsePlaceholders
public org.bukkit.inventory.ItemStack parsePlaceholders(org.bukkit.OfflinePlayer player) Parses placeholders in the item for the player.- Parameters:
player- the player- Returns:
- the itemstack with parsed placeholders
-
removeEnchantment
Remove a certain enchant from the item.- Parameters:
ench- The enchantment to remove- Returns:
- ItemBuilder
-
removeLore
Removes all lore from the item.- Returns:
- this ItemBuilder
-
removeLoreLine
Remove a lore line.- Parameters:
index- The index of the lore line to remove.- Returns:
- ItemBuilder
-
removeLoreLine
Remove a lore line.- Parameters:
line- The lore to remove.- Returns:
- ItemBuilder
-
setAmount
Sets the amount of items.- Parameters:
amount- the amount to set- Returns:
- this ItemBuilder
-
setAmountNone
Sets the amount only if current amount is zero.- Parameters:
i- the amount to set- Returns:
- this ItemBuilder
-
setCustomData
Sets custom data in the persistent data container.- Parameters:
key- the data keyvalue- the data value- Returns:
- this ItemBuilder
-
setCustomModelData
Sets the custom model data.- Parameters:
data- the custom model data- Returns:
- this ItemBuilder
-
setDurability
Deprecated.Change the durability of the item.- Parameters:
dur- The durability to set it to.- Returns:
- ItemBuilder
-
setDyeColor
Deprecated.Sets the dye color on an item. * Notice that this doesn't check for item type, sets the literal data of the dyecolor as durability.- Parameters:
color- The color to put.- Returns:
- ItemBuilder
-
setFireworkPower
Sets the firework power.- Parameters:
power- the power level- Returns:
- this ItemBuilder
-
setHeadFromBase64
Sets the skull head from base64 texture.- Parameters:
value- the base64 texture value- Returns:
- this ItemBuilder
-
setInfinityDurability
Sets infinity durability on the item by setting the durability to Short.MAX_VALUE.- Returns:
- ItemBuilder
-
setLeatherArmorColor
Sets the armor color of a leather armor piece. Works only on leather armor pieces.- Parameters:
color- The color to set it to.- Returns:
- ItemBuilder
-
setLore
Re-sets the lore.- Parameters:
lore- The lore to set it to.- Returns:
- ItemBuilder
-
setLore
Re-sets the lore.- Parameters:
lore- The lore to set it to.- Returns:
- ItemBuilder
-
setLoreLength
Sets the lore length for wrapping.- Parameters:
length- the lore length- Returns:
- this ItemBuilder
-
setName
Set the displayname of the item.- Parameters:
name- The name to change it to.- Returns:
- ItemBuilder
-
setNameIfNotExist
Sets the item name only if it doesn't already have a custom display name.- Parameters:
name- the name to set- Returns:
- this ItemBuilder
-
setPlaceholders
Sets the placeholder mappings.- Parameters:
placeholders- the placeholders map- Returns:
- this ItemBuilder
-
setSkullOwner
Sets the skull owner by offline player.- Parameters:
offlinePlayer- the offline player- Returns:
- this ItemBuilder
-
setSkullOwner
Deprecated.Set the skull owner for the item. Works on skulls only.- Parameters:
owner- The name of the skull's owner.- Returns:
- ItemBuilder
-
setSlot
Sets the slot for the item in an inventory.- Parameters:
slot- the slot number- Returns:
- this ItemBuilder
-
setUnbreakable
Sets whether the item is unbreakable.- Parameters:
unbreakable- whether the item should be unbreakable- Returns:
- this ItemBuilder
-
toItemStack
Deprecated.Use toItemStack(Player player)Retrieves the itemstack from the ItemBuilder.- Returns:
- The itemstack created/modified by the ItemBuilder instance.
-
toItemStack
public org.bukkit.inventory.ItemStack toItemStack(org.bukkit.OfflinePlayer player) Converts the ItemBuilder to an ItemStack with player-specific placeholders.- Parameters:
player- the offline player for placeholder replacement- Returns:
- the final itemstack
-
toItemStack
public org.bukkit.inventory.ItemStack toItemStack(org.bukkit.entity.Player player) Converts the ItemBuilder to an ItemStack with player-specific placeholders.- Parameters:
player- the player for placeholder replacement- Returns:
- the final itemstack
-
toString
-