Class ItemBuilder
java.lang.Object
net.apartium.cocoabeans.spigot.inventory.ItemBuilder
Chained class used to modify and create item stacks.
via the building structure and allows easy and flexible ways to create ItemStacks.
-
Method Summary
Modifier and TypeMethodDescriptionaddAttributeModifiers(org.bukkit.attribute.Attribute attribute, org.bukkit.attribute.AttributeModifier attributeModifier) Add attribute modifier the the item.addCanDestroy(String... ids) Add can destroy flag to the current itemaddCanPlaceOn(String... ids) Add can place on flag to the current itemaddEnchantment(org.bukkit.enchantments.Enchantment enchantment, int level) Adds an enchantment to the map list to finally enchant the item when is constructed.addItemFlags(org.bukkit.inventory.ItemFlag... itemFlags) Add item flags to the item.addLoreLine(String line) Add line to lore of the itemaddLoreLine(net.kyori.adventure.text.Component component) Add line to lore of the itemaddLoreLines(String... lines) Add lines to lore of the itemaddLoreLines(net.kyori.adventure.text.Component... components) Add lines to lore of the itemaddPotionEffect(org.bukkit.potion.PotionEffect potionEffect) Add potion effect to this item if potion, otherwise do nothingorg.bukkit.inventory.ItemStackbuild()Build current item builder instance and return a copy of produced itemstatic ItemBuilderbuilder(org.bukkit.inventory.ItemStack itemStack) Create a new item builder instance from given item stack.static ItemBuilderbuilder(org.bukkit.Material material) Create a new item builder instance based on given materialremoveEnchantment(org.bukkit.enchantments.Enchantment enchantment) Removes an enchantment from the map list to finally enchant the item when is constructed.removeLine(int index) removeLine(String text) setAmount(int amount) Set the amount of the item in the stacksetAttributeModifiers(com.google.common.collect.Multimap<org.bukkit.attribute.Attribute, org.bukkit.attribute.AttributeModifier> map) Set attribute modifiers of the item.setColor(org.bukkit.Color color) Set item color if item meta supports itsetCustomModelData(int data) Set custom model data of the item.setDisplayName(String name) setDisplayName(net.kyori.adventure.text.Component component) abstract ItemBuildersetDurability(short durability) setEnchantment(Map<org.bukkit.enchantments.Enchantment, Integer> enchantments) Sets an enchantment to the map list to finally enchant the item when is constructed.setGlowing(boolean isGlowing) This method requires to include theEnchantGlowclass.setLore(net.kyori.adventure.text.Component lore) setLoreAsText(List<String> lore) set nbt with key type and valueabstract ItemBuildersetOwningPlayer(org.bukkit.OfflinePlayer offlinePlayer) Applicable for skulls.setPotionData(org.bukkit.potion.PotionData potionData) Set potion data if this item stack is a potion, otherwise do nothingsetSkullProfile(com.destroystokyo.paper.profile.PlayerProfile profile) Set profile associated with a skullsetSkullTextureBase64(String base64) setSkullTextureURL(URL url) setType(org.bukkit.Material material) Set type of the item.abstract ItemBuildersetUnbreakable(boolean value) Set this item as unbreakable or notstatic ItemBuilderskullBuilder(com.destroystokyo.paper.profile.PlayerProfile playerProfile) Create a new item builder instance constituting of given player's skullstatic ItemBuilderskullBuilder(String base64) Create a new item builder instance constituting of skull by given base64 encoded stringstatic ItemBuilderskullBuilder(URL url) Create a new item builder instance constituting of skull from given urlstatic ItemBuilderskullBuilder(org.bukkit.OfflinePlayer offlinePlayer) Create a new item builder instance constituting of given player's skull
-
Method Details
-
builder
Create a new item builder instance from given item stack. Clones given item stack to avoid problems.- Parameters:
itemStack- item stack to copy into new builder instance- Returns:
- new builder instance
-
builder
Create a new item builder instance based on given material- Parameters:
material- material to use- Returns:
- new builder instance
-
skullBuilder
Create a new item builder instance constituting of given player's skull- Parameters:
offlinePlayer- offline player to make skull of- Returns:
- new builder instance
-
skullBuilder
Create a new item builder instance constituting of given player's skull- Parameters:
playerProfile- profile containing player's textures- Returns:
- new builder instance
-
skullBuilder
Create a new item builder instance constituting of skull from given url- Parameters:
url- skull url- Returns:
- new builder instance
-
skullBuilder
Create a new item builder instance constituting of skull by given base64 encoded string- Parameters:
base64- head value- Returns:
- new builder instance
-
setSkullTextureBase64
- Parameters:
base64- set skull texture with base64- Returns:
- current instance
- Throws:
MalformedURLException
-
setOwningPlayer
Applicable for skulls.- Parameters:
offlinePlayer- player- Returns:
- current instance
- See Also:
-
setSkullProfile
Set profile associated with a skull- Parameters:
profile- profile with textures- Returns:
- current instance
-
setSkullTextureURL
- Parameters:
url- set skull texture with url to the texture- Returns:
- current instance
-
setLore
- Parameters:
texts- set lore with texts- Returns:
- current instance
-
setLore
- Parameters:
lore- set lore- Returns:
- current instance
-
setLore
- Parameters:
lore- set lore- Returns:
- current instance
-
setLoreAsText
- Parameters:
lore- set lore- Returns:
- current instance
-
setDurability
- Parameters:
durability- set durability to the item- Returns:
- current instance
-
setDisplayName
- Parameters:
component- set item name to component name- Returns:
- current instance
-
setDisplayName
- Parameters:
name- set item name to name- Returns:
- current instance
-
setNBT
public ItemBuilder setNBT(org.bukkit.NamespacedKey namespacedKey, Object persistentDataType, Object object) set nbt with key type and value- Parameters:
namespacedKey- nbt keypersistentDataType- data typeobject- object as value- Returns:
- current instance
-
setAttributeModifiers
public ItemBuilder setAttributeModifiers(com.google.common.collect.Multimap<org.bukkit.attribute.Attribute, org.bukkit.attribute.AttributeModifier> map) Set attribute modifiers of the item.- Parameters:
map- attribute modifiers- Returns:
- current instance
- See Also:
-
ItemMeta.setAttributeModifiers(Multimap)
-
addAttributeModifiers
public ItemBuilder addAttributeModifiers(org.bukkit.attribute.Attribute attribute, org.bukkit.attribute.AttributeModifier attributeModifier) Add attribute modifier the the item.- Parameters:
attribute- attributeattributeModifier- modifier- Returns:
- current instance
- See Also:
-
ItemMeta.addAttributeModifier(Attribute, AttributeModifier)
-
setAmount
Set the amount of the item in the stack- Parameters:
amount- new amount to set- Returns:
- current instance
-
addLoreLines
Add lines to lore of the item- Parameters:
lines- add lines to lore- Returns:
- current instance
-
addLoreLine
Add line to lore of the item- Parameters:
line- add lines to lore- Returns:
- current instance
-
addLoreLines
@AvailableSince("0.0.36") public ItemBuilder addLoreLines(net.kyori.adventure.text.Component... components) Add lines to lore of the item- Parameters:
components- add lines to lore- Returns:
- current instance
-
addLoreLine
@AvailableSince("0.0.36") public ItemBuilder addLoreLine(net.kyori.adventure.text.Component component) Add line to lore of the item- Parameters:
component- add lines to lore- Returns:
- current instance
-
removeLine
- Parameters:
text- remove line by text- Returns:
- current instance
-
removeLine
- Parameters:
index- remove line by index- Returns:
- current instance
-
setCustomModelData
Set custom model data of the item.- Parameters:
data- custom model data- Returns:
- current instance
- See Also:
-
ItemMeta.setCustomModelData(Integer)
-
setColor
Set item color if item meta supports it- Parameters:
color- color to set- Returns:
- current instance
- See Also:
-
LeatherArmorMeta.setColor(Color)PotionMeta.setColor(Color)FireworkEffect.getColors()FireworkEffect.getFadeColors()
-
addEnchantment
Adds an enchantment to the map list to finally enchant the item when is constructed.- Parameters:
enchantment- The enchantment to uselevel- The level to set the enchantment to (is allowing unsafe.)
-
removeEnchantment
Removes an enchantment from the map list to finally enchant the item when is constructed.- Parameters:
enchantment- The enchantment to remove
-
setEnchantment
Sets an enchantment to the map list to finally enchant the item when is constructed.- Parameters:
enchantments- The enchantments to use
-
setGlowing
This method requires to include theEnchantGlowclass. Makes the item glow like its enchanted, but does not actually register the enchantment as anything, simply commits that the item is enchanted.- Parameters:
isGlowing- Set the item to glow, if false this will revoke glow.
-
setType
Set type of the item.- Parameters:
material- type to set- Returns:
- current instance
-
setUnbreakable
Set this item as unbreakable or not- Parameters:
value- true for unbreakable, else false- Returns:
- current instance
- See Also:
-
ItemMeta.setUnbreakable(boolean)
-
addItemFlags
Add item flags to the item.- Parameters:
itemFlags- item flags to add- Returns:
- current instance
-
setPotionData
Set potion data if this item stack is a potion, otherwise do nothing- Parameters:
potionData- potion data to set- Returns:
- current instance
-
addPotionEffect
Add potion effect to this item if potion, otherwise do nothing- Parameters:
potionEffect- potion effect to add- Returns:
- current instance
-
addCanDestroy
Add can destroy flag to the current item- Parameters:
ids- ids- Returns:
- current instance
-
addCanPlaceOn
Add can place on flag to the current item- Parameters:
ids- ids- Returns:
- current instance
-
build
public org.bukkit.inventory.ItemStack build()Build current item builder instance and return a copy of produced item- Returns:
- cloned item stack instance
-