001    package org.bukkit.event.block;
002    
003    import org.bukkit.block.Block;
004    import org.bukkit.entity.Player;
005    import org.bukkit.event.Cancellable;
006    import org.bukkit.event.HandlerList;
007    
008    /**
009     * Called when a block is broken by a player.
010     * <p>
011     * If you wish to have the block drop experience, you must set the experience
012     * value above 0. By default, experience will be set in the event if:
013     * <ol>
014     * <li>The player is not in creative or adventure mode
015     * <li>The player can loot the block (ie: does not destroy it completely, by
016     *     using the correct tool)
017     * <li>The player does not have silk touch
018     * <li>The block drops experience in vanilla Minecraft
019     * </ol>
020     * <p>
021     * Note:
022     * Plugins wanting to simulate a traditional block drop should set the block
023     * to air and utilize their own methods for determining what the default drop
024     * for the block being broken is and what to do about it, if anything.
025     * <p>
026     * If a Block Break event is cancelled, the block will not break and
027     * experience will not drop.
028     */
029    public class BlockBreakEvent extends BlockExpEvent implements Cancellable {
030        private final Player player;
031        private boolean cancel;
032    
033        public BlockBreakEvent(final Block theBlock, final Player player) {
034            super(theBlock, 0);
035    
036            this.player = player;
037        }
038    
039        /**
040         * Gets the Player that is breaking the block involved in this event.
041         *
042         * @return The Player that is breaking the block involved in this event
043         */
044        public Player getPlayer() {
045            return player;
046        }
047    
048        public boolean isCancelled() {
049            return cancel;
050        }
051    
052        public void setCancelled(boolean cancel) {
053            this.cancel = cancel;
054        }
055    }