diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/smartplace/SmartPlaceListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/smartplace/SmartPlaceListener.java index 54411686..84b0053c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/smartplace/SmartPlaceListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/smartplace/SmartPlaceListener.java @@ -37,6 +37,8 @@ import org.bukkit.event.Listener; import org.bukkit.event.block.Action; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.InventoryHolder; @Linked(LinkageType.LISTENER) public class SmartPlaceListener implements Listener { @@ -62,9 +64,11 @@ public class SmartPlaceListener implements Listener { @EventHandler public void onPlayerInteract(PlayerInteractEvent event) { - if (event.getPlayer().getGameMode() == GameMode.SPECTATOR) return; if (event.getAction() != Action.RIGHT_CLICK_BLOCK) return; + if (event.getPlayer().getGameMode() == GameMode.SPECTATOR) return; if (!Config.getInstance().get(event.getPlayer()).getPlainValueOrDefault("smartPlace", false)) return; + + // Reverse repeater if (event.getPlayer().isSneaking()) { if (event.getClickedBlock().getType() == Material.REPEATER) { if (event.getItem() != null && event.getMaterial() != Material.REPEATER) { @@ -79,8 +83,8 @@ public class SmartPlaceListener implements Listener { } return; } - if (!event.getClickedBlock().getType().isInteractable()) return; + if (!event.getClickedBlock().getType().isInteractable()) return; if (event.getItem() == null) return; if (!event.getMaterial().isBlock()) return; try { @@ -93,24 +97,20 @@ public class SmartPlaceListener implements Listener { } if (event.getClickedBlock().getType() == event.getMaterial()) { - switch (event.getMaterial()) { - case HOPPER: - case DISPENSER: - case DROPPER: - break; - default: - return; + if (!(event.getClickedBlock().getState() instanceof InventoryHolder)) { + return; } } else { - switch (event.getMaterial()) { - case REPEATER: - case COMPARATOR: - return; - default: - break; + BlockData blockData = event.getMaterial().createBlockData(); + if (blockData instanceof Directional) { + return; + } + if (blockData instanceof Rotatable) { + return; } } + // TODO: Fix block setting event.setUseInteractedBlock(Event.Result.DENY); World world = event.getPlayer().getWorld(); Block block = world.getBlockAt(event.getClickedBlock().getX() + event.getBlockFace().getModX(), event.getClickedBlock().getY() + event.getBlockFace().getModY(), event.getClickedBlock().getZ() + event.getBlockFace().getModZ());