Changed BlockCanBuild event to pass the material

By: durron597 <martin.jared@gmail.com>
This commit is contained in:
Bukkit/Spigot 2011-01-01 03:12:39 -05:00
parent b8b9e7c22b
commit ea16a44324
2 changed files with 22 additions and 14 deletions

View File

@ -33,10 +33,10 @@ public class SampleBlockListener extends BlockListener {
@Override @Override
public void onBlockCanBuild(BlockCanBuildEvent event) { public void onBlockCanBuild(BlockCanBuildEvent event) {
Block block = event.getBlock(); Material mat = event.getMaterial();
if (block.getType() == Material.Cactus) { if (mat.equals(Material.Cactus)) {
event.setCancelled(false); event.setBuildable(true);
} }
} }
} }

View File

@ -4,18 +4,20 @@
package org.bukkit.event.block; package org.bukkit.event.block;
import org.bukkit.Block; import org.bukkit.Block;
import org.bukkit.Material;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
/** /**
* @author durron597 * @author durron597
*/ */
public class BlockCanBuildEvent extends BlockEvent implements Cancellable { public class BlockCanBuildEvent extends BlockEvent {
protected boolean cancel; protected boolean buildable;
protected Material material;
public BlockCanBuildEvent(Type type, Block block, boolean canBuild) { public BlockCanBuildEvent(Type type, Block block, Material mat, boolean canBuild) {
super(type, block); super(type, block);
buildable = canBuild;
cancel = canBuild; material = mat;
} }
/** /**
@ -24,16 +26,22 @@ public class BlockCanBuildEvent extends BlockEvent implements Cancellable {
* *
* @return boolean whether or not the block can be built * @return boolean whether or not the block can be built
*/ */
@Override public boolean isBuildable() {
public boolean isCancelled() { return buildable;
return cancel;
} }
/** /**
* Set whether the block can be built here. * Set whether the block can be built here.
*/ */
@Override public void setBuildable(boolean cancel) {
public void setCancelled(boolean cancel) { this.buildable = cancel;
this.cancel = cancel; }
public Material getMaterial() {
return material;
}
public int getMaterialID() {
return material.getID();
} }
} }