From ea16a443245632f50ddf3ca21c21c8601d4c5553 Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Sat, 1 Jan 2011 03:12:39 -0500 Subject: [PATCH] Changed BlockCanBuild event to pass the material By: durron597 --- .../bukkit/sample/SampleBlockListener.java | 6 ++-- .../event/block/BlockCanBuildEvent.java | 30 ++++++++++++------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/paper-api/sample/src/com/dinnerbone/bukkit/sample/SampleBlockListener.java b/paper-api/sample/src/com/dinnerbone/bukkit/sample/SampleBlockListener.java index 5094ceadb7..30a7c1175d 100644 --- a/paper-api/sample/src/com/dinnerbone/bukkit/sample/SampleBlockListener.java +++ b/paper-api/sample/src/com/dinnerbone/bukkit/sample/SampleBlockListener.java @@ -33,10 +33,10 @@ public class SampleBlockListener extends BlockListener { @Override public void onBlockCanBuild(BlockCanBuildEvent event) { - Block block = event.getBlock(); + Material mat = event.getMaterial(); - if (block.getType() == Material.Cactus) { - event.setCancelled(false); + if (mat.equals(Material.Cactus)) { + event.setBuildable(true); } } } diff --git a/paper-api/src/org/bukkit/event/block/BlockCanBuildEvent.java b/paper-api/src/org/bukkit/event/block/BlockCanBuildEvent.java index 21b22df4b9..0aed095c1b 100644 --- a/paper-api/src/org/bukkit/event/block/BlockCanBuildEvent.java +++ b/paper-api/src/org/bukkit/event/block/BlockCanBuildEvent.java @@ -4,18 +4,20 @@ package org.bukkit.event.block; import org.bukkit.Block; +import org.bukkit.Material; import org.bukkit.event.Cancellable; /** * @author durron597 */ -public class BlockCanBuildEvent extends BlockEvent implements Cancellable { - protected boolean cancel; +public class BlockCanBuildEvent extends BlockEvent { + 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); - - cancel = canBuild; + buildable = canBuild; + material = mat; } /** @@ -24,16 +26,22 @@ public class BlockCanBuildEvent extends BlockEvent implements Cancellable { * * @return boolean whether or not the block can be built */ - @Override - public boolean isCancelled() { - return cancel; + public boolean isBuildable() { + return buildable; } /** * Set whether the block can be built here. */ - @Override - public void setCancelled(boolean cancel) { - this.cancel = cancel; + public void setBuildable(boolean cancel) { + this.buildable = cancel; + } + + public Material getMaterial() { + return material; + } + + public int getMaterialID() { + return material.getID(); } }