From 5e9d3ccfdee95b652d24d0786f2c8037cf4106e2 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Wed, 22 Dec 2021 11:56:23 +0100 Subject: [PATCH] Add CountingwandListener more range Signed-off-by: yoyosource --- .../features/countingwand/CountingwandListener.java | 10 ++++++++++ 1 file changed, 10 insertions(+) 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; }