From d800eb554475163d09f1b190418a8c952d41b92e Mon Sep 17 00:00:00 2001 From: jojo Date: Sun, 19 Jul 2020 10:14:14 +0200 Subject: [PATCH 1/4] Fix help message 15 --- .../src/de/steamwar/bausystem/commands/CommandTrace.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTrace.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTrace.java index 22eb928..70bea5d 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTrace.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTrace.java @@ -31,7 +31,7 @@ public class CommandTrace implements CommandExecutor { player.sendMessage("§8/§etrace toggleshow §8<§7TNT-ID§8> §8- §7Zeigt/Versteckt ein TNT"); player.sendMessage("§8/§etrace delete §8<§7TNT-ID§8> §8- §7Löscht alle TNT-Positionen"); player.sendMessage("§8/§etrace interpolate §8[§eall§8|§eyaxis§8|§enone§8] §8- §7Interpolationsoptionen"); - player.sendMessage("§8/§etrace list §8<§7FRAME-ID§8>§8- §7Listet alle TNT auf"); + player.sendMessage("§8/§etrace list §8<§7FRAME-ID§8> §8- §7Listet alle TNT auf"); //player.sendMessage("§8/§etrace gui §8- §7Zeigt die Trace Oberfläche an"); player.sendMessage("§7Optionale Parameter mit §8<>§7, Benötigte Parameter mit §8[]"); } -- 2.39.5 From df72a08f9922ff5319af95e2d75fa89541b58824 Mon Sep 17 00:00:00 2001 From: jojo Date: Sun, 19 Jul 2020 14:42:55 +0200 Subject: [PATCH 2/4] Fix NullPointerException in delete() --- .../src/de/steamwar/bausystem/tracer/trace/TNTFrame.java | 1 - 1 file changed, 1 deletion(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/tracer/trace/TNTFrame.java b/BauSystem_Main/src/de/steamwar/bausystem/tracer/trace/TNTFrame.java index ca9364b..11301aa 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/tracer/trace/TNTFrame.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/tracer/trace/TNTFrame.java @@ -50,7 +50,6 @@ public class TNTFrame { private void delete(TNTPrimed tntPrimed, boolean delete) { if (aliveTNT == null) return; TNTTrace tntTrace = aliveTNT.get(tntPrimed); - tntTrace.addLocation(tntPrimed.getLocation()); if (delete) { aliveTNT.remove(tntPrimed); } -- 2.39.5 From 7e5d690c9d0e64159a76563e7399bf8cda59ba4f Mon Sep 17 00:00:00 2001 From: jojo Date: Sun, 19 Jul 2020 14:51:40 +0200 Subject: [PATCH 3/4] Fix synchronization Deadlock --- .../de/steamwar/bausystem/tracer/PlayerTraceCache_15.java | 7 ++++++- .../src/de/steamwar/bausystem/tracer/TNTTracer12.java | 6 +++--- .../src/de/steamwar/bausystem/tracer/TNTTracer15.java | 1 + .../de/steamwar/bausystem/tracer/trace/ShowManager.java | 8 ++++++++ .../de/steamwar/bausystem/tracer/trace/ShowStatus.java | 2 +- 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/BauSystem_15/src/de/steamwar/bausystem/tracer/PlayerTraceCache_15.java b/BauSystem_15/src/de/steamwar/bausystem/tracer/PlayerTraceCache_15.java index 16fc7e9..f60583b 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/tracer/PlayerTraceCache_15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/tracer/PlayerTraceCache_15.java @@ -23,6 +23,8 @@ public class PlayerTraceCache_15 { private float[] pLocation; private float locationThreshold = square(10.0F); + private boolean hiding = false; + public PlayerTraceCache_15() { this.pLocation = new float[]{0.0F, 0.0F, 0.0F}; } @@ -49,7 +51,8 @@ public class PlayerTraceCache_15 { return false; } - public synchronized void show(Player player, TNTShowCallback_15.ShowMode showMode) { + public void show(Player player, TNTShowCallback_15.ShowMode showMode) { + if (hiding) return; if (positions.length == 0 || positions.length % 3 != 0) return; for (int i = 0; i < positions.length; i += 3) { float x = positions[i + 0]; @@ -84,6 +87,7 @@ public class PlayerTraceCache_15 { } public synchronized void hide(Player player) { + hiding = true; if (positions.length == 0 || positions.length % 3 != 0) return; for (int i = 0; i < positions.length; i += 3) { float x = positions[i + 0]; @@ -102,6 +106,7 @@ public class PlayerTraceCache_15 { hideBlock(player, x, y + 0.49F, z); } updatePoints = new float[0]; + hiding = false; } private static void showCorner(Player player, float x, float y, float z, Particle particle) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/tracer/TNTTracer12.java b/BauSystem_Main/src/de/steamwar/bausystem/tracer/TNTTracer12.java index 37fc4fb..8d02563 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/tracer/TNTTracer12.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/tracer/TNTTracer12.java @@ -29,7 +29,7 @@ public class TNTTracer12 { TNTTracer_12.remove(locations, tnt); } - public static void start(){ + public static void start() { if(status == Status.RECORD) return; stop(); @@ -39,7 +39,7 @@ public class TNTTracer12 { task = Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), TNTTracer12::run, 1, 1); } - public static int show(){ + public static int show() { if(status == Status.SHOW) return printedLocs.size(); stop(); @@ -48,7 +48,7 @@ public class TNTTracer12 { return TNTTracer_12.show(locations, printedLocs); } - public static void stop(){ + public static void stop() { status = Status.IDLE; if(task != null) task.cancel(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/tracer/TNTTracer15.java b/BauSystem_Main/src/de/steamwar/bausystem/tracer/TNTTracer15.java index 2d49dba..af13218 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/tracer/TNTTracer15.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/tracer/TNTTracer15.java @@ -326,6 +326,7 @@ public class TNTTracer15 { Bukkit.getOnlinePlayers().forEach(player -> player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText("§7Automatischer TNT-Tracer §8- §aAufnahme gestoppt"))); status = Status.IDLE_AUTO; } + ShowManager.dirty(); if (task != null) task.cancel(); if (tntFrames.getLast().finish()) { tntFrames.removeLast(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/tracer/trace/ShowManager.java b/BauSystem_Main/src/de/steamwar/bausystem/tracer/trace/ShowManager.java index 5506762..d87f465 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/tracer/trace/ShowManager.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/tracer/trace/ShowManager.java @@ -15,6 +15,14 @@ public class ShowManager { TNTTracer15.worldInit(); } + public static void dirty() { + for (Map.Entry entry : showMap.entrySet()) { + if (entry.getValue().getShow() != ShowStatus.Show.NONE) { + entry.getValue().dirty = true; + } + } + } + public static void remove(Player player) { showMap.remove(player); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/tracer/trace/ShowStatus.java b/BauSystem_Main/src/de/steamwar/bausystem/tracer/trace/ShowStatus.java index 0b65c54..a9949d3 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/tracer/trace/ShowStatus.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/tracer/trace/ShowStatus.java @@ -16,7 +16,7 @@ public class ShowStatus { private Player p; - private boolean dirty = false; + boolean dirty = false; public ShowStatus(Player p) { this.p = p; -- 2.39.5 From 6f558b6b91a79ea018e5e528e9875d04a7140eb3 Mon Sep 17 00:00:00 2001 From: jojo Date: Sun, 19 Jul 2020 14:54:07 +0200 Subject: [PATCH 4/4] Fix dirty Flaging --- .../de/steamwar/bausystem/tracer/trace/ShowManager.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/tracer/trace/ShowManager.java b/BauSystem_Main/src/de/steamwar/bausystem/tracer/trace/ShowManager.java index d87f465..74a438e 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/tracer/trace/ShowManager.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/tracer/trace/ShowManager.java @@ -1,6 +1,7 @@ package de.steamwar.bausystem.tracer.trace; import de.steamwar.bausystem.tracer.TNTTracer15; +import org.bukkit.Bukkit; import org.bukkit.entity.Player; import java.util.HashMap; @@ -16,9 +17,9 @@ public class ShowManager { } public static void dirty() { - for (Map.Entry entry : showMap.entrySet()) { - if (entry.getValue().getShow() != ShowStatus.Show.NONE) { - entry.getValue().dirty = true; + for (Player player : Bukkit.getOnlinePlayers()) { + if (showMap.get(player).getShow() != ShowStatus.Show.NONE) { + showMap.get(player).dirty = true; } } } -- 2.39.5