Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
EntityDeathEvent.java
1 package org.bukkit.event.entity;
2 
3 import java.util.List;
7 
8 /**
9  * Thrown whenever a LivingEntity dies
10  */
11 public class EntityDeathEvent extends EntityEvent {
12  private static final HandlerList handlers = new HandlerList();
13  private final List<ItemStack> drops;
14  private int dropExp = 0;
15 
16  public EntityDeathEvent(final LivingEntity entity, final List<ItemStack> drops) {
17  this(entity, drops, 0);
18  }
19 
20  public EntityDeathEvent(final LivingEntity what, final List<ItemStack> drops, final int droppedExp) {
21  super(what);
22  this.drops = drops;
23  this.dropExp = droppedExp;
24  }
25 
26  @Override
27  public LivingEntity getEntity() {
28  return (LivingEntity) entity;
29  }
30 
31  /**
32  * Gets how much EXP should be dropped from this death.
33  * <p>
34  * This does not indicate how much EXP should be taken from the entity in
35  * question, merely how much should be created after its death.
36  *
37  * @return Amount of EXP to drop.
38  */
39  public int getDroppedExp() {
40  return dropExp;
41  }
42 
43  /**
44  * Sets how much EXP should be dropped from this death.
45  * <p>
46  * This does not indicate how much EXP should be taken from the entity in
47  * question, merely how much should be created after its death.
48  *
49  * @param exp Amount of EXP to drop.
50  */
51  public void setDroppedExp(int exp) {
52  this.dropExp = exp;
53  }
54 
55  /**
56  * Gets all the items which will drop when the entity dies
57  *
58  * @return Items to drop when the entity dies
59  */
60  public List<ItemStack> getDrops() {
61  return drops;
62  }
63 
64  @Override
65  public HandlerList getHandlers() {
66  return handlers;
67  }
68 
69  public static HandlerList getHandlerList() {
70  return handlers;
71  }
72 }