From 423ec6999620885b2958b62dc1590e6015254785 Mon Sep 17 00:00:00 2001 From: jojo Date: Sat, 25 Jul 2020 21:09:27 +0200 Subject: [PATCH 1/2] Fix Trace show/hide Bug --- .../src/de/steamwar/bausystem/tracer/TNTTracer_15.java | 4 ++-- .../tracer/updatecallback/TracerUpdateManager.java | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 BauSystem_API/src/de/steamwar/bausystem/tracer/updatecallback/TracerUpdateManager.java diff --git a/BauSystem_15/src/de/steamwar/bausystem/tracer/TNTTracer_15.java b/BauSystem_15/src/de/steamwar/bausystem/tracer/TNTTracer_15.java index 95911bf..de72554 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/tracer/TNTTracer_15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/tracer/TNTTracer_15.java @@ -97,7 +97,7 @@ class TNTTracer_15 { } private static void updateShowPlayer(Player p, PlayerTraceCache_15 traceCache) { - if (!tntCallbackCacheUpdate.run(p) && traceCache.nearLastLocation(p)) { + if (!tntCallbackCacheUpdate.run(p)) { update(p, traceCache); } traceCache.show(p, tntCallbackShow.run(p)); @@ -106,7 +106,7 @@ class TNTTracer_15 { private static float[] noValue = new float[0]; private static void update(Player p, PlayerTraceCache_15 traceCache) { - if (tracerCallbackTracing.run(p)) { + if (!tracerCallbackTracing.run(p) && traceCache.nearLastLocation(p)) { return; } diff --git a/BauSystem_API/src/de/steamwar/bausystem/tracer/updatecallback/TracerUpdateManager.java b/BauSystem_API/src/de/steamwar/bausystem/tracer/updatecallback/TracerUpdateManager.java new file mode 100644 index 0000000..223249c --- /dev/null +++ b/BauSystem_API/src/de/steamwar/bausystem/tracer/updatecallback/TracerUpdateManager.java @@ -0,0 +1,9 @@ +package de.steamwar.bausystem.tracer.updatecallback; + +public class TracerUpdateManager { + + public TracerUpdateManager() { + + } + +} From bb8c6c259ec6924b9159f128465bda32356c862d Mon Sep 17 00:00:00 2001 From: jojo Date: Sat, 25 Jul 2020 21:16:58 +0200 Subject: [PATCH 2/2] Fix Trace show/hide Bug --- .../bausystem/tracer/TNTTracer_15.java | 16 +++++-------- .../bausystem/tracer/TracerUpdateManager.java | 23 +++++++++++++++++++ .../updatecallback/TracerUpdateManager.java | 9 -------- .../bausystem/tracer/TNTTracer15.java | 4 ++-- 4 files changed, 31 insertions(+), 21 deletions(-) create mode 100644 BauSystem_API/src/de/steamwar/bausystem/tracer/TracerUpdateManager.java delete mode 100644 BauSystem_API/src/de/steamwar/bausystem/tracer/updatecallback/TracerUpdateManager.java diff --git a/BauSystem_15/src/de/steamwar/bausystem/tracer/TNTTracer_15.java b/BauSystem_15/src/de/steamwar/bausystem/tracer/TNTTracer_15.java index de72554..fd1c2e8 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/tracer/TNTTracer_15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/tracer/TNTTracer_15.java @@ -24,10 +24,10 @@ class TNTTracer_15 { private static TracerCallbackPositions tracerCallbackPositions; private static TracerCallbackUpdatePoints tracerCallbackUpdatePoints; - private static TracerCallbackTracing tracerCallbackTracing; private static DebugCallbackActionBar debugCallbackActionBar; private static TNTCallbackShow tntCallbackShow; - private static TNTCallbackCacheUpdate tntCallbackCacheUpdate; + + private static TracerUpdateManager tracerUpdateManager; private static Map playerMap = new HashMap<>(); @@ -43,7 +43,7 @@ class TNTTracer_15 { return d * d; } - static void init(Plugin plugin, TracerCallbackPositions tracerCallbackPositions, TracerCallbackUpdatePoints tracerCallbackUpdatePoints, TracerCallbackTracing tracerCallbackTracing, DebugCallbackActionBar debugCallbackActionBar, TNTCallbackShow tntCallbackShow, TNTCallbackCacheUpdate tntCallbackCacheUpdate) { + static void init(Plugin plugin, TracerCallbackPositions tracerCallbackPositions, TracerCallbackUpdatePoints tracerCallbackUpdatePoints, DebugCallbackActionBar debugCallbackActionBar, TNTCallbackShow tntCallbackShow, TracerUpdateManager tracerUpdateManager) { Bukkit.getScheduler().runTaskTimer(plugin, () -> { synchronized (synchronizer) { synchronizer.notifyAll(); @@ -66,8 +66,8 @@ class TNTTracer_15 { TNTTracer_15.tracerCallbackUpdatePoints = tracerCallbackUpdatePoints; TNTTracer_15.debugCallbackActionBar = debugCallbackActionBar; TNTTracer_15.tntCallbackShow = tntCallbackShow; - TNTTracer_15.tntCallbackCacheUpdate = tntCallbackCacheUpdate; - TNTTracer_15.tracerCallbackTracing = tracerCallbackTracing; + + TNTTracer_15.tracerUpdateManager = tracerUpdateManager; } static void initWorld() { @@ -97,7 +97,7 @@ class TNTTracer_15 { } private static void updateShowPlayer(Player p, PlayerTraceCache_15 traceCache) { - if (!tntCallbackCacheUpdate.run(p)) { + if (tracerUpdateManager.run(p, traceCache.nearLastLocation(p))) { update(p, traceCache); } traceCache.show(p, tntCallbackShow.run(p)); @@ -106,10 +106,6 @@ class TNTTracer_15 { private static float[] noValue = new float[0]; private static void update(Player p, PlayerTraceCache_15 traceCache) { - if (!tracerCallbackTracing.run(p) && traceCache.nearLastLocation(p)) { - return; - } - float[] floats = tracerCallbackPositions.run(p); if (floats.length == 0 || floats.length % 3 != 0) { traceCache.setPositions(noValue); diff --git a/BauSystem_API/src/de/steamwar/bausystem/tracer/TracerUpdateManager.java b/BauSystem_API/src/de/steamwar/bausystem/tracer/TracerUpdateManager.java new file mode 100644 index 0000000..8000f2f --- /dev/null +++ b/BauSystem_API/src/de/steamwar/bausystem/tracer/TracerUpdateManager.java @@ -0,0 +1,23 @@ +package de.steamwar.bausystem.tracer; + +import de.steamwar.bausystem.tracer.showcallback.TNTCallbackCacheUpdate; +import de.steamwar.bausystem.tracer.updatecallback.TracerCallbackTracing; +import org.bukkit.entity.Player; + +public class TracerUpdateManager { + + private TracerCallbackTracing tracerCallbackTracing; + private TNTCallbackCacheUpdate tntCallbackCacheUpdate; + + public TracerUpdateManager(TracerCallbackTracing tracerCallbackTracing, TNTCallbackCacheUpdate tntCallbackCacheUpdate) { + this.tracerCallbackTracing = tracerCallbackTracing; + this.tntCallbackCacheUpdate = tntCallbackCacheUpdate; + } + + boolean run(Player p, boolean nearLastLocation) { + if (tntCallbackCacheUpdate.run(p)) return false; + if (!tracerCallbackTracing.run(p) && nearLastLocation) return false; + return true; + } + +} diff --git a/BauSystem_API/src/de/steamwar/bausystem/tracer/updatecallback/TracerUpdateManager.java b/BauSystem_API/src/de/steamwar/bausystem/tracer/updatecallback/TracerUpdateManager.java deleted file mode 100644 index 223249c..0000000 --- a/BauSystem_API/src/de/steamwar/bausystem/tracer/updatecallback/TracerUpdateManager.java +++ /dev/null @@ -1,9 +0,0 @@ -package de.steamwar.bausystem.tracer.updatecallback; - -public class TracerUpdateManager { - - public TracerUpdateManager() { - - } - -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/tracer/TNTTracer15.java b/BauSystem_Main/src/de/steamwar/bausystem/tracer/TNTTracer15.java index 8137898..4391181 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/tracer/TNTTracer15.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/tracer/TNTTracer15.java @@ -45,12 +45,12 @@ public class TNTTracer15 { private static final float[] noValue = new float[0]; public static void initTNTTracer_15() { - TNTTracer_15.init(BauSystem.getPlugin(), TNTTracer15::getTracePoints, TNTTracer15::getTraceUpdatePoints, p -> ShowManager.get(p).isDirty(), TNTTracer15::getActionBar, TNTTracer15::showMode, p -> { + TNTTracer_15.init(BauSystem.getPlugin(), TNTTracer15::getTracePoints, TNTTracer15::getTraceUpdatePoints, TNTTracer15::getActionBar, TNTTracer15::showMode, new TracerUpdateManager(p -> ShowManager.get(p).isDirty(), p -> { if (System.currentTimeMillis() - lastExplosion < 4500) { ShowManager.get(p).dirty(); } return System.currentTimeMillis() - lastExplosion < 4500; - }); + })); } private static float[] accumulate(LinkedList traces) {