001 package org.bukkit.event.player;
002
003 import org.bukkit.Material;
004 import org.bukkit.block.Block;
005 import org.bukkit.block.BlockFace;
006 import org.bukkit.entity.Player;
007 import org.bukkit.event.Cancellable;
008 import org.bukkit.inventory.ItemStack;
009
010 /**
011 * Called when a player interacts with a Bucket
012 */
013 public abstract class PlayerBucketEvent extends PlayerEvent implements Cancellable {
014 private ItemStack itemStack;
015 private boolean cancelled = false;
016 private final Block blockClicked;
017 private final BlockFace blockFace;
018 private final Material bucket;
019
020 public PlayerBucketEvent(final Player who, final Block blockClicked, final BlockFace blockFace, final Material bucket, final ItemStack itemInHand) {
021 super(who);
022 this.blockClicked = blockClicked;
023 this.blockFace = blockFace;
024 this.itemStack = itemInHand;
025 this.bucket = bucket;
026 }
027
028 /**
029 * Returns the bucket used in this event
030 *
031 * @return the used bucket
032 */
033 public Material getBucket() {
034 return bucket;
035 }
036
037 /**
038 * Get the resulting item in hand after the bucket event
039 *
040 * @return Itemstack hold in hand after the event.
041 */
042 public ItemStack getItemStack() {
043 return itemStack;
044 }
045
046 /**
047 * Set the item in hand after the event
048 *
049 * @param itemStack the new held itemstack after the bucket event.
050 */
051 public void setItemStack(ItemStack itemStack) {
052 this.itemStack = itemStack;
053 }
054
055 /**
056 * Return the block clicked
057 *
058 * @return the blicked block
059 */
060 public Block getBlockClicked() {
061 return blockClicked;
062 }
063
064 /**
065 * Get the face on the clicked block
066 *
067 * @return the clicked face
068 */
069 public BlockFace getBlockFace() {
070 return blockFace;
071 }
072
073 public boolean isCancelled() {
074 return cancelled;
075 }
076
077 public void setCancelled(boolean cancel) {
078 this.cancelled = cancel;
079 }
080 }