From 8d10a702b438bc03700d2cfde67b6e6d047e6768 Mon Sep 17 00:00:00 2001 From: jojo Date: Sun, 19 Jul 2020 17:21:33 +0200 Subject: [PATCH] Fix ConcurrentModificationException --- .../src/de/steamwar/bausystem/tracer/TNTTracer_15.java | 8 +++++++- .../tracer/showcallback/TracerCallbackTracing_15.java | 8 ++++++++ .../src/de/steamwar/bausystem/tracer/TNTTracer15.java | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 BauSystem_15/src/de/steamwar/bausystem/tracer/showcallback/TracerCallbackTracing_15.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 5c1cc63..7847323 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/tracer/TNTTracer_15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/tracer/TNTTracer_15.java @@ -21,6 +21,7 @@ class TNTTracer_15 { private static TracerCallback_15 tracerCallback; private static TracerCallbackUpdatePoints_15 tracerCallbackUpdatePoints; + private static TracerCallbackTracing_15 tracerCallbackTracing; private static TracerActionBarCallback_15 tracerActionBarCallback; private static TNTShowCallback_15 tntShowCallback; private static CacheUpdateCallback_15 cacheUpdateCallback; @@ -39,7 +40,7 @@ class TNTTracer_15 { return d * d; } - static void init(Plugin plugin, TracerCallback_15 tracerCallback, TracerCallbackUpdatePoints_15 tracerCallbackUpdatePoints, TracerActionBarCallback_15 tracerActionBarCallback, TNTShowCallback_15 tntShowCallback, CacheUpdateCallback_15 cacheUpdateCallback) { + static void init(Plugin plugin, TracerCallback_15 tracerCallback, TracerCallbackUpdatePoints_15 tracerCallbackUpdatePoints, TracerActionBarCallback_15 tracerActionBarCallback, TNTShowCallback_15 tntShowCallback, CacheUpdateCallback_15 cacheUpdateCallback, TracerCallbackTracing_15 tracerCallbackTracing) { Bukkit.getScheduler().runTaskTimer(plugin, () -> { synchronized (synchronizer) { synchronizer.notifyAll(); @@ -63,6 +64,7 @@ class TNTTracer_15 { TNTTracer_15.tracerActionBarCallback = tracerActionBarCallback; TNTTracer_15.tntShowCallback = tntShowCallback; TNTTracer_15.cacheUpdateCallback = cacheUpdateCallback; + TNTTracer_15.tracerCallbackTracing = tracerCallbackTracing; } static void initWorld() { @@ -100,6 +102,10 @@ class TNTTracer_15 { private static float[] noValue = new float[0]; private static void update(Player p, PlayerTraceCache_15 traceCache) { + if (tracerCallbackTracing.run()) { + return; + } + float[] floats = tracerCallback.run(p); if (floats.length == 0 || floats.length % 3 != 0) { traceCache.setPositions(noValue); diff --git a/BauSystem_15/src/de/steamwar/bausystem/tracer/showcallback/TracerCallbackTracing_15.java b/BauSystem_15/src/de/steamwar/bausystem/tracer/showcallback/TracerCallbackTracing_15.java new file mode 100644 index 0000000..b456011 --- /dev/null +++ b/BauSystem_15/src/de/steamwar/bausystem/tracer/showcallback/TracerCallbackTracing_15.java @@ -0,0 +1,8 @@ +package de.steamwar.bausystem.tracer.showcallback; + +@FunctionalInterface +public interface TracerCallbackTracing_15 { + + boolean run(); + +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/tracer/TNTTracer15.java b/BauSystem_Main/src/de/steamwar/bausystem/tracer/TNTTracer15.java index af13218..d39dd86 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/tracer/TNTTracer15.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/tracer/TNTTracer15.java @@ -44,7 +44,7 @@ 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, TNTTracer15::getActionBar, TNTTracer15::showMode, p -> ShowManager.get(p).isDirty()); + TNTTracer_15.init(BauSystem.getPlugin(), TNTTracer15::getTracePoints, TNTTracer15::getTraceUpdatePoints, TNTTracer15::getActionBar, TNTTracer15::showMode, p -> ShowManager.get(p).isDirty(), () -> status == Status.RECORD || status == Status.RECORD_AUTO); } private static float[] accumulate(LinkedList traces) {