001    package org.bukkit.event.entity;
002    
003    import java.util.List;
004    import org.bukkit.entity.LivingEntity;
005    import org.bukkit.event.HandlerList;
006    import org.bukkit.inventory.ItemStack;
007    
008    /**
009     * Thrown whenever a LivingEntity dies
010     */
011    public class EntityDeathEvent extends EntityEvent {
012        private static final HandlerList handlers = new HandlerList();
013        private final List<ItemStack> drops;
014        private int dropExp = 0;
015    
016        public EntityDeathEvent(final LivingEntity entity, final List<ItemStack> drops) {
017            this(entity, drops, 0);
018        }
019    
020        public EntityDeathEvent(final LivingEntity what, final List<ItemStack> drops, final int droppedExp) {
021            super(what);
022            this.drops = drops;
023            this.dropExp = droppedExp;
024        }
025    
026        @Override
027        public LivingEntity getEntity() {
028            return (LivingEntity) entity;
029        }
030    
031        /**
032         * Gets how much EXP should be dropped from this death.
033         * <p>
034         * This does not indicate how much EXP should be taken from the entity in
035         * question, merely how much should be created after its death.
036         *
037         * @return Amount of EXP to drop.
038         */
039        public int getDroppedExp() {
040            return dropExp;
041        }
042    
043        /**
044         * Sets how much EXP should be dropped from this death.
045         * <p>
046         * This does not indicate how much EXP should be taken from the entity in
047         * question, merely how much should be created after its death.
048         *
049         * @param exp Amount of EXP to drop.
050         */
051        public void setDroppedExp(int exp) {
052            this.dropExp = exp;
053        }
054    
055        /**
056         * Gets all the items which will drop when the entity dies
057         *
058         * @return Items to drop when the entity dies
059         */
060        public List<ItemStack> getDrops() {
061            return drops;
062        }
063    
064        @Override
065        public HandlerList getHandlers() {
066            return handlers;
067        }
068    
069        public static HandlerList getHandlerList() {
070            return handlers;
071        }
072    }