Added canBuild to event

By: durron597 <martin.jared@gmail.com>
This commit is contained in:
Bukkit/Spigot 2011-01-07 05:38:45 -05:00
parent 019134d7df
commit 99ed6048d7

View file

@ -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;
}
}