Class ItemBuilder
java.lang.Object
fr.multimc.api.spigot.common.tools.builders.items.ItemBuilder
- Direct Known Subclasses:
BookBuilder,LeatherArmorBuilder,SkullBuilder
Create easily an item.
- Since:
- 04/10/2022
-
Constructor Summary
ConstructorsConstructorDescriptionItemBuilder(@NotNull org.bukkit.inventory.ItemStack item) Create an instance of an existing item.ItemBuilder(@NotNull org.bukkit.Material material) Create a new item.ItemBuilder(@NotNull org.bukkit.Material material, int amount) Create a new item with a different amount. -
Method Summary
Modifier and TypeMethodDescriptionaddEnchantment(@NotNull org.bukkit.enchantments.Enchantment enchantment, int level) Enchant the item.addEnchantments(@NotNull Map<org.bukkit.enchantments.Enchantment, Integer> enchantments) Add a list of enchantments.addFlags(@NotNull org.bukkit.inventory.ItemFlag... flags) Add some flags (tags) to the item.applyMeta(@NotNull org.bukkit.inventory.meta.ItemMeta meta) Apply the metadata to the item.org.bukkit.inventory.ItemStackbuild()Build the modified item.org.bukkit.inventory.meta.ItemMetagetMeta()Get the item metadata.Un enchant the item.removeEnchantment(@NotNull org.bukkit.enchantments.Enchantment enchantment) Remove an enchantment.removeEnchantments(@NotNull List<org.bukkit.enchantments.Enchantment> enchantments) Remove a list of enchantments.removeEnchantments(@NotNull org.bukkit.enchantments.Enchantment... enchantments) Remove a list of enchantments.removeFlags(@NotNull org.bukkit.inventory.ItemFlag... flags) Remove some flags (tags) of the item.setCustomModelData(int data) Set the item's custom model data using a texture pack.setLegacyLore(@NotNull String... lore) Deprecated.setLegacyLore(List<String> lore) Deprecated.setLegacyName(@NotNull String name) Deprecated.setLore(@NotNull net.kyori.adventure.text.Component... lore) setName(@NotNull net.kyori.adventure.text.Component name) setUnbreakable(boolean state) Set the item's unbreakable state.
-
Constructor Details
-
ItemBuilder
public ItemBuilder(@NotNull @NotNull org.bukkit.inventory.ItemStack item) Create an instance of an existing item.- Parameters:
item- Base item.
-
ItemBuilder
public ItemBuilder(@NotNull @NotNull org.bukkit.Material material) Create a new item.- Parameters:
material- Item type.
-
ItemBuilder
public ItemBuilder(@NotNull @NotNull org.bukkit.Material material, int amount) Create a new item with a different amount.- Parameters:
material- Item type.amount- Item amount.
-
-
Method Details
-
build
public org.bukkit.inventory.ItemStack build()Build the modified item.- Returns:
- Item modified.
-
getMeta
public org.bukkit.inventory.meta.ItemMeta getMeta()Get the item metadata.- Returns:
- Item metadata.
-
applyMeta
Apply the metadata to the item.- Parameters:
meta- Meta data to apply.- Returns:
- The current instance of the builder.
-
setLegacyName
Deprecated.Set the item custom display name (colors included).- Parameters:
name- Display name.- Returns:
- Current instance of the builder.
-
setName
-
setLegacyLore
Deprecated.Set the item description (colors included).- Parameters:
lore- Description lines.- Returns:
- Current instance of the builder.
-
setLore
-
setLegacyLore
Deprecated.Set the item description (colors included).- Parameters:
lore- Descriptions lines.- Returns:
- Current instance of the builder.
-
setLore
-
setUnbreakable
Set the item's unbreakable state.- Parameters:
state- State.- Returns:
- Current instance of the builder.
-
addFlags
Add some flags (tags) to the item.- Parameters:
flags- Flags.- Returns:
- Current instance of the builder.
-
removeFlags
Remove some flags (tags) of the item.- Parameters:
flags- Flags.- Returns:
- Current instance of the builder.
-
addEnchantment
public ItemBuilder addEnchantment(@NotNull @NotNull org.bukkit.enchantments.Enchantment enchantment, int level) Enchant the item.- Parameters:
enchantment- Enchantment.level- Level.- Returns:
- Current instance of the builder.
-
addEnchantments
public ItemBuilder addEnchantments(@NotNull @NotNull Map<org.bukkit.enchantments.Enchantment, Integer> enchantments) Add a list of enchantments.- Parameters:
enchantments- Enchantments list.- Returns:
- Current instance of the builder.
-
removeEnchantment
public ItemBuilder removeEnchantment(@NotNull @NotNull org.bukkit.enchantments.Enchantment enchantment) Remove an enchantment.- Parameters:
enchantment- Enchantment.- Returns:
- Current instance of the builder.
-
removeEnchantments
public ItemBuilder removeEnchantments(@NotNull @NotNull List<org.bukkit.enchantments.Enchantment> enchantments) Remove a list of enchantments.- Parameters:
enchantments- Enchantments list.- Returns:
- Current instance of the builder.
-
removeEnchantments
public ItemBuilder removeEnchantments(@NotNull @NotNull org.bukkit.enchantments.Enchantment... enchantments) Remove a list of enchantments.- Parameters:
enchantments- Enchantments list.- Returns:
- Current instance of the builder.
-
removeAllEnchantments
Un enchant the item.- Returns:
- Current instance of the builder.
-
setCustomModelData
Set the item's custom model data using a texture pack.- Parameters:
data- Custom model data.- Returns:
- Current instance of the builder.
-