001 package org.bukkit.inventory.meta;
002
003 import java.util.Map;
004
005 import org.bukkit.Material;
006 import org.bukkit.enchantments.Enchantment;
007
008 /**
009 * EnchantmentMeta is specific to items that can <i>store</i> enchantments, as
010 * opposed to being enchanted. {@link Material#ENCHANTED_BOOK} is an example
011 * of an item with enchantment storage.
012 */
013 public interface EnchantmentStorageMeta extends ItemMeta {
014
015 /**
016 * Checks for the existence of any stored enchantments.
017 *
018 * @return true if an enchantment exists on this meta
019 */
020 boolean hasStoredEnchants();
021
022 /**
023 * Checks for storage of the specified enchantment.
024 *
025 * @param ench enchantment to check
026 * @return true if this enchantment is stored in this meta
027 */
028 boolean hasStoredEnchant(Enchantment ench);
029
030 /**
031 * Checks for the level of the stored enchantment.
032 *
033 * @param ench enchantment to check
034 * @return The level that the specified stored enchantment has, or 0 if
035 * none
036 */
037 int getStoredEnchantLevel(Enchantment ench);
038
039 /**
040 * Gets a copy the stored enchantments in this ItemMeta.
041 *
042 * @return An immutable copy of the stored enchantments
043 */
044 Map<Enchantment, Integer> getStoredEnchants();
045
046 /**
047 * Stores the specified enchantment in this item meta.
048 *
049 * @param ench Enchantment to store
050 * @param level Level for the enchantment
051 * @param ignoreLevelRestriction this indicates the enchantment should be
052 * applied, ignoring the level limit
053 * @return true if the item meta changed as a result of this call, false
054 * otherwise
055 * @throws IllegalArgumentException if enchantment is null
056 */
057 boolean addStoredEnchant(Enchantment ench, int level, boolean ignoreLevelRestriction);
058
059 /**
060 * Remove the specified stored enchantment from this item meta.
061 *
062 * @param ench Enchantment to remove
063 * @return true if the item meta changed as a result of this call, false
064 * otherwise
065 * @throws IllegalArgumentException if enchantment is null
066 */
067 boolean removeStoredEnchant(Enchantment ench) throws IllegalArgumentException;
068
069 /**
070 * Checks if the specified enchantment conflicts with any enchantments in
071 * this ItemMeta.
072 *
073 * @param ench enchantment to test
074 * @return true if the enchantment conflicts, false otherwise
075 */
076 boolean hasConflictingStoredEnchant(Enchantment ench);
077
078 EnchantmentStorageMeta clone();
079 }