Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
PrepareItemEnchantEvent.java
1 package org.bukkit.event.enchantment;
2 
3 import org.bukkit.block.Block;
4 import org.bukkit.entity.Player;
10 
11 /**
12  * Called when an ItemStack is inserted in an enchantment table - can be
13  * called multiple times
14  */
15 public class PrepareItemEnchantEvent extends InventoryEvent implements Cancellable {
16  private static final HandlerList handlers = new HandlerList();
17  private final Block table;
18  private final ItemStack item;
19  private final int[] levelsOffered;
20  private final int bonus;
21  private boolean cancelled;
22  private final Player enchanter;
23 
24  public PrepareItemEnchantEvent(final Player enchanter, InventoryView view, final Block table, final ItemStack item, final int[] levelsOffered, final int bonus) {
25  super(view);
26  this.enchanter = enchanter;
27  this.table = table;
28  this.item = item;
29  this.levelsOffered = levelsOffered;
30  this.bonus = bonus;
31  this.cancelled = false;
32  }
33 
34  /**
35  * Gets the player enchanting the item
36  *
37  * @return enchanting player
38  */
39  public Player getEnchanter() {
40  return enchanter;
41  }
42 
43  /**
44  * Gets the block being used to enchant the item
45  *
46  * @return the block used for enchanting
47  */
49  return table;
50  }
51 
52  /**
53  * Gets the item to be enchanted (can be modified)
54  *
55  * @return ItemStack of item
56  */
57  public ItemStack getItem() {
58  return item;
59  }
60 
61  /**
62  * Get list of offered exp level costs of the enchantment (modify values
63  * to change offer)
64  *
65  * @return experience level costs offered
66  */
67  public int[] getExpLevelCostsOffered() {
68  return levelsOffered;
69  }
70 
71  /**
72  * Get enchantment bonus in effect - corresponds to number of bookshelves
73  *
74  * @return enchantment bonus
75  */
76  public int getEnchantmentBonus() {
77  return bonus;
78  }
79 
80  public boolean isCancelled() {
81  return cancelled;
82  }
83 
84  public void setCancelled(boolean cancel) {
85  this.cancelled = cancel;
86  }
87 
88  @Override
89  public HandlerList getHandlers() {
90  return handlers;
91  }
92 
93  public static HandlerList getHandlerList() {
94  return handlers;
95  }
96 }