Package net.pinger.disguise.item
Class ItemBuilder
java.lang.Object
net.pinger.disguise.item.ItemBuilder
This class is a utility class mainly used for easier
creation of different ItemStacks.
Using this class, you can make your code even more readable and also do it in as little operations as possible.
- Since:
- 2.0
- Author:
- Pinger
-
Constructor Summary
ConstructorsConstructorDescriptionItemBuilder(XMaterial material)Constructs a newItemBuilderwith the givenXMaterial.ItemBuilder(org.bukkit.inventory.ItemStack item)Constructs a newItemBuilderwith the givenItemStackto modify.ItemBuilder(org.bukkit.Material material)Constructs a newItemBuilderwith the given material.ItemBuilder(org.bukkit.Material material, int amount)Constructs a newItemBuilderwith the given material and its' amount.ItemBuilder(org.bukkit.Material material, int amount, short data)Constructs a newItemBuilderwith the givenItemStackcontents.ItemBuilder(org.bukkit.Material material, short data)Constructs a newItemBuilderwith the given material and the material data. -
Method Summary
Modifier and TypeMethodDescriptionThis method adds lore to the current lore of theItemStack.This method adds lore to the current lore of theItemStack.org.bukkit.inventory.ItemStackbuild()This method builds thisItemBuilderinto aItemStackinstance while taking all specified fields into account.enchant(org.bukkit.enchantments.Enchantment enchantment)This method adds an enchantment to theItemStack.enchant(org.bukkit.enchantments.Enchantment enchantment, int level)This method adds a leveled enchantment to theItemStack.flag()This method adds all flags from theItemFlagenum to the item.flag(org.bukkit.inventory.ItemFlag... flags)This method adds flags to theItemStack.This method overrides the lore of theItemStackwith the specified lore.This method overrides the lore of theItemStackwith the specified lore.This method sets the display name of theItemStackinstance.
-
Constructor Details
-
ItemBuilder
public ItemBuilder(@Nonnull org.bukkit.inventory.ItemStack item)Constructs a newItemBuilderwith the givenItemStackto modify.- Parameters:
item- the item to modify
-
ItemBuilder
public ItemBuilder(org.bukkit.Material material, int amount, short data)Constructs a newItemBuilderwith the givenItemStackcontents.- Parameters:
material- the material typeamount- the amount of theItemStackdata- the data of theItemStack
-
ItemBuilder
public ItemBuilder(org.bukkit.Material material, int amount)Constructs a newItemBuilderwith the given material and its' amount.- Parameters:
material- the materialamount- the amount
-
ItemBuilder
public ItemBuilder(org.bukkit.Material material, short data)Constructs a newItemBuilderwith the given material and the material data.- Parameters:
material- the materialdata- the material data
-
ItemBuilder
public ItemBuilder(org.bukkit.Material material)Constructs a newItemBuilderwith the given material.- Parameters:
material- the material
-
ItemBuilder
Constructs a newItemBuilderwith the givenXMaterial.- Parameters:
material- the material
-
-
Method Details
-
name
This method sets the display name of theItemStackinstance.- Parameters:
displayName- the display name- Returns:
- this instance
-
lore
This method overrides the lore of theItemStackwith the specified lore.- Parameters:
lore- the lore to override- Returns:
- this instance
-
lore
This method overrides the lore of theItemStackwith the specified lore.- Parameters:
lore- the lore to override- Returns:
- this instance
-
addLore
This method adds lore to the current lore of theItemStack.- Parameters:
lore- the lore to add- Returns:
- this instance
-
addLore
This method adds lore to the current lore of theItemStack.- Parameters:
lore- the lore to add- Returns:
- this instance
-
flag
This method adds flags to theItemStack.- Parameters:
flags- the flags to add- Returns:
- this instance
-
flag
This method adds all flags from theItemFlagenum to the item.- Returns:
- this instance
-
enchant
This method adds a leveled enchantment to theItemStack.- Parameters:
enchantment- the enchantment to addlevel- the level of the enchantment- Returns:
- this instance
-
enchant
This method adds an enchantment to theItemStack.- Parameters:
enchantment- the enchantment to add- Returns:
- this instance
-
build
public org.bukkit.inventory.ItemStack build()This method builds thisItemBuilderinto aItemStackinstance while taking all specified fields into account.- Returns:
- the built
ItemStack
-