From fc8d52cae4d9d36f60c3c99519f2a3f81f52bcf6 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 3 Oct 2021 23:02:11 +0200 Subject: [PATCH] Fix SmartPlaceListener Signed-off-by: yoyosource --- .../smartplace/SmartPlaceListener.java | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) 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());