summaryrefslogtreecommitdiffstats
path: root/src/main/java/org
diff options
context:
space:
mode:
authorWesley Wolfe <weswolf@aol.com>2012-12-21 07:28:33 -0600
committerWesley Wolfe <weswolf@aol.com>2012-12-21 10:36:17 -0600
commit5be32cd8f0d5c17ed8f4a8f74b6d60e4ccc66d03 (patch)
treef757458f4fe2a9f1b9542eee778ab6db8c2a24ca /src/main/java/org
parent13803d713c7b23e62494bb1c8236a7403177dae9 (diff)
downloadbukkit-5be32cd8f0d5c17ed8f4a8f74b6d60e4ccc66d03.tar
bukkit-5be32cd8f0d5c17ed8f4a8f74b6d60e4ccc66d03.tar.gz
bukkit-5be32cd8f0d5c17ed8f4a8f74b6d60e4ccc66d03.tar.lz
bukkit-5be32cd8f0d5c17ed8f4a8f74b6d60e4ccc66d03.tar.xz
bukkit-5be32cd8f0d5c17ed8f4a8f74b6d60e4ccc66d03.zip
Add enchantment storage meta. Adds BUKKIT-3237
Books can 'store' enchantments that can be applied to other items later. These enchantments exist seperately of enchantments that actually effect the item, and are as stated 'stored' in the book instead of the book being enchanted. The meta is generically named as the concept could be applied to other item types later, such as a enchantment scroll. All of the methods mimic those in the base meta, but instead specify 'stored' in each method name.
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/bukkit/inventory/meta/EnchantmentStorageMeta.java65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/inventory/meta/EnchantmentStorageMeta.java b/src/main/java/org/bukkit/inventory/meta/EnchantmentStorageMeta.java
new file mode 100644
index 00000000..8822d695
--- /dev/null
+++ b/src/main/java/org/bukkit/inventory/meta/EnchantmentStorageMeta.java
@@ -0,0 +1,65 @@
+package org.bukkit.inventory.meta;
+
+import java.util.Map;
+
+import org.bukkit.Material;
+import org.bukkit.enchantments.Enchantment;
+
+/**
+ * EnchantmentMeta is specific to items that can <i>store</i> enchantments, as opposed to being enchanted.
+ * {@link Material#ENCHANTED_BOOK} is an example of an item with enchantment storage.
+ */
+public interface EnchantmentStorageMeta extends ItemMeta {
+
+ /**
+ * Checks for the existence of any stored enchantments.
+ *
+ * @return true if an enchantment exists on this meta
+ */
+ boolean hasStoredEnchants();
+
+ /**
+ * Checks for storage of the specified enchantment.
+ *
+ * @param ench enchantment to check
+ * @return true if this enchantment is stored in this meta
+ */
+ boolean hasStoredEnchant(Enchantment ench);
+
+ /**
+ * Checks for the level of the stored enchantment.
+ *
+ * @param ench enchantment to check
+ * @return The level that the specified stored enchantment has, or 0 if none
+ */
+ int getStoredEnchantLevel(Enchantment ench);
+
+ /**
+ * Gets a copy the stored enchantments in this ItemMeta.
+ *
+ * @return An immutable copy of the stored enchantments
+ */
+ Map<Enchantment, Integer> getStoredEnchants();
+
+ /**
+ * Stores the specified enchantment in this item meta.
+ *
+ * @param ench Enchantment to store
+ * @param level Level for the enchantment
+ * @param ignoreLevelRestriction this indicates the enchantment should be applied, ignoring the level limit
+ * @return true if the item meta changed as a result of this call, false otherwise
+ * @throws IllegalArgumentException if enchantment is null
+ */
+ boolean addStoredEnchant(Enchantment ench, int level, boolean ignoreLevelRestriction);
+
+ /**
+ * Remove the specified stored enchantment from this item meta.
+ *
+ * @param ench Enchantment to remove
+ * @return true if the item meta changed as a result of this call, false otherwise
+ * @throws IllegalArgumentException if enchantment is null
+ */
+ boolean removeStoredEnchant(Enchantment ench) throws IllegalArgumentException;
+
+ EnchantmentStorageMeta clone();
+}