SteamWar/BauSystem
Archiviert
13
0

Fix ConcurrentModificationException #76

Manuell gemergt
Lixfel hat 1 Commits von TNTTracer nach master 2020-07-19 17:29:19 +02:00 zusammengeführt
3 geänderte Dateien mit 16 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -21,6 +21,7 @@ class TNTTracer_15 {
private static TracerCallback_15 tracerCallback; private static TracerCallback_15 tracerCallback;
private static TracerCallbackUpdatePoints_15 tracerCallbackUpdatePoints; private static TracerCallbackUpdatePoints_15 tracerCallbackUpdatePoints;
private static TracerCallbackTracing_15 tracerCallbackTracing;
private static TracerActionBarCallback_15 tracerActionBarCallback; private static TracerActionBarCallback_15 tracerActionBarCallback;
private static TNTShowCallback_15 tntShowCallback; private static TNTShowCallback_15 tntShowCallback;
private static CacheUpdateCallback_15 cacheUpdateCallback; private static CacheUpdateCallback_15 cacheUpdateCallback;
@ -39,7 +40,7 @@ class TNTTracer_15 {
return d * d; 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, () -> { Bukkit.getScheduler().runTaskTimer(plugin, () -> {
synchronized (synchronizer) { synchronized (synchronizer) {
synchronizer.notifyAll(); synchronizer.notifyAll();
@ -63,6 +64,7 @@ class TNTTracer_15 {
TNTTracer_15.tracerActionBarCallback = tracerActionBarCallback; TNTTracer_15.tracerActionBarCallback = tracerActionBarCallback;
TNTTracer_15.tntShowCallback = tntShowCallback; TNTTracer_15.tntShowCallback = tntShowCallback;
TNTTracer_15.cacheUpdateCallback = cacheUpdateCallback; TNTTracer_15.cacheUpdateCallback = cacheUpdateCallback;
TNTTracer_15.tracerCallbackTracing = tracerCallbackTracing;
} }
static void initWorld() { static void initWorld() {
@ -100,6 +102,10 @@ class TNTTracer_15 {
private static float[] noValue = new float[0]; private static float[] noValue = new float[0];
private static void update(Player p, PlayerTraceCache_15 traceCache) { private static void update(Player p, PlayerTraceCache_15 traceCache) {
if (tracerCallbackTracing.run()) {
return;
}
float[] floats = tracerCallback.run(p); float[] floats = tracerCallback.run(p);
if (floats.length == 0 || floats.length % 3 != 0) { if (floats.length == 0 || floats.length % 3 != 0) {
traceCache.setPositions(noValue); traceCache.setPositions(noValue);

Datei anzeigen

@ -0,0 +1,8 @@
package de.steamwar.bausystem.tracer.showcallback;
@FunctionalInterface
public interface TracerCallbackTracing_15 {
boolean run();
}

Datei anzeigen

@ -44,7 +44,7 @@ public class TNTTracer15 {
private static final float[] noValue = new float[0]; private static final float[] noValue = new float[0];
public static void initTNTTracer_15() { 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<TNTTrace> traces) { private static float[] accumulate(LinkedList<TNTTrace> traces) {