001 package org.bukkit.event.hanging;
002
003 import org.bukkit.entity.Hanging;
004 import org.bukkit.event.Cancellable;
005 import org.bukkit.event.HandlerList;
006
007 /**
008 * Triggered when a hanging entity is removed
009 */
010 public class HangingBreakEvent extends HangingEvent implements Cancellable {
011 private static final HandlerList handlers = new HandlerList();
012 private boolean cancelled;
013 private final HangingBreakEvent.RemoveCause cause;
014
015 public HangingBreakEvent(final Hanging hanging, final HangingBreakEvent.RemoveCause cause) {
016 super(hanging);
017 this.cause = cause;
018 }
019
020 /**
021 * Gets the cause for the hanging entity's removal
022 *
023 * @return the RemoveCause for the hanging entity's removal
024 */
025 public HangingBreakEvent.RemoveCause getCause() {
026 return cause;
027 }
028
029 public boolean isCancelled() {
030 return cancelled;
031 }
032
033 public void setCancelled(boolean cancel) {
034 this.cancelled = cancel;
035 }
036
037 /**
038 * An enum to specify the cause of the removal
039 */
040 public enum RemoveCause {
041 /**
042 * Removed by an entity
043 */
044 ENTITY,
045 /**
046 * Removed by an explosion
047 */
048 EXPLOSION,
049 /**
050 * Removed by placing a block on it
051 */
052 OBSTRUCTION,
053 /**
054 * Removed by destroying the block behind it, etc
055 */
056 PHYSICS,
057 /**
058 * Removed by an uncategorised cause
059 */
060 DEFAULT,
061 }
062
063 @Override
064 public HandlerList getHandlers() {
065 return handlers;
066 }
067
068 public static HandlerList getHandlerList() {
069 return handlers;
070 }
071 }