Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
at develop 70 lines 1.9 kB view raw
1package org.bukkit.event.block; 2 3import org.bukkit.block.Block; 4import org.bukkit.entity.Player; 5import org.bukkit.event.Cancellable; 6import org.bukkit.inventory.ItemStack; 7 8/** 9 * Called when a block is damaged by a player. 10 * <p/> 11 * If a Block Damage event is cancelled, the block will not be damaged. 12 */ 13public class BlockDamageEvent extends BlockEvent implements Cancellable { 14 private Player player; 15 private boolean instaBreak; 16 private boolean cancel; 17 private ItemStack itemstack; 18 19 public BlockDamageEvent(Player player, Block block, ItemStack itemInHand, boolean instaBreak) { 20 super(Type.BLOCK_DAMAGE, block); 21 this.instaBreak = instaBreak; 22 this.player = player; 23 this.itemstack = itemInHand; 24 this.cancel = false; 25 } 26 27 /** 28 * Gets the player damaging the block involved in this event. 29 * 30 * @return The player damaging the block involved in this event 31 */ 32 public Player getPlayer() { 33 return player; 34 } 35 36 /** 37 * Gets if the block is set to instantly break when damaged by the player. 38 * 39 * @return true if the block should instantly break when damaged by the player 40 */ 41 public boolean getInstaBreak() { 42 return instaBreak; 43 } 44 45 /** 46 * Sets if the block should instantly break when damaged by the player. 47 * 48 * @param bool true if you want the block to instantly break when damaged by the player 49 */ 50 public void setInstaBreak(boolean bool) { 51 this.instaBreak = bool; 52 } 53 54 /** 55 * Gets the ItemStack for the item currently in the player's hand. 56 * 57 * @return The ItemStack for the item currently in the player's hand 58 */ 59 public ItemStack getItemInHand() { 60 return itemstack; 61 } 62 63 public boolean isCancelled() { 64 return cancel; 65 } 66 67 public void setCancelled(boolean cancel) { 68 this.cancel = cancel; 69 } 70}