Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
BlockCanBuildEvent.java
1 package org.bukkit.event.block;
2 
3 import org.bukkit.block.Block;
4 import org.bukkit.Material;
6 
7 /**
8  * Called when we try to place a block, to see if we can build it here or not.
9  * <p>
10  * Note:
11  * <ul>
12  * <li>The Block returned by getBlock() is the block we are trying to place
13  * on, not the block we are trying to place.
14  * <li>If you want to figure out what is being placed, use {@link
15  * #getMaterial()} or {@link #getMaterialId()} instead.
16  * </ul>
17  */
18 public class BlockCanBuildEvent extends BlockEvent {
19  private static final HandlerList handlers = new HandlerList();
20  protected boolean buildable;
21 
22  /**
23  *
24  * @deprecated Magic value
25  */
26  @Deprecated
27  protected int material;
28 
29  /**
30  *
31  * @deprecated Magic value
32  */
33  @Deprecated
34  public BlockCanBuildEvent(final Block block, final int id, final boolean canBuild) {
35  super(block);
36  buildable = canBuild;
37  material = id;
38  }
39 
40  /**
41  * Gets whether or not the block can be built here.
42  * <p>
43  * By default, returns Minecraft's answer on whether the block can be
44  * built here or not.
45  *
46  * @return boolean whether or not the block can be built
47  */
48  public boolean isBuildable() {
49  return buildable;
50  }
51 
52  /**
53  * Sets whether the block can be built here or not.
54  *
55  * @param cancel true if you want to allow the block to be built here
56  * despite Minecraft's default behaviour
57  */
58  public void setBuildable(boolean cancel) {
59  this.buildable = cancel;
60  }
61 
62  /**
63  * Gets the Material that we are trying to place.
64  *
65  * @return The Material that we are trying to place
66  */
67  public Material getMaterial() {
68  return Material.getMaterial(material);
69  }
70 
71  /**
72  * Gets the Material ID for the Material that we are trying to place.
73  *
74  * @return The Material ID for the Material that we are trying to place
75  * @deprecated Magic value
76  */
77  @Deprecated
78  public int getMaterialId() {
79  return material;
80  }
81 
82  @Override
83  public HandlerList getHandlers() {
84  return handlers;
85  }
86 
87  public static HandlerList getHandlerList() {
88  return handlers;
89  }
90 }
static Material getMaterial(final int id)
Definition: Material.java:575
BlockCanBuildEvent(final Block block, final int id, final boolean canBuild)