summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMike Primm <mike@primmhome.com>2012-01-21 01:26:45 -0600
committerEvilSeph <evilseph@gmail.com>2012-01-24 06:13:48 -0500
commit65e4d888c195b8a46873d98ba132326788372e02 (patch)
tree3b8a06a85b418eacacebfeb92f42853aec915256 /src
parentb516d3bf78ea2f2bef75a6f15293bf83630dcfa5 (diff)
downloadbukkit-65e4d888c195b8a46873d98ba132326788372e02.tar
bukkit-65e4d888c195b8a46873d98ba132326788372e02.tar.gz
bukkit-65e4d888c195b8a46873d98ba132326788372e02.tar.lz
bukkit-65e4d888c195b8a46873d98ba132326788372e02.tar.xz
bukkit-65e4d888c195b8a46873d98ba132326788372e02.zip
[Bleeding] Added EnchantmentTable API.
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/bukkit/event/enchantment/EnchantItemEvent.java105
-rw-r--r--src/main/java/org/bukkit/event/enchantment/PrepareItemEnchantEvent.java91
2 files changed, 196 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/event/enchantment/EnchantItemEvent.java b/src/main/java/org/bukkit/event/enchantment/EnchantItemEvent.java
new file mode 100644
index 00000000..42e4bedf
--- /dev/null
+++ b/src/main/java/org/bukkit/event/enchantment/EnchantItemEvent.java
@@ -0,0 +1,105 @@
+package org.bukkit.event.enchantment;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.bukkit.block.Block;
+import org.bukkit.enchantments.Enchantment;
+import org.bukkit.entity.Player;
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList;
+import org.bukkit.inventory.ItemStack;
+
+/**
+ * Called when an ItemStack is successfully enchanted (currently at enchantment table)
+ */
+@SuppressWarnings("serial")
+public class EnchantItemEvent extends Event implements Cancellable {
+ private static final HandlerList handlers = new HandlerList();
+ private Block table;
+ private ItemStack item;
+ private int level;
+ private boolean cancelled;
+ private Map<Enchantment,Integer> enchants;
+ private Player enchanter;
+
+ public EnchantItemEvent(Player enchanter, Block table, ItemStack item, int level, Map<Enchantment, Integer> enchants) {
+ this.enchanter = enchanter;
+ this.table = table;
+ this.item = item;
+ this.level = level;
+ this.enchants = new HashMap<Enchantment, Integer>(enchants);
+ this.cancelled = false;
+ }
+
+ /**
+ * Gets the player enchanting the item
+ *
+ * @returns enchanting player
+ */
+ public Player getEnchanter() {
+ return enchanter;
+ }
+
+ /**
+ * Gets the block being used to enchant the item
+ *
+ * @return the block used for enchanting
+ */
+ public Block getEnchantBlock() {
+ return table;
+ }
+
+ /**
+ * Gets the item to be enchanted (can be modified)
+ *
+ * @return ItemStack of item
+ */
+ public ItemStack getItem() {
+ return item;
+ }
+
+ /**
+ * Get cost in exp levels of the enchantment
+ * @return experience level cost
+ */
+ public int getExpLevelCost() {
+ return level;
+ }
+
+ /**
+ * Set cost in exp levels of the enchantment
+ * @param level - cost in levels
+ */
+ public void setExpLevelCost(int level) {
+ this.level = level;
+ }
+
+ /**
+ * Get map of enchantment (levels, keyed by type) to be added to item (modify map returned to change values)
+ * Note: Any enchantments not allowed for the item will be ignored
+ *
+ * @return map of enchantment levels, keyed by enchantment
+ */
+ public Map<Enchantment, Integer> getEnchantsToAdd() {
+ return enchants;
+ }
+
+ public boolean isCancelled() {
+ return cancelled;
+ }
+
+ public void setCancelled(boolean cancel) {
+ this.cancelled = cancel;
+ }
+
+ @Override
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+}
diff --git a/src/main/java/org/bukkit/event/enchantment/PrepareItemEnchantEvent.java b/src/main/java/org/bukkit/event/enchantment/PrepareItemEnchantEvent.java
new file mode 100644
index 00000000..ee0dc504
--- /dev/null
+++ b/src/main/java/org/bukkit/event/enchantment/PrepareItemEnchantEvent.java
@@ -0,0 +1,91 @@
+package org.bukkit.event.enchantment;
+
+import org.bukkit.block.Block;
+import org.bukkit.entity.Player;
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList;
+import org.bukkit.inventory.ItemStack;
+
+/**
+ * Called when an ItemStack is inserted in an enchantment table - can be called multiple times
+ */
+@SuppressWarnings("serial")
+public class PrepareItemEnchantEvent extends Event implements Cancellable {
+ private static final HandlerList handlers = new HandlerList();
+ private Block table;
+ private ItemStack item;
+ private int[] levels_offered;
+ private int bonus;
+ private boolean cancelled;
+ private Player enchanter;
+
+ public PrepareItemEnchantEvent(Player enchanter, Block table, ItemStack item, int[] levels_offered, int bonus) {
+ this.enchanter = enchanter;
+ this.table = table;
+ this.item = item;
+ this.levels_offered = levels_offered;
+ this.bonus = bonus;
+ this.cancelled = false;
+ }
+
+ /**
+ * Gets the player enchanting the item
+ *
+ * @returns enchanting player
+ */
+ public Player getEnchanter() {
+ return enchanter;
+ }
+
+ /**
+ * Gets the block being used to enchant the item
+ *
+ * @return the block used for enchanting
+ */
+ public Block getEnchantBlock() {
+ return table;
+ }
+
+ /**
+ * Gets the item to be enchanted (can be modified)
+ *
+ * @return ItemStack of item
+ */
+ public ItemStack getItem() {
+ return item;
+ }
+
+ /**
+ * Get list of offered exp level costs of the enchantment (modify values to change offer)
+ * @return experience level costs offered
+ */
+ public int[] getExpLevelCostsOffered() {
+ return levels_offered;
+ }
+
+ /**
+ * Get enchantment bonus in effect - corresponds to number of bookshelves
+ * @return enchantment bonus
+ */
+ public int getEnchantmentBonus() {
+ return bonus;
+ }
+
+ public boolean isCancelled() {
+ return cancelled;
+ }
+
+ public void setCancelled(boolean cancel) {
+ this.cancelled = cancel;
+ }
+
+ @Override
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+}