Class EnchantmentStorageBuilder

java.lang.Object
io.github.lucfr1746.llibrary.itemstack.ItemBuilder
io.github.lucfr1746.llibrary.itemstack.EnchantmentStorageBuilder

public class EnchantmentStorageBuilder extends ItemBuilder
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 Details

    • EnchantmentStorageBuilder

      public EnchantmentStorageBuilder()
      Constructs a EnchantmentStorageBuilder with a new enchanted book.
    • EnchantmentStorageBuilder

      public EnchantmentStorageBuilder(@NotNull @NotNull org.bukkit.inventory.ItemStack itemStack)
      Constructs a EnchantmentStorageBuilder using an existing ItemStack.
      Parameters:
      itemStack - the item stack to modify
      Throws:
      IllegalArgumentException - if the item's meta is not an instance of EnchantmentStorageMeta
  • 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 add
      level - the level of the enchantment
      ignoreLevelRestriction - 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

      public Map<org.bukkit.enchantments.Enchantment,Integer> 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