From b999cb4195e9b436d71fb00639c08ed01b756f0d Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Thu, 14 Feb 2019 17:38:36 +0000 Subject: [PATCH] Fix players being able to place boats, armorstands etc using offhand --- .../bukkit/listeners/PlayerEvents.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java index ea5f96be0..8d98ddb03 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java @@ -1886,23 +1886,29 @@ import java.util.regex.Pattern; break; } ItemStack hand = player.getInventory().getItemInMainHand(); + ItemStack offHand = player.getInventory().getItemInOffHand(); Material type = (hand == null) ? null : hand.getType(); - if (type == Material.AIR) { + Material offType = (offHand == null) ? null : offHand.getType(); + if ((type == Material.AIR && offType != Material.AIR && !player.isSneaking() + && blockType.isInteractable()) || (type == Material.AIR + && offType == Material.AIR)) { eventType = PlayerBlockEventType.INTERACT_BLOCK; break; } + if (!(type != null && type.equals(offType))) { + type = offType; + } if (type == null || type.isBlock()) { location = BukkitUtil .getLocation(block.getRelative(event.getBlockFace()).getLocation()); eventType = PlayerBlockEventType.PLACE_BLOCK; break; } - Material handType = hand.getType(); - lb = new BukkitLazyBlock(PlotBlock.get(handType.toString())); - if (handType.toString().endsWith("egg")) { + lb = new BukkitLazyBlock(PlotBlock.get(type.toString())); + if (type.toString().endsWith("egg")) { eventType = PlayerBlockEventType.SPAWN_MOB; } else { - switch (handType) { + switch (type) { case FIREWORK_ROCKET: case FIREWORK_STAR: eventType = PlayerBlockEventType.SPAWN_MOB;