Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
PlayerItemHeldEvent.java
1 package org.bukkit.event.player;
2 
3 import org.bukkit.entity.Player;
6 
7 /**
8  * Fired when a player changes their currently held item
9  */
10 public class PlayerItemHeldEvent extends PlayerEvent implements Cancellable {
11  private static final HandlerList handlers = new HandlerList();
12  private boolean cancel = false;
13  private final int previous;
14  private final int current;
15 
16  public PlayerItemHeldEvent(final Player player, final int previous, final int current) {
17  super(player);
18  this.previous = previous;
19  this.current = current;
20  }
21 
22  /**
23  * Gets the previous held slot index
24  *
25  * @return Previous slot index
26  */
27  public int getPreviousSlot() {
28  return previous;
29  }
30 
31  /**
32  * Gets the new held slot index
33  *
34  * @return New slot index
35  */
36  public int getNewSlot() {
37  return current;
38  }
39 
40  public boolean isCancelled() {
41  return cancel;
42  }
43 
44  public void setCancelled(boolean cancel) {
45  this.cancel = cancel;
46  }
47 
48  @Override
49  public HandlerList getHandlers() {
50  return handlers;
51  }
52 
53  public static HandlerList getHandlerList() {
54  return handlers;
55  }
56 }