From 5d2a8ae74c73970bb94682d39d8dad8161657bfa Mon Sep 17 00:00:00 2001 From: durron597 Date: Fri, 7 Jan 2011 05:38:45 -0500 Subject: Added canBuild to event --- .../bukkit/event/player/PlayerBlockItemEvent.java | 42 ++++++++++++---------- 1 file changed, 24 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/main/java/org/bukkit/event/player/PlayerBlockItemEvent.java b/src/main/java/org/bukkit/event/player/PlayerBlockItemEvent.java index 2af86624..766296e3 100644 --- a/src/main/java/org/bukkit/event/player/PlayerBlockItemEvent.java +++ b/src/main/java/org/bukkit/event/player/PlayerBlockItemEvent.java @@ -24,27 +24,12 @@ import org.bukkit.event.Cancellable; public class PlayerBlockItemEvent extends PlayerItemEvent implements Cancellable { protected Block blockClicked; protected BlockFace direction; - protected boolean cancel; + protected boolean canBuild; - public PlayerBlockItemEvent(Type type, Player who, ItemStack item, Block blockClicked, BlockFace direction) { + public PlayerBlockItemEvent(Type type, Player who, ItemStack item, Block blockClicked, BlockFace direction, boolean canBuild) { super(type, who, item); this.blockClicked = blockClicked; - cancel = false; - } - - /** - * Gets the cancellation state of this event. Set to true if you - * want to prevent buckets from placing water, from a block from being - * placed - * - * @return boolean cancellation state - */ - public boolean isCancelled() { - return cancel; - } - - public void setCancelled(boolean cancel) { - this.cancel = cancel; + this.canBuild = canBuild; } /** @@ -76,4 +61,25 @@ public class PlayerBlockItemEvent extends PlayerItemEvent implements Cancellable public BlockFace getBlockFace() { return direction; } + + /** + * Gets the value whether the player would be allowed to build here. + * Defaults to spawn if the server was going to stop them (such as, the + * player is in Spawn). Note that this is an entirely different check + * than BLOCK_CANBUILD, as this refers to a player, not universe-physics + * rule like cactus on dirt. + * + * @return boolean whether the server would allow a player to build here + */ + public boolean canBuild() { + return this.canBuild; + } + + /** + * Sets the canBuild state of this event. Set to true if you want the + * player to be able to build. + */ + public void setBuild(boolean canBuild) { + this.canBuild = canBuild; + } } -- cgit v1.2.3