mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 07:20:24 +01:00
Added canBuild to event
By: durron597 <martin.jared@gmail.com>
This commit is contained in:
parent
019134d7df
commit
99ed6048d7
1 changed files with 24 additions and 18 deletions
|
@ -24,27 +24,12 @@ import org.bukkit.event.Cancellable;
|
||||||
public class PlayerBlockItemEvent extends PlayerItemEvent implements Cancellable {
|
public class PlayerBlockItemEvent extends PlayerItemEvent implements Cancellable {
|
||||||
protected Block blockClicked;
|
protected Block blockClicked;
|
||||||
protected BlockFace direction;
|
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);
|
super(type, who, item);
|
||||||
this.blockClicked = blockClicked;
|
this.blockClicked = blockClicked;
|
||||||
cancel = false;
|
this.canBuild = canBuild;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -76,4 +61,25 @@ public class PlayerBlockItemEvent extends PlayerItemEvent implements Cancellable
|
||||||
public BlockFace getBlockFace() {
|
public BlockFace getBlockFace() {
|
||||||
return direction;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue