Class EnchantmentStorageBuilder
java.lang.Object
io.github.lucfr1746.llibrary.itemstack.ItemBuilder
io.github.lucfr1746.llibrary.itemstack.EnchantmentStorageBuilder
The
EnchantmentStorageBuilder
class extends ItemBuilder
to provide
additional functionality for modifying EnchantmentStorageMeta
of an ItemStack
.
This class allows adding, removing, and checking stored enchantments in enchanted books.-
Constructor Summary
ConstructorsConstructorDescriptionConstructs aEnchantmentStorageBuilder
with a new enchanted book.EnchantmentStorageBuilder
(@NotNull org.bukkit.inventory.ItemStack itemStack) Constructs aEnchantmentStorageBuilder
using an existingItemStack
. -
Method Summary
Modifier and TypeMethodDescriptionaddStoredEnchant
(@NotNull org.bukkit.enchantments.Enchantment enchantment, int level, boolean ignoreLevelRestriction) Adds a stored enchantment to the item.int
getStoredEnchantLevel
(@NotNull org.bukkit.enchantments.Enchantment enchantment) Gets the level of a stored enchantment.Gets all stored enchantments on the item.boolean
hasConflictingStoredEnchant
(@NotNull org.bukkit.enchantments.Enchantment enchantment) Checks if the specified enchantment conflicts with any stored enchantments.boolean
hasStoredEnchant
(@NotNull org.bukkit.enchantments.Enchantment enchantment) Checks if the item has a specific stored enchantment.boolean
Checks if the item has any stored enchantments.removeStoredEnchant
(@NotNull org.bukkit.enchantments.Enchantment enchantment) Removes a stored enchantment from the item.Methods inherited from class io.github.lucfr1746.llibrary.itemstack.ItemBuilder
addAttributeModifier, addEnchant, addEnchant, addEnchant, addItemFlags, addLore, build, getAmount, getAttributeModifiers, getAttributeModifiers, getAttributeModifiers, getCustomModelData, getDamageResistant, getDisplayName, getEnchantable, getEnchantLevel, getEnchantmentGlintOverride, getEnchants, getEquippableComponent, getFoodComponent, getItemFlags, getItemMeta, getItemModel, getJukeboxPlayableComponent, getMaxStackSize, getRarity, getToolComponent, getTooltipStyle, getTranslationKey, getType, getUseCooldownComponent, getUseRemainder, hasAttributeModifiers, hasConflictingEnchant, hasCustomModelData, hasDamageResistant, hasEnchant, hasEnchantable, hasEnchantmentGlintOverride, hasEnchants, hasEquippableComponent, hasFoodComponent, hasItemFlag, hasItemModel, hasJukeboxPlayableComponent, hasMaxStackSize, hasRarity, hasToolComponent, hasTooltipStyle, hasUseCooldownComponent, hasUseRemainder, hideAllItemFlags, insertLore, isGlider, isHideTooltip, isUnbreakable, removeAttributeModifier, removeAttributeModifier, removeAttributeModifier, removeEnchant, removeEnchants, removeItemFlags, replaceLore, setAmount, setAttributeModifiers, setCustomModelData, setDamageResistant, setDisplayName, setEnchantable, setEnchantmentGlintOverride, setEquippableComponent, setEquippableComponent, setFood, setFoodComponent, setGlider, setHideTooltip, setItemModel, setItemModel, setJukeboxPlayableComponent, setJukeboxPlayableComponent, setJukeboxPlayableComponent, setLores, setLores, setMaxStackSize, setRarity, setToolComponent, setToolComponent, setTooltipStyle, setTooltipStyle, setType, setUnbreakable, setUseCooldownComponent, setUseCooldownComponent, setUseCooldownComponent, setUseRemainder
-
Constructor Details
-
EnchantmentStorageBuilder
public EnchantmentStorageBuilder()Constructs aEnchantmentStorageBuilder
with a new enchanted book. -
EnchantmentStorageBuilder
public EnchantmentStorageBuilder(@NotNull @NotNull org.bukkit.inventory.ItemStack itemStack) Constructs aEnchantmentStorageBuilder
using an existingItemStack
.- Parameters:
itemStack
- the item stack to modify- Throws:
IllegalArgumentException
- if the item's meta is not an instance ofEnchantmentStorageMeta
-
-
Method Details
-
addStoredEnchant
public EnchantmentStorageBuilder addStoredEnchant(@NotNull @NotNull org.bukkit.enchantments.Enchantment enchantment, int level, boolean ignoreLevelRestriction) Adds a stored enchantment to the item.- Parameters:
enchantment
- the enchantment to addlevel
- the level of the enchantmentignoreLevelRestriction
- whether to ignore level restrictions- Returns:
- this
EnchantmentStorageBuilder
instance for method chaining
-
removeStoredEnchant
public EnchantmentStorageBuilder removeStoredEnchant(@NotNull @NotNull org.bukkit.enchantments.Enchantment enchantment) Removes a stored enchantment from the item.- Parameters:
enchantment
- the enchantment to remove- Returns:
- this
EnchantmentStorageBuilder
instance for method chaining
-
getStoredEnchantLevel
public int getStoredEnchantLevel(@NotNull @NotNull org.bukkit.enchantments.Enchantment enchantment) Gets the level of a stored enchantment.- Parameters:
enchantment
- the enchantment to check- Returns:
- the level of the enchantment, or 0 if not present
-
getStoredEnchants
Gets all stored enchantments on the item.- Returns:
- a map of enchantments and their levels
-
hasStoredEnchant
public boolean hasStoredEnchant(@NotNull @NotNull org.bukkit.enchantments.Enchantment enchantment) Checks if the item has a specific stored enchantment.- Parameters:
enchantment
- the enchantment to check for- Returns:
- true if the enchantment is stored, false otherwise
-
hasStoredEnchants
public boolean hasStoredEnchants()Checks if the item has any stored enchantments.- Returns:
- true if there are stored enchantments, false otherwise
-
hasConflictingStoredEnchant
public boolean hasConflictingStoredEnchant(@NotNull @NotNull org.bukkit.enchantments.Enchantment enchantment) Checks if the specified enchantment conflicts with any stored enchantments.- Parameters:
enchantment
- the enchantment to check for conflicts- Returns:
- true if there is a conflict, false otherwise
-