diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/countingwand/CountingwandListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/countingwand/CountingwandListener.java index 3fedffce..ced97677 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/countingwand/CountingwandListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/countingwand/CountingwandListener.java @@ -22,12 +22,14 @@ package de.steamwar.bausystem.features.countingwand; import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.region.Point; +import org.bukkit.FluidCollisionMode; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.block.Action; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.util.RayTraceResult; import java.util.Objects; @@ -51,6 +53,14 @@ public class CountingwandListener implements Listener { return; } + if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_AIR) { + RayTraceResult rayTraceResult = event.getPlayer().rayTraceBlocks(200, FluidCollisionMode.NEVER); + if (rayTraceResult == null) { + return; + } + Countingwand.checkSelection(Point.fromLocation(Objects.requireNonNull(rayTraceResult.getHitBlock()).getLocation()), event.getAction() == Action.LEFT_CLICK_AIR, event.getPlayer()); + return; + } if (event.getAction() != Action.RIGHT_CLICK_BLOCK) { return; }