diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/observer/ObserverTracer.java b/BauSystem_Main/src/de/steamwar/bausystem/features/observer/ObserverTracer.java index 878380f1..655e82b8 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/observer/ObserverTracer.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/observer/ObserverTracer.java @@ -39,31 +39,23 @@ public class ObserverTracer { private Player player; private Block block; - private Set seen = new HashSet<>(); + Set seen = new HashSet<>(); private List blockList = new ArrayList<>(); - private int retrace = 0; - public ObserverTracer(Player player, Block block) { this.player = player; this.block = block; } public void show() { - retrace++; - if (retrace > 4) { - retrace = 0; - seen.clear(); - blockList.clear(); - trace(); - return; - } for (Location l : seen) { spawnParticle(player, l, l.getBlock()); } } public void trace() { + seen.clear(); + blockList.clear(); if (block.getType() != Material.OBSERVER) { return; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/observer/ObserverTracerListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/observer/ObserverTracerListener.java index e0ba837b..a2542d61 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/observer/ObserverTracerListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/observer/ObserverTracerListener.java @@ -47,15 +47,19 @@ public class ObserverTracerListener implements Listener { @EventHandler public void onPlayerInteract(PlayerInteractEvent event) { - if (event.getMaterial() == Material.OBSERVER) { + if (event.getClickedBlock() == null) { return; } + if (observerTracerMap.containsKey(event.getPlayer())) { + ObserverTracer observerTracer = observerTracerMap.get(event.getPlayer()); + if (observerTracer.seen.contains(event.getClickedBlock().getLocation())) { + Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), observerTracer::trace, 1L); + return; + } + } if (event.getAction() != Action.RIGHT_CLICK_BLOCK) { return; } - if (event.getClickedBlock() == null) { - return; - } if (event.getClickedBlock().getType() == Material.OBSERVER) { ObserverTracer observerTracer = new ObserverTracer(event.getPlayer(), event.getClickedBlock()); observerTracer.trace();