001    package org.bukkit.event.entity;
002    
003    import org.bukkit.entity.Entity;
004    import org.bukkit.event.HandlerList;
005    
006    /**
007     * Called immediately prior to an entity being unleashed.
008     */
009    public class EntityUnleashEvent extends EntityEvent {
010        private static final HandlerList handlers = new HandlerList();
011        private final UnleashReason reason;
012    
013        public EntityUnleashEvent(Entity entity, UnleashReason reason) {
014            super(entity);
015            this.reason = reason;
016        }
017    
018        /**
019         * Returns the reason for the unleashing.
020         *
021         * @return The reason
022         */
023        public UnleashReason getReason() {
024            return reason;
025        }
026    
027        @Override
028        public HandlerList getHandlers() {
029            return handlers;
030        }
031    
032        public static HandlerList getHandlerList() {
033            return handlers;
034        }
035    
036        public enum UnleashReason {
037            /**
038             * When the entity's leashholder has died or logged out, and so is
039             * unleashed
040             */
041            HOLDER_GONE,
042            /**
043             * When the entity's leashholder attempts to unleash it
044             */
045            PLAYER_UNLEASH,
046            /**
047             * When the entity's leashholder is more than 10 blocks away
048             */
049            DISTANCE,
050            UNKNOWN;
051        }
052    }