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 f60583b..922cc31 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/tracer/PlayerTraceCache_15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/tracer/PlayerTraceCache_15.java @@ -1,6 +1,6 @@ package de.steamwar.bausystem.tracer; -import de.steamwar.bausystem.tracer.showcallback.TNTShowCallback_15; +import de.steamwar.bausystem.tracer.showcallback.TNTCallbackShow; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -51,7 +51,7 @@ public class PlayerTraceCache_15 { return false; } - public void show(Player player, TNTShowCallback_15.ShowMode showMode) { + public void show(Player player, TNTCallbackShow.ShowMode showMode) { if (hiding) return; if (positions.length == 0 || positions.length % 3 != 0) return; for (int i = 0; i < positions.length; i += 3) { @@ -59,7 +59,7 @@ public class PlayerTraceCache_15 { float y = positions[i + 1]; float z = positions[i + 2]; - if (showMode == TNTShowCallback_15.ShowMode.PARTICLE && positions.length / 3 < 1000) { + if (showMode == TNTCallbackShow.ShowMode.PARTICLE && positions.length / 3 < 1000) { showCorner(player, x - 0.49F, y, z - 0.49F, Particle.FLAME); } else { showBlock(player, x, y + 0.49F, z, Material.RED_STAINED_GLASS, (byte) 14); @@ -78,7 +78,7 @@ public class PlayerTraceCache_15 { if (hasBlock(positions, x, y, z)) continue; - if (showMode == TNTShowCallback_15.ShowMode.PARTICLE) { + if (showMode == TNTCallbackShow.ShowMode.PARTICLE) { showCorner(player, x - 0.49F, y, z - 0.49F, Particle.VILLAGER_HAPPY); } else { showBlock(player, x, y + 0.49F, z, Material.LIME_STAINED_GLASS, (byte) 5); diff --git a/BauSystem_15/src/de/steamwar/bausystem/tracer/TNTTracerGUI_15.java b/BauSystem_15/src/de/steamwar/bausystem/tracer/TNTTracerGUI_15.java index fa2664a..24f24b2 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/tracer/TNTTracerGUI_15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/tracer/TNTTracerGUI_15.java @@ -1,8 +1,8 @@ package de.steamwar.bausystem.tracer; -import de.steamwar.bausystem.tracer.guicallback.RecordingCallback_15; -import de.steamwar.bausystem.tracer.guicallback.TNTFrameCallback_15; -import de.steamwar.bausystem.tracer.guicallback.TNTTraceCallback_15; +import de.steamwar.bausystem.tracer.guicallback.GuiCallbackRecording; +import de.steamwar.bausystem.tracer.guicallback.GuiCallbackTNTFrame; +import de.steamwar.bausystem.tracer.guicallback.GuiCallbackTNTTrace; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; @@ -17,9 +17,9 @@ import java.util.List; public class TNTTracerGUI_15 { - private static TNTFrameCallback_15 tntFrameCallback_15; - private static TNTTraceCallback_15 tntTraceCallback_15; - private static RecordingCallback_15 recordingCallback_15; + private static GuiCallbackTNTFrame guiCallbackTNTFrame; + private static GuiCallbackTNTTrace guiCallbackTNTTrace; + private static GuiCallbackRecording guiCallbackRecording; private static Inventory getEmpty(String title) { Inventory inventory = Bukkit.createInventory(null, 54, title); @@ -60,12 +60,12 @@ public class TNTTracerGUI_15 { inventory.setItem(1, createItem(Material.HONEYCOMB, false, "§eShow§8/§eHide")); inventory.setItem(4, createItem(Material.BARRIER, false, "§eClear ausgewählte Positionen")); inventory.setItem(5, createItem(Material.OBSERVER, false, "§eToggle AUTO-Trace")); - inventory.setItem(6, recordingCallback_15.run()); + inventory.setItem(6, guiCallbackRecording.run()); inventory.setItem(8, createItem(Material.PAPER, false, "§7PAGE §e§l" + page + "§8/§e§l" + allPages)); } private static Inventory getFrameInventory(Player p, int page) { - ItemStack[] items = tntFrameCallback_15.run(p); + ItemStack[] items = guiCallbackTNTFrame.run(p); Inventory inventory = getEmpty("§7§lTRACE §8- §e§lAufnahmen"); if (items.length == 0) { @@ -76,10 +76,10 @@ public class TNTTracerGUI_15 { return inventory; } - public static void init(TNTFrameCallback_15 tntFrameCallback_15, TNTTraceCallback_15 tntTraceCallback_15, RecordingCallback_15 recordingCallback_15) { - TNTTracerGUI_15.tntFrameCallback_15 = tntFrameCallback_15; - TNTTracerGUI_15.tntTraceCallback_15 = tntTraceCallback_15; - TNTTracerGUI_15.recordingCallback_15 = recordingCallback_15; + public static void init(GuiCallbackTNTFrame guiCallbackTNTFrame, GuiCallbackTNTTrace guiCallbackTNTTrace, GuiCallbackRecording guiCallbackRecording) { + TNTTracerGUI_15.guiCallbackTNTFrame = guiCallbackTNTFrame; + TNTTracerGUI_15.guiCallbackTNTTrace = guiCallbackTNTTrace; + TNTTracerGUI_15.guiCallbackRecording = guiCallbackRecording; } public enum Menu { 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 feea293..7bf223f 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/tracer/TNTTracer_15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/tracer/TNTTracer_15.java @@ -1,6 +1,9 @@ package de.steamwar.bausystem.tracer; -import de.steamwar.bausystem.tracer.showcallback.*; +import de.steamwar.bausystem.tracer.debugcallback.DebugCallbackActionBar; +import de.steamwar.bausystem.tracer.showcallback.TNTCallbackCacheUpdate; +import de.steamwar.bausystem.tracer.showcallback.TNTCallbackShow; +import de.steamwar.bausystem.tracer.updatecallback.*; import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.Bukkit; @@ -19,12 +22,12 @@ class TNTTracer_15 { private 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; + 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 Map playerMap = new HashMap<>(); @@ -40,7 +43,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, TracerCallbackTracing_15 tracerCallbackTracing) { + static void init(Plugin plugin, TracerCallbackPositions tracerCallbackPositions, TracerCallbackUpdatePoints tracerCallbackUpdatePoints, TracerCallbackTracing tracerCallbackTracing, DebugCallbackActionBar debugCallbackActionBar, TNTCallbackShow tntCallbackShow, TNTCallbackCacheUpdate tntCallbackCacheUpdate) { Bukkit.getScheduler().runTaskTimer(plugin, () -> { synchronized (synchronizer) { synchronizer.notifyAll(); @@ -59,11 +62,11 @@ class TNTTracer_15 { } }); - TNTTracer_15.tracerCallback = tracerCallback; + TNTTracer_15.tracerCallbackPositions = tracerCallbackPositions; TNTTracer_15.tracerCallbackUpdatePoints = tracerCallbackUpdatePoints; - TNTTracer_15.tracerActionBarCallback = tracerActionBarCallback; - TNTTracer_15.tntShowCallback = tntShowCallback; - TNTTracer_15.cacheUpdateCallback = cacheUpdateCallback; + TNTTracer_15.debugCallbackActionBar = debugCallbackActionBar; + TNTTracer_15.tntCallbackShow = tntCallbackShow; + TNTTracer_15.tntCallbackCacheUpdate = tntCallbackCacheUpdate; TNTTracer_15.tracerCallbackTracing = tracerCallbackTracing; } @@ -77,7 +80,7 @@ class TNTTracer_15 { private static void run() { if (actionBar) { - String actionBar = tracerActionBarCallback.run(); + String actionBar = debugCallbackActionBar.run(); Bukkit.getOnlinePlayers().forEach(player -> player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(actionBar))); } for (Player p : Bukkit.getOnlinePlayers()) { @@ -89,13 +92,13 @@ class TNTTracer_15 { traceCache = playerMap.get(p); } - if (!traceCache.nearLastLocation(p) && !cacheUpdateCallback.run(p)) { - traceCache.show(p, tntShowCallback.run(p)); + if (!traceCache.nearLastLocation(p) && !tntCallbackCacheUpdate.run(p)) { + traceCache.show(p, tntCallbackShow.run(p)); continue; } update(p, traceCache); - traceCache.show(p, tntShowCallback.run(p)); + traceCache.show(p, tntCallbackShow.run(p)); } } @@ -106,7 +109,7 @@ class TNTTracer_15 { return; } - float[] floats = tracerCallback.run(p); + float[] floats = tracerCallbackPositions.run(p); if (floats.length == 0 || floats.length % 3 != 0) { traceCache.setPositions(noValue); traceCache.setUpdatePoints(noValue); diff --git a/BauSystem_15/src/de/steamwar/bausystem/tracer/showcallback/TracerActionBarCallback_15.java b/BauSystem_15/src/de/steamwar/bausystem/tracer/showcallback/TracerActionBarCallback_15.java deleted file mode 100644 index adc5cef..0000000 --- a/BauSystem_15/src/de/steamwar/bausystem/tracer/showcallback/TracerActionBarCallback_15.java +++ /dev/null @@ -1,8 +0,0 @@ -package de.steamwar.bausystem.tracer.showcallback; - -@FunctionalInterface -public interface TracerActionBarCallback_15 { - - String run(); - -} 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 deleted file mode 100644 index 16ee5b7..0000000 --- a/BauSystem_15/src/de/steamwar/bausystem/tracer/showcallback/TracerCallbackTracing_15.java +++ /dev/null @@ -1,10 +0,0 @@ -package de.steamwar.bausystem.tracer.showcallback; - -import org.bukkit.entity.Player; - -@FunctionalInterface -public interface TracerCallbackTracing_15 { - - boolean run(Player p); - -} diff --git a/BauSystem_15/src/de/steamwar/bausystem/tracer/showcallback/TracerCallbackUpdatePoints_15.java b/BauSystem_15/src/de/steamwar/bausystem/tracer/showcallback/TracerCallbackUpdatePoints_15.java deleted file mode 100644 index 7d810c3..0000000 --- a/BauSystem_15/src/de/steamwar/bausystem/tracer/showcallback/TracerCallbackUpdatePoints_15.java +++ /dev/null @@ -1,10 +0,0 @@ -package de.steamwar.bausystem.tracer.showcallback; - -import org.bukkit.entity.Player; - -@FunctionalInterface -public interface TracerCallbackUpdatePoints_15 { - - float[] run(Player p); - -} diff --git a/BauSystem_15/src/de/steamwar/bausystem/tracer/showcallback/TracerCallback_15.java b/BauSystem_15/src/de/steamwar/bausystem/tracer/showcallback/TracerCallback_15.java deleted file mode 100644 index 9f36e06..0000000 --- a/BauSystem_15/src/de/steamwar/bausystem/tracer/showcallback/TracerCallback_15.java +++ /dev/null @@ -1,10 +0,0 @@ -package de.steamwar.bausystem.tracer.showcallback; - -import org.bukkit.entity.Player; - -@FunctionalInterface -public interface TracerCallback_15 { - - float[] run(Player p); - -} diff --git a/BauSystem_API/src/de/steamwar/bausystem/tracer/debugcallback/DebugCallbackActionBar.java b/BauSystem_API/src/de/steamwar/bausystem/tracer/debugcallback/DebugCallbackActionBar.java new file mode 100644 index 0000000..b6988fb --- /dev/null +++ b/BauSystem_API/src/de/steamwar/bausystem/tracer/debugcallback/DebugCallbackActionBar.java @@ -0,0 +1,8 @@ +package de.steamwar.bausystem.tracer.debugcallback; + +@FunctionalInterface +public interface DebugCallbackActionBar { + + String run(); + +} diff --git a/BauSystem_15/src/de/steamwar/bausystem/tracer/guicallback/RecordingCallback_15.java b/BauSystem_API/src/de/steamwar/bausystem/tracer/guicallback/GuiCallbackRecording.java similarity index 77% rename from BauSystem_15/src/de/steamwar/bausystem/tracer/guicallback/RecordingCallback_15.java rename to BauSystem_API/src/de/steamwar/bausystem/tracer/guicallback/GuiCallbackRecording.java index 91bb725..66b03d8 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/tracer/guicallback/RecordingCallback_15.java +++ b/BauSystem_API/src/de/steamwar/bausystem/tracer/guicallback/GuiCallbackRecording.java @@ -3,7 +3,7 @@ package de.steamwar.bausystem.tracer.guicallback; import org.bukkit.inventory.ItemStack; @FunctionalInterface -public interface RecordingCallback_15 { +public interface GuiCallbackRecording { ItemStack run(); diff --git a/BauSystem_15/src/de/steamwar/bausystem/tracer/guicallback/TNTFrameCallback_15.java b/BauSystem_API/src/de/steamwar/bausystem/tracer/guicallback/GuiCallbackTNTFrame.java similarity index 82% rename from BauSystem_15/src/de/steamwar/bausystem/tracer/guicallback/TNTFrameCallback_15.java rename to BauSystem_API/src/de/steamwar/bausystem/tracer/guicallback/GuiCallbackTNTFrame.java index d06da2d..ee1b77e 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/tracer/guicallback/TNTFrameCallback_15.java +++ b/BauSystem_API/src/de/steamwar/bausystem/tracer/guicallback/GuiCallbackTNTFrame.java @@ -4,7 +4,7 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @FunctionalInterface -public interface TNTFrameCallback_15 { +public interface GuiCallbackTNTFrame { ItemStack[] run(Player p); diff --git a/BauSystem_15/src/de/steamwar/bausystem/tracer/guicallback/TNTTraceCallback_15.java b/BauSystem_API/src/de/steamwar/bausystem/tracer/guicallback/GuiCallbackTNTTrace.java similarity index 82% rename from BauSystem_15/src/de/steamwar/bausystem/tracer/guicallback/TNTTraceCallback_15.java rename to BauSystem_API/src/de/steamwar/bausystem/tracer/guicallback/GuiCallbackTNTTrace.java index 46b5d93..cc57b60 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/tracer/guicallback/TNTTraceCallback_15.java +++ b/BauSystem_API/src/de/steamwar/bausystem/tracer/guicallback/GuiCallbackTNTTrace.java @@ -4,7 +4,7 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @FunctionalInterface -public interface TNTTraceCallback_15 { +public interface GuiCallbackTNTTrace { ItemStack[] run(Player p); diff --git a/BauSystem_15/src/de/steamwar/bausystem/tracer/showcallback/CacheUpdateCallback_15.java b/BauSystem_API/src/de/steamwar/bausystem/tracer/showcallback/TNTCallbackCacheUpdate.java similarity index 76% rename from BauSystem_15/src/de/steamwar/bausystem/tracer/showcallback/CacheUpdateCallback_15.java rename to BauSystem_API/src/de/steamwar/bausystem/tracer/showcallback/TNTCallbackCacheUpdate.java index f05d2cb..d92369f 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/tracer/showcallback/CacheUpdateCallback_15.java +++ b/BauSystem_API/src/de/steamwar/bausystem/tracer/showcallback/TNTCallbackCacheUpdate.java @@ -3,7 +3,7 @@ package de.steamwar.bausystem.tracer.showcallback; import org.bukkit.entity.Player; @FunctionalInterface -public interface CacheUpdateCallback_15 { +public interface TNTCallbackCacheUpdate { boolean run(Player p); diff --git a/BauSystem_15/src/de/steamwar/bausystem/tracer/showcallback/TNTShowCallback_15.java b/BauSystem_API/src/de/steamwar/bausystem/tracer/showcallback/TNTCallbackShow.java similarity index 84% rename from BauSystem_15/src/de/steamwar/bausystem/tracer/showcallback/TNTShowCallback_15.java rename to BauSystem_API/src/de/steamwar/bausystem/tracer/showcallback/TNTCallbackShow.java index 4a874c6..fc91355 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/tracer/showcallback/TNTShowCallback_15.java +++ b/BauSystem_API/src/de/steamwar/bausystem/tracer/showcallback/TNTCallbackShow.java @@ -3,7 +3,7 @@ package de.steamwar.bausystem.tracer.showcallback; import org.bukkit.entity.Player; @FunctionalInterface -public interface TNTShowCallback_15 { +public interface TNTCallbackShow { public static enum ShowMode { BLOCK, diff --git a/BauSystem_API/src/de/steamwar/bausystem/tracer/updatecallback/TracerCallbackPositions.java b/BauSystem_API/src/de/steamwar/bausystem/tracer/updatecallback/TracerCallbackPositions.java new file mode 100644 index 0000000..ce1b4ec --- /dev/null +++ b/BauSystem_API/src/de/steamwar/bausystem/tracer/updatecallback/TracerCallbackPositions.java @@ -0,0 +1,10 @@ +package de.steamwar.bausystem.tracer.updatecallback; + +import org.bukkit.entity.Player; + +@FunctionalInterface +public interface TracerCallbackPositions { + + float[] run(Player p); + +} diff --git a/BauSystem_API/src/de/steamwar/bausystem/tracer/updatecallback/TracerCallbackTracing.java b/BauSystem_API/src/de/steamwar/bausystem/tracer/updatecallback/TracerCallbackTracing.java new file mode 100644 index 0000000..e88d073 --- /dev/null +++ b/BauSystem_API/src/de/steamwar/bausystem/tracer/updatecallback/TracerCallbackTracing.java @@ -0,0 +1,10 @@ +package de.steamwar.bausystem.tracer.updatecallback; + +import org.bukkit.entity.Player; + +@FunctionalInterface +public interface TracerCallbackTracing { + + boolean run(Player p); + +} diff --git a/BauSystem_API/src/de/steamwar/bausystem/tracer/updatecallback/TracerCallbackUpdatePoints.java b/BauSystem_API/src/de/steamwar/bausystem/tracer/updatecallback/TracerCallbackUpdatePoints.java new file mode 100644 index 0000000..efe2a20 --- /dev/null +++ b/BauSystem_API/src/de/steamwar/bausystem/tracer/updatecallback/TracerCallbackUpdatePoints.java @@ -0,0 +1,10 @@ +package de.steamwar.bausystem.tracer.updatecallback; + +import org.bukkit.entity.Player; + +@FunctionalInterface +public interface TracerCallbackUpdatePoints { + + float[] run(Player p); + +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/tracer/TNTTracer15.java b/BauSystem_Main/src/de/steamwar/bausystem/tracer/TNTTracer15.java index 6a9731b..8137898 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/tracer/TNTTracer15.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/tracer/TNTTracer15.java @@ -1,7 +1,7 @@ package de.steamwar.bausystem.tracer; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.tracer.showcallback.TNTShowCallback_15; +import de.steamwar.bausystem.tracer.showcallback.TNTCallbackShow; import de.steamwar.bausystem.tracer.trace.ShowManager; import de.steamwar.bausystem.tracer.trace.ShowStatus; import de.steamwar.bausystem.tracer.trace.TNTFrame; @@ -45,7 +45,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(), p -> { + TNTTracer_15.init(BauSystem.getPlugin(), TNTTracer15::getTracePoints, TNTTracer15::getTraceUpdatePoints, p -> ShowManager.get(p).isDirty(), TNTTracer15::getActionBar, TNTTracer15::showMode, p -> { if (System.currentTimeMillis() - lastExplosion < 4500) { ShowManager.get(p).dirty(); } @@ -202,11 +202,11 @@ public class TNTTracer15 { return traces; } - private static TNTShowCallback_15.ShowMode showMode(Player player) { + private static TNTCallbackShow.ShowMode showMode(Player player) { if (ShowManager.get(player).getShowMode() == ShowStatus.ShowMode.BLOCK) { - return TNTShowCallback_15.ShowMode.BLOCK; + return TNTCallbackShow.ShowMode.BLOCK; } else { - return TNTShowCallback_15.ShowMode.PARTICLE; + return TNTCallbackShow.ShowMode.PARTICLE; } } @@ -270,6 +270,9 @@ public class TNTTracer15 { static void explode(TNTPrimed tntPrimed) { if (tntFrames.isEmpty()) return; + if (System.currentTimeMillis() - lastExplosion > 4500) { + ShowManager.dirty(); + } lastExplosion = System.currentTimeMillis(); tntFrames.getLast().explode(tntPrimed); } @@ -313,9 +316,7 @@ public class TNTTracer15 { tntFrames.addLast(new TNTFrame()); task = Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), TNTTracer15::run, 1, 1); current = System.currentTimeMillis(); - if (status == Status.RECORD_AUTO) { - run(); - } + run(); } if (status == Status.RECORD_AUTO) { current = System.currentTimeMillis();