Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
PlayerStatisticIncrementEvent.java
1 package org.bukkit.event.player;
2 
3 import org.bukkit.Material;
4 import org.bukkit.Statistic;
6 import org.bukkit.entity.Player;
9 
10 /**
11  * Called when a player statistic is incremented.
12  * <p>
13  * This event is not called for {@link org.bukkit.Statistic#PLAY_ONE_TICK} or
14  * movement based statistics.
15  *
16  */
17 public class PlayerStatisticIncrementEvent extends PlayerEvent implements Cancellable {
18  private static final HandlerList handlers = new HandlerList();
19  protected final Statistic statistic;
20  private final int initialValue;
21  private final int newValue;
22  private boolean isCancelled = false;
23  private final EntityType entityType;
24  private final Material material;
25 
26  public PlayerStatisticIncrementEvent(Player player, Statistic statistic, int initialValue, int newValue) {
27  super (player);
28  this.statistic = statistic;
29  this.initialValue = initialValue;
30  this.newValue = newValue;
31  this.entityType = null;
32  this.material = null;
33  }
34 
35  public PlayerStatisticIncrementEvent(Player player, Statistic statistic, int initialValue, int newValue, EntityType entityType) {
36  super (player);
37  this.statistic = statistic;
38  this.initialValue = initialValue;
39  this.newValue = newValue;
40  this.entityType = entityType;
41  this.material = null;
42  }
43 
44  public PlayerStatisticIncrementEvent(Player player, Statistic statistic, int initialValue, int newValue, Material material) {
45  super (player);
46  this.statistic = statistic;
47  this.initialValue = initialValue;
48  this.newValue = newValue;
49  this.entityType = null;
50  this.material = material;
51  }
52 
53  /**
54  * Gets the statistic that is being incremented.
55  *
56  * @return the incremented statistic
57  */
59  return statistic;
60  }
61 
62  /**
63  * Gets the previous value of the statistic.
64  *
65  * @return the previous value of the statistic
66  */
67  public int getPreviousValue() {
68  return initialValue;
69  }
70 
71  /**
72  * Gets the new value of the statistic.
73  *
74  * @return the new value of the statistic
75  */
76  public int getNewValue() {
77  return newValue;
78  }
79 
80  /**
81  * Gets the EntityType if {@link #getStatistic() getStatistic()} is an
82  * entity statistic otherwise returns null.
83  *
84  * @return the EntityType of the statistic
85  */
87  return entityType;
88  }
89 
90  /**
91  * Gets the Material if {@link #getStatistic() getStatistic()} is a block
92  * or item statistic otherwise returns null.
93  *
94  * @return the Material of the statistic
95  */
96  public Material getMaterial() {
97  return material;
98  }
99 
100  public boolean isCancelled() {
101  return isCancelled;
102  }
103 
104  public void setCancelled(boolean cancel) {
105  this.isCancelled = cancel;
106  }
107 
108  @Override
109  public HandlerList getHandlers() {
110  return handlers;
111  }
112 
113  public static HandlerList getHandlerList() {
114  return handlers;
115  }
116 }