Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
BlockBreakEvent.java
1 package org.bukkit.event.block;
2 
3 import org.bukkit.block.Block;
4 import org.bukkit.entity.Player;
7 
8 /**
9  * Called when a block is broken by a player.
10  * <p>
11  * If you wish to have the block drop experience, you must set the experience
12  * value above 0. By default, experience will be set in the event if:
13  * <ol>
14  * <li>The player is not in creative or adventure mode
15  * <li>The player can loot the block (ie: does not destroy it completely, by
16  * using the correct tool)
17  * <li>The player does not have silk touch
18  * <li>The block drops experience in vanilla Minecraft
19  * </ol>
20  * <p>
21  * Note:
22  * Plugins wanting to simulate a traditional block drop should set the block
23  * to air and utilize their own methods for determining what the default drop
24  * for the block being broken is and what to do about it, if anything.
25  * <p>
26  * If a Block Break event is cancelled, the block will not break and
27  * experience will not drop.
28  */
29 public class BlockBreakEvent extends BlockExpEvent implements Cancellable {
30  private final Player player;
31  private boolean cancel;
32 
33  public BlockBreakEvent(final Block theBlock, final Player player) {
34  super(theBlock, 0);
35 
36  this.player = player;
37  }
38 
39  /**
40  * Gets the Player that is breaking the block involved in this event.
41  *
42  * @return The Player that is breaking the block involved in this event
43  */
44  public Player getPlayer() {
45  return player;
46  }
47 
48  public boolean isCancelled() {
49  return cancel;
50  }
51 
52  public void setCancelled(boolean cancel) {
53  this.cancel = cancel;
54  }
55 }