diff options
author | AgentLV <contact@agentlv.net> | 2016-03-15 12:51:16 +0100 |
---|---|---|
committer | md_5 <git@md-5.net> | 2016-03-16 07:13:52 +1100 |
commit | 6e846a5517443fddf08133186e439f4c121b2386 (patch) | |
tree | f0a78452626675f50eb3837ee9188978e3e81f86 /src/main | |
parent | 37a1591a7b3dc99897da89c2377fd69777b99dcd (diff) | |
download | bukkit-6e846a5517443fddf08133186e439f4c121b2386.tar bukkit-6e846a5517443fddf08133186e439f4c121b2386.tar.gz bukkit-6e846a5517443fddf08133186e439f4c121b2386.tar.lz bukkit-6e846a5517443fddf08133186e439f4c121b2386.tar.xz bukkit-6e846a5517443fddf08133186e439f4c121b2386.zip |
Add hand used to BlockPlaceEvent.
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/org/bukkit/event/block/BlockPlaceEvent.java | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/event/block/BlockPlaceEvent.java b/src/main/java/org/bukkit/event/block/BlockPlaceEvent.java index 6d0ffe81..0ee9e465 100644 --- a/src/main/java/org/bukkit/event/block/BlockPlaceEvent.java +++ b/src/main/java/org/bukkit/event/block/BlockPlaceEvent.java @@ -5,6 +5,7 @@ import org.bukkit.block.BlockState; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; /** @@ -20,14 +21,21 @@ public class BlockPlaceEvent extends BlockEvent implements Cancellable { protected BlockState replacedBlockState; protected ItemStack itemInHand; protected Player player; + protected EquipmentSlot hand; + @Deprecated public BlockPlaceEvent(final Block placedBlock, final BlockState replacedBlockState, final Block placedAgainst, final ItemStack itemInHand, final Player thePlayer, final boolean canBuild) { + this(placedBlock, replacedBlockState, placedAgainst, itemInHand, thePlayer, canBuild, EquipmentSlot.HAND); + } + + public BlockPlaceEvent(final Block placedBlock, final BlockState replacedBlockState, final Block placedAgainst, final ItemStack itemInHand, final Player thePlayer, final boolean canBuild, final EquipmentSlot hand) { super(placedBlock); this.placedAgainst = placedAgainst; this.itemInHand = itemInHand; this.player = thePlayer; this.replacedBlockState = replacedBlockState; this.canBuild = canBuild; + this.hand = hand; cancel = false; } @@ -88,6 +96,14 @@ public class BlockPlaceEvent extends BlockEvent implements Cancellable { } /** + * Gets the hand which placed the block + * @return Main or off-hand, depending on which hand was used to place the block + */ + public EquipmentSlot getHand() { + return this.hand; + } + + /** * 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 |