Added getBlockReplacedState to enable checking of type of replaced block.

By: VictorD <victor.danell@gmail.com>
This commit is contained in:
Bukkit/Spigot 2011-01-24 23:24:17 +01:00
parent 6c00742888
commit 2b2dec5b91

View file

@ -1,9 +1,10 @@
package org.bukkit.event.block; package org.bukkit.event.block;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.inventory.ItemStack; import org.bukkit.block.BlockState;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
import org.bukkit.inventory.ItemStack;
/** /**
* Not implemented yet * Not implemented yet
@ -12,14 +13,16 @@ public class BlockPlaceEvent extends BlockEvent implements Cancellable {
protected boolean cancel; protected boolean cancel;
protected boolean canBuild; protected boolean canBuild;
protected Block placedAgainst; protected Block placedAgainst;
protected BlockState replacedBlockState;
protected ItemStack itemInHand; protected ItemStack itemInHand;
protected Player player; protected Player player;
public BlockPlaceEvent(Type type, Block placedBlock, Block placedAgainst, ItemStack itemInHand, Player thePlayer, boolean canBuild) { public BlockPlaceEvent(Type type, Block placedBlock, BlockState replacedBlockState, Block placedAgainst, ItemStack itemInHand, Player thePlayer, boolean canBuild) {
super(type, placedBlock); super(type, placedBlock);
this.placedAgainst = placedAgainst; this.placedAgainst = placedAgainst;
this.itemInHand = itemInHand; this.itemInHand = itemInHand;
this.player = thePlayer; this.player = thePlayer;
this.replacedBlockState = replacedBlockState;
this.canBuild = canBuild; this.canBuild = canBuild;
cancel = false; cancel = false;
} }
@ -63,6 +66,15 @@ public class BlockPlaceEvent extends BlockEvent implements Cancellable {
return getBlock(); return getBlock();
} }
/**
* Returns the state of the block which was replaced. Material type air mostly.
*
* @return BlockState of block which was replaced.
*/
public BlockState getBlockReplacedState() {
return this.replacedBlockState;
}
/** /**
* Get the block that this block was placed against * Get the block that this block was placed against