Class ItemCreator
java.lang.Object
com.github.pinont.singularitylib.api.items.ItemCreator
- Direct Known Subclasses:
CrossbowCreator, ItemHeadCreator
Builder class for creating and modifying ItemStacks with enhanced functionality.
Provides a fluent API for setting item properties, adding enchantments, lore, tags, and interactions.
-
Constructor Summary
ConstructorsConstructorDescriptionItemCreator(org.bukkit.plugin.Plugin plugin, @NotNull org.bukkit.inventory.ItemStack item) Creates a new ItemCreator from an existing ItemStack.ItemCreator(org.bukkit.plugin.Plugin plugin, org.bukkit.Material type) Creates a new ItemCreator for the specified material type.ItemCreator(org.bukkit.plugin.Plugin plugin, org.bukkit.Material type, int amount) Creates a new ItemCreator for the specified material type and amount. -
Method Summary
Modifier and TypeMethodDescriptionaddAttribute(AttributeType attributeType, double amount, org.bukkit.attribute.AttributeModifier.Operation operation, org.bukkit.inventory.EquipmentSlot slot) Adds an attribute modifier to the item.addEnchant(org.bukkit.enchantments.Enchantment enchantment, int level, boolean ignoreLevelRestriction) Adds an enchantment to the item.addInteraction(ItemInteraction itemInteraction) Adds an interaction to the item.addItemFlag(org.bukkit.inventory.ItemFlag... flags) Adds item flags to hide certain item properties.Adds lore to the item.Adds lore to the item.addLore(net.kyori.adventure.text.Component... lores) Adds lore to the item.Adds a single tag to the item.Adds a tag with a specific value to the item.Adds tags to the item.clone()org.bukkit.inventory.ItemStackcreate()Creates the final ItemStack with all applied properties.intGets the amount of items in the stack.static Set<ItemInteraction> Gets all registered item interactions.org.bukkit.inventory.meta.ItemMetaGets the ItemMeta of the item.Gets the value of a specific key from the item's tags.getName()Gets the display name of the item.getTagValue(String key) Gets the value of a specific tag.org.bukkit.MaterialgetType()Gets the material type of the item.Checks if the item has a specific tag.Removes a tag from the item.replaceTag(String oldKey, String newKey) Replaces an existing tag with a new key.setAmount(int amount) Sets the amount of items in the stack.setCannotMove(boolean b) Sets whether the item can be moved in inventories.setDataContainer(String key, Object value, PersistType type) Sets data in the item's PersistentDataContainer.setDurability(int durability) Sets the durability of the item.setDurability(short durability) Sets the durability of the item.setItemMeta(org.bukkit.inventory.meta.ItemMeta meta) Sets the ItemMeta for the item.setModelData(int data) Sets the custom model data for the item.Sets the display name of the item.setName(@Nullable net.kyori.adventure.text.Component name) Sets the display name of the item using a Component.setTagValue(String key, String newValue) Sets the value of a specific tag.setType(org.bukkit.Material type) Sets the material type of the item.setUnbreakable(boolean unbreakable) Sets whether the item is unbreakable.setUnstackable(boolean bool) Sets the item as unstackable.
-
Constructor Details
-
ItemCreator
public ItemCreator(org.bukkit.plugin.Plugin plugin, org.bukkit.Material type) Creates a new ItemCreator for the specified material type.- Parameters:
type- the material type for the item
-
ItemCreator
public ItemCreator(org.bukkit.plugin.Plugin plugin, org.bukkit.Material type, int amount) Creates a new ItemCreator for the specified material type and amount.- Parameters:
type- the material type for the itemamount- the amount of items in the stack
-
ItemCreator
public ItemCreator(org.bukkit.plugin.Plugin plugin, @NotNull @NotNull org.bukkit.inventory.ItemStack item) Creates a new ItemCreator from an existing ItemStack.- Parameters:
item- the ItemStack to create from
-
-
Method Details
-
getInteractions
Gets all registered item interactions.- Returns:
- set of all item interactions
-
clone
-
getName
-
getItemMeta
public org.bukkit.inventory.meta.ItemMeta getItemMeta()Gets the ItemMeta of the item.- Returns:
- the ItemMeta
-
getType
public org.bukkit.Material getType()Gets the material type of the item.- Returns:
- the material type
-
getAmount
public int getAmount()Gets the amount of items in the stack.- Returns:
- the amount
-
create
public org.bukkit.inventory.ItemStack create()Creates the final ItemStack with all applied properties.- Returns:
- the created ItemStack
-
hasTag
-
getKey
-
addLore
Adds lore to the item.- Parameters:
lore- the lore text to add- Returns:
- this ItemCreator for method chaining
-
setItemMeta
Sets the ItemMeta for the item.- Parameters:
meta- the ItemMeta to set- Returns:
- this ItemCreator for method chaining
-
setType
Sets the material type of the item.- Parameters:
type- the material type to set- Returns:
- this ItemCreator for method chaining
-
addItemFlag
Adds item flags to hide certain item properties.- Parameters:
flags- the item flags to add- Returns:
- this ItemCreator for method chaining
-
setCannotMove
Sets whether the item can be moved in inventories.- Parameters:
b- true if the item cannot be moved, false otherwise- Returns:
- this ItemCreator for method chaining
-
setAmount
Sets the amount of items in the stack.- Parameters:
amount- the amount to set- Returns:
- this ItemCreator for method chaining
-
setName
Sets the display name of the item.- Parameters:
name- the display name to set- Returns:
- this ItemCreator for method chaining
-
setName
Sets the display name of the item using a Component.- Parameters:
name- the Component display name to set- Returns:
- this ItemCreator for method chaining
-
setDurability
Sets the durability of the item.- Parameters:
durability- the durability value- Returns:
- this ItemCreator for method chaining
-
setUnbreakable
Sets whether the item is unbreakable.- Parameters:
unbreakable- true if the item should be unbreakable, false otherwise- Returns:
- this ItemCreator for method chaining
-
addEnchant
public ItemCreator addEnchant(org.bukkit.enchantments.Enchantment enchantment, int level, boolean ignoreLevelRestriction) Adds an enchantment to the item.- Parameters:
enchantment- the enchantment to addlevel- the level of the enchantmentignoreLevelRestriction- whether to ignore level restrictions- Returns:
- this ItemCreator for method chaining
-
addLore
Adds lore to the item.- Parameters:
lores- the lore texts to add- Returns:
- this ItemCreator for method chaining
-
addLore
Adds lore to the item.- Parameters:
lores- the lore Components to add- Returns:
- this ItemCreator for method chaining
-
addAttribute
public ItemCreator addAttribute(AttributeType attributeType, double amount, org.bukkit.attribute.AttributeModifier.Operation operation, org.bukkit.inventory.EquipmentSlot slot) Adds an attribute modifier to the item.- Parameters:
attributeType- the type of the attribute to modifyamount- the amount to modify the attribute byoperation- the operation to perform (addition, multiplication, etc.)slot- the equipment slot this modifier applies to- Returns:
- this ItemCreator for method chaining
-
setUnstackable
Sets the item as unstackable.- Parameters:
bool- true to make the item unstackable, false otherwise- Returns:
- this ItemCreator for method chaining
-
setModelData
Sets the custom model data for the item.- Parameters:
data- the custom model data value- Returns:
- this ItemCreator for method chaining
-
addTags
Adds tags to the item.- Parameters:
tags- the tags to add- Returns:
- this ItemCreator for method chaining
-
addTag
Adds a single tag to the item.- Parameters:
key- the key of the tag to add- Returns:
- this ItemCreator for method chaining
-
addTag
Adds a tag with a specific value to the item.- Parameters:
key- the key of the tag to addvalue- the value of the tag- Returns:
- this ItemCreator for method chaining
-
replaceTag
Replaces an existing tag with a new key.- Parameters:
oldKey- the current key of the tagnewKey- the new key to replace with- Returns:
- this ItemCreator for method chaining
-
getTagValue
-
setTagValue
Sets the value of a specific tag.- Parameters:
key- the key of the tag to set the value fornewValue- the new value to set- Returns:
- this ItemCreator for method chaining
-
removeTag
Removes a tag from the item.- Parameters:
tag- the tag to remove- Returns:
- this ItemCreator for method chaining
-
setDurability
Sets the durability of the item.- Parameters:
durability- the durability value- Returns:
- this ItemCreator for method chaining
-
setDataContainer
Sets data in the item's PersistentDataContainer.- Parameters:
key- the key of the data to setvalue- the value to settype- the type of the data- Returns:
- this ItemCreator for method chaining
-
addInteraction
Adds an interaction to the item.- Parameters:
itemInteraction- the ItemInteraction to add- Returns:
- this ItemCreator for method chaining
-