diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockPlaceEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockPlaceEvent.java index 6d0ffe81cc..0ee9e465e2 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockPlaceEvent.java +++ b/paper-api/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; } @@ -87,6 +95,14 @@ public class BlockPlaceEvent extends BlockEvent implements Cancellable { return itemInHand; } + /** + * 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