001 package org.bukkit.event.hanging;
002
003 import org.bukkit.block.Block;
004 import org.bukkit.block.BlockFace;
005 import org.bukkit.entity.Hanging;
006 import org.bukkit.entity.Player;
007 import org.bukkit.event.Cancellable;
008 import org.bukkit.event.HandlerList;
009
010 /**
011 * Triggered when a hanging entity is created in the world
012 */
013 public class HangingPlaceEvent extends HangingEvent implements Cancellable {
014 private static final HandlerList handlers = new HandlerList();
015 private boolean cancelled;
016 private final Player player;
017 private final Block block;
018 private final BlockFace blockFace;
019
020 public HangingPlaceEvent(final Hanging hanging, final Player player, final Block block, final BlockFace blockFace) {
021 super(hanging);
022 this.player = player;
023 this.block = block;
024 this.blockFace = blockFace;
025 }
026
027 /**
028 * Returns the player placing the hanging entity
029 *
030 * @return the player placing the hanging entity
031 */
032 public Player getPlayer() {
033 return player;
034 }
035
036 /**
037 * Returns the block that the hanging entity was placed on
038 *
039 * @return the block that the hanging entity was placed on
040 */
041 public Block getBlock() {
042 return block;
043 }
044
045 /**
046 * Returns the face of the block that the hanging entity was placed on
047 *
048 * @return the face of the block that the hanging entity was placed on
049 */
050 public BlockFace getBlockFace() {
051 return blockFace;
052 }
053
054 public boolean isCancelled() {
055 return cancelled;
056 }
057
058 public void setCancelled(boolean cancel) {
059 this.cancelled = cancel;
060 }
061
062 @Override
063 public HandlerList getHandlers() {
064 return handlers;
065 }
066
067 public static HandlerList getHandlerList() {
068 return handlers;
069 }
070 }