From bb92dc51db0ca4557a919feb6b5c4f5875985464 Mon Sep 17 00:00:00 2001 From: jojo Date: Sat, 5 Dec 2020 21:33:48 +0100 Subject: [PATCH] Add basic Trace System --- .../bausystem/tracer/TNTTracer_12.java | 30 --- .../bausystem/tracer/TraceTNT_12.java | 53 +++++ .../bausystem/tracer/TNTTracer_15.java | 30 --- .../bausystem/tracer/TraceTNT_15.java | 37 +++ .../bausystem/tracer/ReflectionsUtils.java | 39 +++ .../src/de/steamwar/bausystem/BauSystem.java | 10 +- .../bausystem/commands/CommandTrace.java | 30 ++- .../commands/CommandTraceTabCompleter.java | 5 +- .../bausystem/tracer/ExplodeListener.java | 19 ++ .../bausystem/tracer/RecordManager.java | 87 +++++++ .../data => tracer}/RecordStatus.java | 2 +- .../bausystem/tracer/ShowManager.java | 225 ------------------ .../steamwar/bausystem/tracer/TNTTrace.java | 112 --------- .../steamwar/bausystem/tracer/TNTTracer.java | 125 ---------- .../bausystem/tracer/TNTTracerGUI.java | 99 -------- .../steamwar/bausystem/tracer/TraceCache.java | 170 ------------- .../bausystem/tracer/TraceListener.java | 73 ------ .../bausystem/tracer/TraceManager.java | 107 +++------ .../steamwar/bausystem/tracer/TraceTNT.java | 97 ++++++++ .../tracer/recorder/RecordManager.java | 136 ----------- .../tracer/recorder/TNTRecorder.java | 70 ------ .../bausystem/tracernew/DataHolder.java | 45 ---- .../bausystem/tracernew/TraceHolder.java | 4 - .../bausystem/tracernew/data/TNTTrace.java | 4 - .../tracernew/recorder/ExplodeListener.java | 22 -- .../tracernew/recorder/RecordManager.java | 91 ------- .../tracernew/recorder/TNTRecorder.java | 51 ---- .../bausystem/world/BauScoreboard.java | 14 +- 28 files changed, 393 insertions(+), 1394 deletions(-) delete mode 100644 BauSystem_12/src/de/steamwar/bausystem/tracer/TNTTracer_12.java create mode 100644 BauSystem_12/src/de/steamwar/bausystem/tracer/TraceTNT_12.java delete mode 100644 BauSystem_15/src/de/steamwar/bausystem/tracer/TNTTracer_15.java create mode 100644 BauSystem_15/src/de/steamwar/bausystem/tracer/TraceTNT_15.java create mode 100644 BauSystem_API/src/de/steamwar/bausystem/tracer/ReflectionsUtils.java create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/tracer/ExplodeListener.java create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/tracer/RecordManager.java rename BauSystem_Main/src/de/steamwar/bausystem/{tracernew/data => tracer}/RecordStatus.java (90%) delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/tracer/ShowManager.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/tracer/TNTTrace.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/tracer/TNTTracer.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/tracer/TNTTracerGUI.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/tracer/TraceCache.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/tracer/TraceListener.java create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/tracer/TraceTNT.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/tracer/recorder/RecordManager.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/tracer/recorder/TNTRecorder.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/tracernew/DataHolder.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/tracernew/TraceHolder.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/tracernew/data/TNTTrace.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/tracernew/recorder/ExplodeListener.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/tracernew/recorder/RecordManager.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/tracernew/recorder/TNTRecorder.java diff --git a/BauSystem_12/src/de/steamwar/bausystem/tracer/TNTTracer_12.java b/BauSystem_12/src/de/steamwar/bausystem/tracer/TNTTracer_12.java deleted file mode 100644 index 7f7ad45..0000000 --- a/BauSystem_12/src/de/steamwar/bausystem/tracer/TNTTracer_12.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - This file is a part of the SteamWar software. - - Copyright (C) 2020 SteamWar.de-Serverteam - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -*/ - -package de.steamwar.bausystem.tracer; - -import org.bukkit.Material; - -class TNTTracer_12 { - private TNTTracer_12(){} - - static Material getMaterial(){ - return Material.STAINED_GLASS; - } -} diff --git a/BauSystem_12/src/de/steamwar/bausystem/tracer/TraceTNT_12.java b/BauSystem_12/src/de/steamwar/bausystem/tracer/TraceTNT_12.java new file mode 100644 index 0000000..5079f69 --- /dev/null +++ b/BauSystem_12/src/de/steamwar/bausystem/tracer/TraceTNT_12.java @@ -0,0 +1,53 @@ +package de.steamwar.bausystem.tracer; + +import net.minecraft.server.v1_12_R1.PacketPlayOutEntityDestroy; +import net.minecraft.server.v1_12_R1.PacketPlayOutSpawnEntity; +import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer; +import org.bukkit.entity.Player; + +import java.util.UUID; + +public class TraceTNT_12 { + + // public PacketPlayOutSpawnEntity(Entity var1, int var2, int var3) { + // this.a = var1.getId(); + // this.b = var1.getUniqueID(); + // this.c = var1.locX; + // this.d = var1.locY; + // this.e = var1.locZ; + // this.i = MathHelper.d(var1.pitch * 256.0F / 360.0F); + // this.j = MathHelper.d(var1.yaw * 256.0F / 360.0F); + // this.k = var2; + // this.l = var3; + // double var4 = 3.9D; + // this.f = (int)(MathHelper.a(var1.motX, -3.9D, 3.9D) * 8000.0D); + // this.g = (int)(MathHelper.a(var1.motY, -3.9D, 3.9D) * 8000.0D); + // this.h = (int)(MathHelper.a(var1.motZ, -3.9D, 3.9D) * 8000.0D); + // } + + static void showTNT(int entityID, Player player, float... position) { + PacketPlayOutSpawnEntity spawnEntity = new PacketPlayOutSpawnEntity(); + ReflectionsUtils.setField("a", spawnEntity, entityID); + ReflectionsUtils.setField("b", spawnEntity, UUID.randomUUID()); + ReflectionsUtils.setField("c", spawnEntity, position[0]); + ReflectionsUtils.setField("d", spawnEntity, position[1]); + ReflectionsUtils.setField("e", spawnEntity, position[2]); + ReflectionsUtils.setField("i", spawnEntity, 0); + ReflectionsUtils.setField("j", spawnEntity, 0); + // EntityType + ReflectionsUtils.setField("k", spawnEntity, 0); + ReflectionsUtils.setField("l", spawnEntity, 0); + ReflectionsUtils.setField("f", spawnEntity, 0); + ReflectionsUtils.setField("g", spawnEntity, 0); + ReflectionsUtils.setField("h", spawnEntity, 0); + + ((CraftPlayer) player).getHandle().playerConnection.sendPacket(spawnEntity); + } + + static void hideTNT(int entityID, Player player, float... position) { + PacketPlayOutEntityDestroy deleteEntity = new PacketPlayOutEntityDestroy(entityID); + + ((CraftPlayer) player).getHandle().playerConnection.sendPacket(deleteEntity); + } + +} diff --git a/BauSystem_15/src/de/steamwar/bausystem/tracer/TNTTracer_15.java b/BauSystem_15/src/de/steamwar/bausystem/tracer/TNTTracer_15.java deleted file mode 100644 index f88d841..0000000 --- a/BauSystem_15/src/de/steamwar/bausystem/tracer/TNTTracer_15.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - This file is a part of the SteamWar software. - - Copyright (C) 2020 SteamWar.de-Serverteam - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -*/ - -package de.steamwar.bausystem.tracer; - -import org.bukkit.Material; - -class TNTTracer_15 { - private TNTTracer_15(){} - - static Material getMaterial(boolean updatePoint){ - return updatePoint ? Material.LIME_STAINED_GLASS : Material.RED_STAINED_GLASS; - } -} diff --git a/BauSystem_15/src/de/steamwar/bausystem/tracer/TraceTNT_15.java b/BauSystem_15/src/de/steamwar/bausystem/tracer/TraceTNT_15.java new file mode 100644 index 0000000..148f27d --- /dev/null +++ b/BauSystem_15/src/de/steamwar/bausystem/tracer/TraceTNT_15.java @@ -0,0 +1,37 @@ +package de.steamwar.bausystem.tracer; + +import net.minecraft.server.v1_15_R1.EntityTypes; +import net.minecraft.server.v1_15_R1.PacketPlayOutEntityDestroy; +import net.minecraft.server.v1_15_R1.PacketPlayOutSpawnEntity; +import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer; +import org.bukkit.entity.Player; + +import java.util.UUID; + +public class TraceTNT_15 { + + static void showTNT(int entityID, Player player, float... position) { + PacketPlayOutSpawnEntity spawnEntity = new PacketPlayOutSpawnEntity(); + ReflectionsUtils.setField("a", spawnEntity, entityID); + ReflectionsUtils.setField("b", spawnEntity, UUID.randomUUID()); + ReflectionsUtils.setField("c", spawnEntity, position[0]); + ReflectionsUtils.setField("d", spawnEntity, position[1]); + ReflectionsUtils.setField("e", spawnEntity, position[2]); + ReflectionsUtils.setField("i", spawnEntity, 0); + ReflectionsUtils.setField("j", spawnEntity, 0); + ReflectionsUtils.setField("k", spawnEntity, EntityTypes.FALLING_BLOCK); + ReflectionsUtils.setField("l", spawnEntity, 0); + ReflectionsUtils.setField("f", spawnEntity, 0); + ReflectionsUtils.setField("g", spawnEntity, 0); + ReflectionsUtils.setField("h", spawnEntity, 0); + + ((CraftPlayer) player).getHandle().playerConnection.sendPacket(spawnEntity); + } + + static void hideTNT(int entityID, Player player, float... position) { + PacketPlayOutEntityDestroy deleteEntity = new PacketPlayOutEntityDestroy(entityID); + + ((CraftPlayer) player).getHandle().playerConnection.sendPacket(deleteEntity); + } + +} diff --git a/BauSystem_API/src/de/steamwar/bausystem/tracer/ReflectionsUtils.java b/BauSystem_API/src/de/steamwar/bausystem/tracer/ReflectionsUtils.java new file mode 100644 index 0000000..236e5c7 --- /dev/null +++ b/BauSystem_API/src/de/steamwar/bausystem/tracer/ReflectionsUtils.java @@ -0,0 +1,39 @@ +package de.steamwar.bausystem.tracer; + +import java.lang.reflect.Field; +import java.util.LinkedHashMap; +import java.util.Map; + +public class ReflectionsUtils { + + private static Map fieldMap = new LinkedHashMap() { + @Override + protected boolean removeEldestEntry(Map.Entry eldest) { + return size() > 100; + } + }; + + @SuppressWarnings({"java:S3011"}) + static void setField(String fieldName, Object object, Object fieldValue) { + String cacheName = object.getClass().getTypeName() + ":" + fieldName; + Field field; + if (fieldMap.containsKey(cacheName)) { + field = fieldMap.get(cacheName); + } else { + try { + field = object.getClass().getDeclaredField(fieldName); + } catch (NoSuchFieldException e) { + return; + } + fieldMap.put(cacheName, field); + } + + field.setAccessible(true); + try { + field.set(object, fieldValue); + } catch (IllegalAccessException e) { + + } + } + +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index 267533f..7c4de53 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -20,9 +20,7 @@ package de.steamwar.bausystem; import de.steamwar.bausystem.commands.*; -import de.steamwar.bausystem.tracer.ShowManager; -import de.steamwar.bausystem.tracer.TNTTracer; -import de.steamwar.bausystem.tracer.TraceListener; +import de.steamwar.bausystem.tracer.ExplodeListener; import de.steamwar.bausystem.world.*; import de.steamwar.core.CommandRemover; import de.steamwar.core.Core; @@ -134,10 +132,10 @@ public class BauSystem extends JavaPlugin implements Listener { Bukkit.getPluginManager().registerEvents(this, this); Bukkit.getPluginManager().registerEvents(new RegionListener(), this); Bukkit.getPluginManager().registerEvents(new BauScoreboard(), this); - Bukkit.getPluginManager().registerEvents(new TraceListener(), this); + Bukkit.getPluginManager().registerEvents(new ExplodeListener(), this); Bukkit.getPluginManager().registerEvents(new ClipboardListener(), this); new AFKStopper(); - TNTTracer.init(); + // TNTTracer.init(); autoShutdown = Bukkit.getScheduler().runTaskLater(this, Bukkit::shutdown, 1200); } @@ -182,7 +180,7 @@ public class BauSystem extends JavaPlugin implements Listener { Player p = e.getPlayer(); p.setOp(true); - ShowManager.add(p); + // ShowManager.add(p); if (Core.getVersion() == 15) Bukkit.getWorlds().get(0).setGameRule(GameRule.REDUCED_DEBUG_INFO, false); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTrace.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTrace.java index 430c3ab..3b0cb63 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTrace.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTrace.java @@ -21,9 +21,8 @@ package de.steamwar.bausystem.commands; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.tracer.ShowManager; +import de.steamwar.bausystem.tracer.RecordManager; import de.steamwar.bausystem.tracer.TraceManager; -import de.steamwar.bausystem.tracer.recorder.RecordManager; import de.steamwar.bausystem.world.Welt; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -69,19 +68,27 @@ public class CommandTrace implements CommandExecutor { switch (args[0].toLowerCase()) { case "start": + RecordManager.commandStart(); + break; case "stop": + RecordManager.commandStop(); + break; case "toggleauto": case "auto": - RecordManager.tracer(player, args); + RecordManager.commandAuto(); break; case "show": + TraceManager.commandShow(player); + break; case "hide": + TraceManager.commandHide(player); + break; case "toggleshow": case "interpolate": case "distance": - if (tracer(player, args)) { + /*if (tracer(player, args)) { help(player); - } + }*/ break; case "list": case "gui": @@ -99,7 +106,7 @@ public class CommandTrace implements CommandExecutor { } private boolean delete(Player player, String[] args) { - if (args.length == 2) { + /*if (args.length == 2) { try { TraceManager.delete(Integer.parseInt(args[1])); player.sendMessage(BauSystem.PREFIX + "§cTNT-Positionen mit ID " + args[1] + " gelöscht"); @@ -108,15 +115,16 @@ public class CommandTrace implements CommandExecutor { } catch (NumberFormatException e) { return true; } - } - TraceManager.deleteAll(); + }*/ + TraceManager.commandDelete(); + // TraceManager.deleteAll(); player.sendMessage(BauSystem.PREFIX + "§cAlle TNT-Positionen gelöscht"); - ShowManager.globalDirty(); + // ShowManager.globalDirty(); return false; } - public boolean tracer(Player player, String[] args) { + /*public boolean tracer(Player player, String[] args) { ShowManager.ShowStatus showStatus = ShowManager.showMap.get(player.getUniqueId().toString()); showStatus.dirty = true; switch (args[0].toLowerCase()) { @@ -240,5 +248,5 @@ public class CommandTrace implements CommandExecutor { return true; } return false; - } + }*/ } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTraceTabCompleter.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTraceTabCompleter.java index b97fa39..ef0ace0 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTraceTabCompleter.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTraceTabCompleter.java @@ -19,7 +19,8 @@ package de.steamwar.bausystem.commands; -import de.steamwar.bausystem.tracer.recorder.RecordManager; +import de.steamwar.bausystem.tracer.RecordManager; +import de.steamwar.bausystem.tracer.RecordStatus; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.command.TabCompleter; @@ -39,7 +40,7 @@ public class CommandTraceTabCompleter implements TabCompleter { private List tracerTabComplete(Player player, String[] args) { List tabComplete = new ArrayList<>(); - if (RecordManager.getStatus() == RecordManager.Status.IDLE || RecordManager.getStatus() == RecordManager.Status.IDLE_AUTO) { + if (RecordManager.getRecordStatus() == RecordStatus.IDLE || RecordManager.getRecordStatus() == RecordStatus.IDLE_AUTO) { tabComplete.add("start"); } else { tabComplete.add("stop"); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/tracer/ExplodeListener.java b/BauSystem_Main/src/de/steamwar/bausystem/tracer/ExplodeListener.java new file mode 100644 index 0000000..de2654d --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/tracer/ExplodeListener.java @@ -0,0 +1,19 @@ +package de.steamwar.bausystem.tracer; + +import org.bukkit.entity.TNTPrimed; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityExplodeEvent; + +public class ExplodeListener implements Listener { + + @EventHandler(priority = EventPriority.MONITOR) + public void onEntityExplode(EntityExplodeEvent event) { + if (!(event.getEntity() instanceof TNTPrimed)) return; + + RecordManager.tntExplode(); + TraceManager.tntExplode((TNTPrimed) event.getEntity()); + } + +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/tracer/RecordManager.java b/BauSystem_Main/src/de/steamwar/bausystem/tracer/RecordManager.java new file mode 100644 index 0000000..24ad350 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/tracer/RecordManager.java @@ -0,0 +1,87 @@ +package de.steamwar.bausystem.tracer; + +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.commands.CommandTPSLimiter; +import org.bukkit.Bukkit; +import org.bukkit.World; +import org.bukkit.entity.TNTPrimed; +import org.bukkit.scheduler.BukkitTask; + +public class RecordManager { + + private static final World world = Bukkit.getWorlds().get(0); + + private static RecordStatus recordStatus = RecordStatus.IDLE; + + private static BukkitTask recorder = null; + private static long startTime = 0; + private static long lastExplosion = 0; + + public static void commandStart() { + recordStatus = RecordStatus.RECORD; + recordStart(); + } + + public static void commandStop() { + recordStatus = RecordStatus.IDLE; + recordStop(); + } + + public static void commandAuto() { + if (recordStatus != RecordStatus.IDLE) { + return; + } + if (recordStatus == RecordStatus.IDLE_AUTO) { + recordStatus = RecordStatus.IDLE; + } else { + recordStatus = RecordStatus.IDLE_AUTO; + } + } + + public static void tntExplode() { + if (recordStatus == RecordStatus.RECORD_AUTO) { + lastExplosion = System.currentTimeMillis(); + return; + } + if (recordStatus != RecordStatus.IDLE_AUTO) { + return; + } + lastExplosion = System.currentTimeMillis(); + recordStatus = RecordStatus.RECORD_AUTO; + recordStart(); + } + + private static void recordStart() { + if (recorder != null) return; + startTime = System.currentTimeMillis(); + recorder = Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), () -> { + world.getEntitiesByClass(TNTPrimed.class).forEach(TraceManager::tntAdd); + recordAutoStop(); + }, 1, 1); + } + + private static void recordStop() { + if (recorder == null) return; + recorder.cancel(); + recorder = null; + startTime = 0; + TraceManager.recordStop(); + } + + private static void recordAutoStop() { + if (recordStatus != RecordStatus.RECORD_AUTO) return; + if (System.currentTimeMillis() - lastExplosion > (20.0 / CommandTPSLimiter.getCurrentTPSLimit()) * 50 * 80) { + recordStatus = RecordStatus.IDLE_AUTO; + recordStop(); + } + } + + public static RecordStatus getRecordStatus() { + return recordStatus; + } + + public static long getStartTime() { + return startTime; + } + +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/tracernew/data/RecordStatus.java b/BauSystem_Main/src/de/steamwar/bausystem/tracer/RecordStatus.java similarity index 90% rename from BauSystem_Main/src/de/steamwar/bausystem/tracernew/data/RecordStatus.java rename to BauSystem_Main/src/de/steamwar/bausystem/tracer/RecordStatus.java index 7da8547..eee5ad5 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/tracernew/data/RecordStatus.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/tracer/RecordStatus.java @@ -1,4 +1,4 @@ -package de.steamwar.bausystem.tracernew.data; +package de.steamwar.bausystem.tracer; public enum RecordStatus { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/tracer/ShowManager.java b/BauSystem_Main/src/de/steamwar/bausystem/tracer/ShowManager.java deleted file mode 100644 index 9514990..0000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/tracer/ShowManager.java +++ /dev/null @@ -1,225 +0,0 @@ -/* - This file is a part of the SteamWar software. - - Copyright (C) 2020 SteamWar.de-Serverteam - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -*/ - -package de.steamwar.bausystem.tracer; - -import org.bukkit.Location; -import org.bukkit.entity.Player; - -import java.util.*; - -public class ShowManager { - - public enum DisplayMode { - NONE, - Y_AXIS, - ALL - } - - public enum DisplayType { - Particle, - Block - } - - public enum ShowSelection { - NONE, - SELECTIVE, - ALL - } - - - public interface Mode { - void run(int tntID); - } - - public interface ModeChoose { - boolean run(int tntID); - } - - - public static class ShowStatus { - - private ShowSelection showSelection = ShowSelection.NONE; - public DisplayType displayType = DisplayType.Particle; - public DisplayMode displayMode = DisplayMode.ALL; - - public boolean dirty = true; - private int count = 0; - - private Set selected = new HashSet<>(); - - private void clear() { - if (showSelection == ShowSelection.NONE) return; - selected.clear(); - } - - public void show() { - showSelection = ShowSelection.ALL; - } - - public void hide() { - clear(); - showSelection = ShowSelection.NONE; - } - - public void addSelection(int id) { - if (showSelection == ShowSelection.ALL) return; - if (showSelection == ShowSelection.NONE) showSelection = ShowSelection.SELECTIVE; - TraceManager.getFrame(id).forEach(i -> selected.add(i)); - if (selected.size() == TraceManager.getAllTraces().size()) { - showSelection = ShowSelection.ALL; - clear(); - } - } - - public void removeSelection(int id) { - if (showSelection == ShowSelection.NONE) return; - if (showSelection == ShowSelection.ALL) selected = TraceManager.getAllTraces(); - TraceManager.getFrame(id).forEach(i -> selected.remove(i)); - showSelection = ShowSelection.SELECTIVE; - if (selected.isEmpty()) showSelection = ShowSelection.NONE; - } - - public boolean toggleSelection(int id) { - if (showSelection == ShowSelection.NONE) { - addSelection(id); - return true; - } - if (showSelection == ShowSelection.ALL) { - removeSelection(id); - return false; - } - if (selected.contains(id)) { - removeSelection(id); - return false; - } else { - addSelection(id); - return true; - } - } - - public DisplayType getDisplayType() { - return displayType; - } - - public DisplayMode getDisplayMode() { - return displayMode; - } - - public LinkedList getTraces() { - if (showSelection == ShowSelection.NONE) return new LinkedList<>(); - Set tntIDs; - if (showSelection == ShowSelection.ALL) { - tntIDs = TraceManager.getAllTraces(); - } else { - tntIDs = selected; - } - - LinkedList traces = new LinkedList<>(); - for (int traceId : tntIDs) { - TNTTrace trace = TraceManager.getTrace(traceId); - if (trace == null) continue; - traces.add(trace); - } - return traces; - } - - public boolean isDirty() { - if (displayType == DisplayType.Block) { - count++; - } - if (count >= 10) { - count = 0; - return true; - } - if (dirty) { - dirty = false; - return true; - } - return false; - } - - public double slopeHeight = 7.0; - - private int size = 0; - - private TraceCache.Loc loc = null; - - public double getShowRadius() { - double maxRadius = 80.0; - if (showSelection == ShowSelection.NONE) return maxRadius; - if (showSelection == ShowSelection.ALL) size = TraceManager.getAllTraces().size(); - if (showSelection == ShowSelection.SELECTIVE) size = selected.size(); - if (size == 0) return maxRadius; - double minRadius = 20.0; - if (size >= 950) return minRadius; - - double slope = -(size / slopeHeight) + 85; - return Math.min(Math.max(slope, minRadius), maxRadius); - } - - public void setSlope(double slope) { - double minSlope = 3.0; - double maxSlope = 11.0; - slopeHeight = Math.min(Math.max(slope, minSlope), maxSlope); - } - - public void move(Player player) { - if (loc != null && !loc.remove(player, 4)) { - return; - } - Location location = player.getLocation(); - loc = new TraceCache.Loc((float) location.getX(), (float) location.getY(), (float) location.getZ()); - dirty = true; - } - - } - - public static Map showMap = new HashMap<>(); - - public static void add(Player p) { - showMap.put(p.getUniqueId().toString(), new ShowStatus()); - } - - public static ShowStatus get(Player p) { - if (!showMap.containsKey(p.getUniqueId().toString())) add(p); - return showMap.get(p.getUniqueId().toString()); - } - - public static void traceAdd() { - for (Map.Entry entry : showMap.entrySet()) { - if (entry.getValue().showSelection == ShowSelection.ALL) { - entry.getValue().dirty = true; - } - } - } - - public static void traceRemove(int id) { - for (Map.Entry entry : showMap.entrySet()) { - entry.getValue().removeSelection(id); - } - } - - public static void globalDirty() { - for (Map.Entry entry : showMap.entrySet()) { - entry.getValue().dirty = true; - } - } - -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/tracer/TNTTrace.java b/BauSystem_Main/src/de/steamwar/bausystem/tracer/TNTTrace.java deleted file mode 100644 index 6c7b770..0000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/tracer/TNTTrace.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - This file is a part of the SteamWar software. - - Copyright (C) 2020 SteamWar.de-Serverteam - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -*/ - -package de.steamwar.bausystem.tracer; - -import org.bukkit.Location; - -import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; - -public class TNTTrace { - - private final int frameID; - - private int index = 0; - private float[] positions = new float[240]; - - private Set posSet = new HashSet<>(); - private Set posYSet = new HashSet<>(); - private Set posXYZSet = new HashSet<>(); - - TNTTrace(int frameID) { - this.frameID = frameID; - } - - void addLocation(Location location) { - if (index >= positions.length) { - positions = Arrays.copyOf(positions, positions.length + 3); - } - positions[index] = (float)location.getX(); - positions[index + 1] = (float)location.getY(); - positions[index + 2] = (float)location.getZ(); - index += 3; - } - - private int size() { - return index / 3; - } - - public int length() { - return size(); - } - - private int realLength() { - return positions.length; - } - - int getFrameID() { - return frameID; - } - - void cleanUp() { - positions = Arrays.copyOf(positions, index); - ShowManager.traceAdd(); - - for (int i = 0; i < length(); i++) { - posSet.add(new TraceCache.Loc(positions[i * 3], positions[i * 3 + 1], positions[i * 3 + 2])); - } - - for (int i = 0; i < realLength() - 3; i += 3) { - float x1 = positions[i]; - float y1 = positions[i + 1]; - float z1 = positions[i + 2]; - - float x2 = positions[i + 3]; - float y2 = positions[i + 4]; - float z2 = positions[i + 5]; - - if (isDifferent(y2, y1)) { - TraceCache.Loc loc = new TraceCache.Loc(x1, y2, z1); - posYSet.add(loc); - posXYZSet.add(loc); - } - if (Math.abs(x2 - x1) > Math.abs(z2 - z1)) { - if (isDifferent(x2, x1)) posXYZSet.add(new TraceCache.Loc(x2, y2, z1)); - } else { - if (isDifferent(z2, z1)) posXYZSet.add(new TraceCache.Loc(x1, y2, z2)); - } - } - } - - Set locs() { - return posSet; - } - - Set locsUpdate(ShowManager.DisplayMode displayMode) { - if (displayMode == ShowManager.DisplayMode.NONE) return new HashSet<>(); - if (displayMode == ShowManager.DisplayMode.Y_AXIS) return posYSet; - return posXYZSet; - } - - private static boolean isDifferent(float d1, float d2) { - return (d2 - d1) * (d2 - d1) >= 0.01; - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/tracer/TNTTracer.java b/BauSystem_Main/src/de/steamwar/bausystem/tracer/TNTTracer.java deleted file mode 100644 index a7ea71b..0000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/tracer/TNTTracer.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - This file is a part of the SteamWar software. - - Copyright (C) 2020 SteamWar.de-Serverteam - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -*/ - -package de.steamwar.bausystem.tracer; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.core.Core; -import net.md_5.bungee.api.ChatMessageType; -import net.md_5.bungee.api.chat.TextComponent; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Particle; -import org.bukkit.entity.Player; - -import java.util.Set; - -public class TNTTracer { - private TNTTracer(){} - - static final boolean DEBUG = false; - - private static final Object synchronizer = new Object(); - private static final TraceCache traceCache = new TraceCache(); - - public static void init(){ - Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), TNTTracer::run, 0, 20); - } - - private static void run() { - for (Player p : Bukkit.getOnlinePlayers()) { - if (DEBUG) { - String actionBar = "§e" + TraceManager.getAllTraces().size() + " §cTraces §e" + ShowManager.get(p).getShowRadius() + " §cRadius"; - p.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(actionBar)); - } - - boolean dirty = ShowManager.get(p).isDirty(); - if (ShowManager.get(p).getDisplayType() == ShowManager.DisplayType.Block && !dirty) { - continue; - } - Set toHide = traceCache.update(p, dirty); - Set toShow = traceCache.get(p); - - hideBlockTraces(toHide, p); - showTraces(toShow, ShowManager.get(p).getDisplayType(), p); - } - } - - private static void hideBlockTraces(Set locs, Player player) { - if (locs.isEmpty()) return; - - for (TraceCache.Loc l : locs) { - hideBlock(player, l.x, l.y - 0.49F, l.z); - } - } - - private static void showTraces(Set locs, ShowManager.DisplayType displayMode, Player player) { - if (locs.isEmpty()) return; - - for (TraceCache.Loc l : locs) { - if (displayMode == ShowManager.DisplayType.Block) { - showBlock(player, l.x, l.y - 0.49F, l.z, getMaterial(l), (l.updatePoint ? (byte) 5 : (byte) 14)); - } else { - showCorner(player, l.x - 0.49F, l.y, l.z - 0.49F, (l.updatePoint ? Particle.FLAME : Particle.VILLAGER_HAPPY)); - } - } - } - - private static Material getMaterial(TraceCache.Loc l){ - switch(Core.getVersion()){ - case 15: - return TNTTracer_15.getMaterial(l.updatePoint); - default: - return TNTTracer_12.getMaterial(); - } - } - - private static void showCorner(Player player, float x, float y, float z, Particle particle) { - player.spawnParticle(particle, makeLocation(x + 0.00F, y + 0.00F, z + 0.00F), 1, 0F, 0F, 0F, 0.001); - player.spawnParticle(particle, makeLocation(x + 0.98F, y + 0.00F, z + 0.00F), 1, 0F, 0F, 0F, 0.001); - player.spawnParticle(particle, makeLocation(x + 0.00F, y + 0.00F, z + 0.98F), 1, 0F, 0F, 0F, 0.001); - player.spawnParticle(particle, makeLocation(x + 0.98F, y + 0.00F, z + 0.98F), 1, 0F, 0F, 0F, 0.001); - - player.spawnParticle(particle, makeLocation(x + 0.00F, y + 0.98F, z + 0.00F), 1, 0F, 0F, 0F, 0.001); - player.spawnParticle(particle, makeLocation(x + 0.98F, y + 0.98F, z + 0.00F), 1, 0F, 0F, 0F, 0.001); - player.spawnParticle(particle, makeLocation(x + 0.00F, y + 0.98F, z + 0.98F), 1, 0F, 0F, 0F, 0.001); - player.spawnParticle(particle, makeLocation(x + 0.98F, y + 0.98F, z + 0.98F), 1, 0F, 0F, 0F, 0.001); - } - - private static void showBlock(Player p, float x, float y, float z, Material block, byte b) { - if (makeLocation(x, y, z).getBlock().getType() == Material.AIR) { - p.sendBlockChange(makeLocation(x, y, z), block, b); - } - } - - private static void hideBlock(Player p, float x, float y, float z) { - if (makeLocation(x, y, z).getBlock().getType() == Material.AIR) { - p.sendBlockChange(makeLocation(x, y, z), Material.AIR, (byte) 0); - } - } - - private static final Location location = new Location(Bukkit.getWorlds().get(0), 0, 0, 0); - private static Location makeLocation(float x, float y, float z) { - location.setX(x); - location.setY(y); - location.setZ(z); - return location; - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/tracer/TNTTracerGUI.java b/BauSystem_Main/src/de/steamwar/bausystem/tracer/TNTTracerGUI.java deleted file mode 100644 index e011e48..0000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/tracer/TNTTracerGUI.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - This file is a part of the SteamWar software. - - Copyright (C) 2020 SteamWar.de-Serverteam - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -*/ - -package de.steamwar.bausystem.tracer; - -public class TNTTracerGUI { - - /*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); - ItemStack i1 = createItem(Material.LIGHT_GRAY_STAINED_GLASS_PANE, false, ""); - for (int i = 0; i < 9; i++) { - inventory.setItem(i, i1); - } - ItemStack i2 = createItem(Material.RED_STAINED_GLASS, false, ""); - for (int i = 9; i < 54; i++) { - inventory.setItem(i, i2); - } - return inventory; - } - - public static ItemStack createItem(Material material, boolean selected, String name, String... lore) { - ItemStack item = new ItemStack(material, 1); - ItemMeta im = item.getItemMeta(); - - if (im == null) return item; - if (name == null) name = "§f"; - if (name.isEmpty()) name = "§f"; - im.setDisplayName(name); - if (selected) { - im.addEnchant(Enchantment.PROTECTION_ENVIRONMENTAL, 1, true); - } - im.addItemFlags(ItemFlag.HIDE_ENCHANTS); - - if (lore != null) { - List lorelist = Arrays.asList(lore); - im.setLore(lorelist); - } - - item.setItemMeta(im); - return item; - } - - private static void frameControls(Inventory inventory, int page, int allPages) { - 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, 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 = guiCallbackTNTFrame.run(p); - - Inventory inventory = getEmpty("§7§lTRACE §8- §e§lAufnahmen"); - if (items.length == 0) { - frameControls(inventory, page + 1, 1); - } else { - frameControls(inventory, page + 1, items.length / 45 + (items.length % 45 == 0 ? 0 : 1)); - } - return inventory; - } - - 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 { - FRAME, - TRACE, - BLOCK - } - - public static void show(Player p, int page, Menu menu) { - - }*/ - -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/tracer/TraceCache.java b/BauSystem_Main/src/de/steamwar/bausystem/tracer/TraceCache.java deleted file mode 100644 index 1f094cb..0000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/tracer/TraceCache.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - This file is a part of the SteamWar software. - - Copyright (C) 2020 SteamWar.de-Serverteam - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -*/ - -package de.steamwar.bausystem.tracer; - -import org.bukkit.entity.Player; - -import java.util.*; - -public class TraceCache { - - private static final Set empty = new HashSet<>(); - private Map> playerMap = new HashMap<>(); - private Map playerDisplayMap = new HashMap<>(); - - public Set get(Player player) { - return playerMap.getOrDefault(player.getUniqueId().toString(), empty); - } - - Set update(Player player, boolean dirty) { - if (!dirty) return empty; - String key = player.getUniqueId().toString(); - Set locOld; - ShowManager.DisplayType displayMode; - if (!playerMap.containsKey(key)) { - locOld = new HashSet<>(); - displayMode = getDisplayType(player); - } else { - locOld = playerMap.get(key); - displayMode = playerDisplayMap.get(key); - } - - Set locSet = new HashSet<>(); - updatePoints(player).forEach(loc -> { - loc.updatePoint = true; - locSet.add(loc); - }); - updateLocations(player).forEach(loc -> { - loc.updatePoint = false; - locSet.add(loc); - }); - - playerMap.put(key, locSet); - ShowManager.DisplayType currentMode = getDisplayType(player); - playerDisplayMap.put(key, currentMode); - - if (currentMode == ShowManager.DisplayType.Particle && displayMode == ShowManager.DisplayType.Block) return locOld; - if (currentMode == ShowManager.DisplayType.Block) return diff(locOld, locSet); - return empty; - } - - public static class Loc { - final float x; - final float y; - final float z; - - private final float dx; - private final float dy; - private final float dz; - - boolean updatePoint = false; - - public Loc(float x, float y, float z) { - this.x = x; - this.y = y; - this.z = z; - this.dx = round(x); - this.dy = round(y); - this.dz = round(z); - } - - private static float round(float toRound) { - final int roundNumber = 10; - float r = (toRound * roundNumber); - float t = r - (int) r; - if (t >= 0.5) { - return (((float)(int)r) + 1) / roundNumber; - } else { - return (((float)(int)r) + 0) / roundNumber; - } - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof Loc)) return false; - Loc loc = (Loc) o; - return Float.compare(loc.dx, dx) == 0 && - Float.compare(loc.dy, dy) == 0 && - Float.compare(loc.dz, dz) == 0; - } - - @Override - public int hashCode() { - return Objects.hash(dx, dy, dz); - } - - @Override - public String toString() { - return "Loc{" + - "x=" + x + - ", y=" + y + - ", z=" + z + - '}'; - } - - public boolean remove(Player player, double radius) { - double x = player.getLocation().getX(); - double y = player.getLocation().getY(); - double z = player.getLocation().getZ(); - - double dx = (this.x - x) * (this.x - x); - double dy = (this.y - y) * (this.y - y); - double dz = (this.z - z) * (this.z - z); - - return (dx + dy + dz) > radius * radius; - } - } - - private Set diff(Set locOld, Set locNew) { - if (locOld.isEmpty()) return empty; - if (locNew.isEmpty()) return locOld; - for (Loc l : locNew) { - locOld.remove(l); - } - return locOld; - } - - private Set updateLocations(Player player) { - Iterator traces = ShowManager.get(player).getTraces().descendingIterator(); - Set locSet = new HashSet<>(); - while (traces.hasNext()) { - locSet.addAll(traces.next().locs()); - } - double radius = ShowManager.get(player).getShowRadius(); - locSet.removeIf(loc -> loc.remove(player, radius)); - return locSet; - } - - private Set updatePoints(Player player) { - Iterator traces = ShowManager.get(player).getTraces().descendingIterator(); - Set locSet = new HashSet<>(); - while (traces.hasNext()) { - locSet.addAll(traces.next().locsUpdate(ShowManager.get(player).getDisplayMode())); - } - double radius = ShowManager.get(player).getShowRadius(); - locSet.removeIf(loc -> loc.remove(player, radius)); - return locSet; - } - - private ShowManager.DisplayType getDisplayType(Player player) { - return ShowManager.get(player).getDisplayType(); - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/tracer/TraceListener.java b/BauSystem_Main/src/de/steamwar/bausystem/tracer/TraceListener.java deleted file mode 100644 index be87341..0000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/tracer/TraceListener.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - This file is a part of the SteamWar software. - - Copyright (C) 2020 SteamWar.de-Serverteam - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -*/ - -package de.steamwar.bausystem.tracer; - -import de.steamwar.bausystem.tracer.recorder.RecordManager; -import org.bukkit.entity.Player; -import org.bukkit.entity.TNTPrimed; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.entity.EntityExplodeEvent; -import org.bukkit.event.player.PlayerMoveEvent; - -import java.util.HashMap; -import java.util.Map; -import java.util.stream.Stream; - -public class TraceListener implements Listener { - - private static final Map tntMap = new HashMap<>(); - - public static void onTick(Stream tntPrimedStream) { - tntPrimedStream.forEach(tnt -> { - TNTTrace trace; - if (!tntMap.containsKey(tnt)) { - trace = TraceManager.createTrace(); - if (trace == null) return; - tntMap.put(tnt, trace); - } else { - trace = tntMap.get(tnt); - } - trace.addLocation(tnt.getLocation()); - }); - } - - @EventHandler - public void onEntityExplode(EntityExplodeEvent event) { - if (!(event.getEntity() instanceof TNTPrimed)) - return; - - if (RecordManager.getStatus() == RecordManager.Status.IDLE_AUTO) - RecordManager.startAuto(); - if (RecordManager.getStatus() == RecordManager.Status.RECORD_AUTO) - RecordManager.updateAuto(); - - TNTTrace trace = tntMap.remove((TNTPrimed) event.getEntity()); - if (trace != null) - trace.cleanUp(); - } - - - @EventHandler - public void playerMove(PlayerMoveEvent event) { - Player p = event.getPlayer(); - ShowManager.get(p).move(p); - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/tracer/TraceManager.java b/BauSystem_Main/src/de/steamwar/bausystem/tracer/TraceManager.java index 1491610..9826b76 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/tracer/TraceManager.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/tracer/TraceManager.java @@ -1,101 +1,48 @@ -/* - This file is a part of the SteamWar software. - - Copyright (C) 2020 SteamWar.de-Serverteam - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -*/ - package de.steamwar.bausystem.tracer; -import java.util.*; +import org.bukkit.entity.Player; +import org.bukkit.entity.TNTPrimed; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; public class TraceManager { - private TraceManager(){} - private static Map> frameMap = new HashMap<>(); - private static Map traceMap = new HashMap<>(); + private static Map traceTNTMap = new HashMap<>(); + private static Set traceTNTSet = new HashSet<>(); - private static int currentFrame; - - private static int currentID = 0; - private static synchronized int generateID() { - return currentID++; + public static void recordStop() { + traceTNTMap.clear(); } - public static void startFrame() { - currentFrame = generateID(); - frameMap.put(currentFrame, new ArrayList<>()); + public static void tntExplode(TNTPrimed tntPrimed) { + if (!traceTNTMap.containsKey(tntPrimed)) return; + traceTNTMap.remove(tntPrimed).explosion(tntPrimed); } - public static TNTTrace createTrace() { - if (!frameMap.containsKey(currentFrame)) return null; - TNTTrace trace = new TNTTrace(currentFrame); - int id = generateID(); - traceMap.put(id, trace); - frameMap.get(currentFrame).add(id); - return trace; + public static void tntAdd(TNTPrimed tntPrimed) { + TraceTNT traceTNT = new TraceTNT(tntPrimed); + traceTNTMap.put(tntPrimed, traceTNT); + traceTNTSet.add(traceTNT); } - public static TNTTrace getTrace(int id) { - return traceMap.get(id); + public static void commandDelete() { + traceTNTMap.clear(); + traceTNTSet.clear(); } - public static Set getAllTraces() { - return traceMap.keySet(); + public static int getRecordSize() { + return traceTNTMap.size(); } - public static List getFrame(int frameID) { - return new ArrayList<>(frameMap.getOrDefault(frameID, new ArrayList<>())); + public static void commandShow(Player player) { + traceTNTSet.forEach(traceTNT -> traceTNT.showTrace(player)); } - public static int currentFrameSize() { - if (!frameMap.containsKey(currentFrame)) return 0; - return frameMap.get(currentFrame).size(); + public static void commandHide(Player player) { + traceTNTSet.forEach(traceTNT -> traceTNT.hideTrace(player)); } - public static void stopFrame() { - testRemoveFrame(currentFrame); - } - - private static void testRemoveFrame(int frame){ - if (!frameMap.containsKey(frame) || !frameMap.get(frame).isEmpty()) - return; - frameMap.remove(frame); - } - - public static void deleteAll() { - for (Integer integer : new HashSet<>(traceMap.keySet())) { - delete(integer); - } - } - - public static void delete(int id) { - TNTTrace trace = traceMap.remove(id); - if(trace == null){ - List frame = frameMap.get(id); - if(frame == null) - return; - - for(int t : new HashSet<>(frame)){ - delete(t); - } - return; - } - int frameID = trace.getFrameID(); - ShowManager.traceRemove(id); - if (frameMap.containsKey(frameID)) frameMap.get(frameID).remove((Integer) id); - testRemoveFrame(frameID); - } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/tracer/TraceTNT.java b/BauSystem_Main/src/de/steamwar/bausystem/tracer/TraceTNT.java new file mode 100644 index 0000000..78f4de9 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/tracer/TraceTNT.java @@ -0,0 +1,97 @@ +package de.steamwar.bausystem.tracer; + +import de.steamwar.core.Core; +import org.bukkit.entity.Player; +import org.bukkit.entity.TNTPrimed; + +import java.util.function.Consumer; + +public class TraceTNT { + + private static int traceID = 0; + + private int id = traceID++; + private float[] source = new float[3]; + private float[] explosion = new float[3]; + private int index = 0; + private float[] position = new float[240]; + private float[] velocity = new float[240]; + + public TraceTNT(TNTPrimed tntPrimed) { + source[0] = (float) tntPrimed.getLocation().getX(); + source[1] = (float) tntPrimed.getLocation().getY(); + source[2] = (float) tntPrimed.getLocation().getZ(); + } + + public void explosion(TNTPrimed tntPrimed) { + explosion[0] = (float) tntPrimed.getLocation().getX(); + explosion[1] = (float) tntPrimed.getLocation().getY(); + explosion[2] = (float) tntPrimed.getLocation().getZ(); + } + + public void add(TNTPrimed tntPrimed) { + if (index > position.length) return; + position[index + 0] = (float) tntPrimed.getLocation().getX(); + position[index + 1] = (float) tntPrimed.getLocation().getY(); + position[index + 2] = (float) tntPrimed.getLocation().getZ(); + velocity[index + 0] = (float) tntPrimed.getVelocity().getX(); + velocity[index + 1] = (float) tntPrimed.getVelocity().getY(); + velocity[index + 2] = (float) tntPrimed.getVelocity().getZ(); + index += 3; + } + + public long size() { + long size = 0; + + // id: + size += 32; + + // index: + size += 32; + + // source: + size += source.length * 32; + + // explosion: + size += explosion.length * 32; + + // position: + size += position.length * 32; + + // velocity: + size += velocity.length * 32; + + return size; + } + + public void showTrace(Player player) { + int entityID = Integer.MAX_VALUE - id * 200; + + tnt(entityID, player, source, TraceTNT_15::showTNT, TraceTNT_12::showTNT); + } + + public void hideTrace(Player player) { + int entityID = Integer.MAX_VALUE - id * 200; + + tnt(entityID, player, source, TraceTNT_15::hideTNT, TraceTNT_12::hideTNT); + } + + private void tnt(int entityID, Player player, float[] position, VersionConsumer version15, VersionConsumer versionDefault) { + if (position.length != 3) return; + switch (Core.getVersion()) { + case 15: + version15.accept(entityID, player, position); + break; + default: + versionDefault.accept(entityID, player, position); + break; + } + } + + private interface VersionConsumer { + + void accept(K k, V v, S s); + + } + +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/tracer/recorder/RecordManager.java b/BauSystem_Main/src/de/steamwar/bausystem/tracer/recorder/RecordManager.java deleted file mode 100644 index 0e7d55b..0000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/tracer/recorder/RecordManager.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - This file is a part of the SteamWar software. - - Copyright (C) 2020 SteamWar.de-Serverteam - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -*/ - -package de.steamwar.bausystem.tracer.recorder; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.tracer.TraceManager; -import net.md_5.bungee.api.ChatMessageType; -import net.md_5.bungee.api.chat.TextComponent; -import org.bukkit.Bukkit; -import org.bukkit.World; -import org.bukkit.entity.Player; - -import static de.steamwar.bausystem.tracer.recorder.TNTRecorder.*; - -public class RecordManager { - - static Status status = Status.IDLE; - - static final World world = Bukkit.getWorlds().get(0); - - public static void tracer(Player player, String[] args) { - switch (args[0].toLowerCase()) { - case "start": - start(); - player.sendMessage(BauSystem.PREFIX + "§aAufnahme gestartet"); - break; - case "stop": - stop(); - player.sendMessage(BauSystem.PREFIX + "§cTNT-Tracer gestoppt"); - break; - case "auto": - case "toggleauto": - toggleAuto(); - if (status == Status.IDLE || status == Status.RECORD) { - player.sendMessage(BauSystem.PREFIX + "§cAutomatischer TNT-Tracer deaktiviert"); - } else { - player.sendMessage(BauSystem.PREFIX + "§aAutomatischer TNT-Tracer aktiviert"); - } - break; - } - } - - private static void toggleAuto() { - switch (status) { - case IDLE: - status = Status.IDLE_AUTO; - break; - case RECORD: - status = Status.RECORD_AUTO; - break; - case IDLE_AUTO: - status = Status.IDLE; - break; - case RECORD_AUTO: - status = Status.RECORD; - break; - default: - break; - } - } - - public static Status getStatus() { - return status; - } - - private static void start() { - status = Status.RECORD; - TraceManager.startFrame(); - startRecording(); - } - - public static void startAuto() { - status = Status.RECORD_AUTO; - Bukkit.getOnlinePlayers().forEach(player -> player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText("§7Automatischer TNT-Tracer §8- §aAufnahme gestartet"))); - TraceManager.startFrame(); - startRecording(); - } - - public static void updateAuto() { - update(); - } - - private static void stop() { - status = Status.IDLE; - stopRecording(); - TraceManager.stopFrame(); - } - - static void stopAuto() { - status = Status.IDLE_AUTO; - Bukkit.getOnlinePlayers().forEach(player -> player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText("§7Automatischer TNT-Tracer §8- §aAufnahme gestoppt"))); - stopRecording(); - TraceManager.stopFrame(); - } - - public enum Status { - RECORD("§aan", true), - RECORD_AUTO("§aan", true), - IDLE("§caus", false), - IDLE_AUTO("§eauto", false); - - String value; - boolean tracing; - - Status(String value, boolean tracing) { - this.value = value; - this.tracing = tracing; - } - - public String getValue() { - return value; - } - - public boolean isTracing() { - return tracing; - } - } - -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/tracer/recorder/TNTRecorder.java b/BauSystem_Main/src/de/steamwar/bausystem/tracer/recorder/TNTRecorder.java deleted file mode 100644 index e51b936..0000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/tracer/recorder/TNTRecorder.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - This file is a part of the SteamWar software. - - Copyright (C) 2020 SteamWar.de-Serverteam - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -*/ - -package de.steamwar.bausystem.tracer.recorder; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.tracer.TraceListener; -import org.bukkit.Bukkit; -import org.bukkit.entity.TNTPrimed; -import org.bukkit.scheduler.BukkitTask; - -import java.util.stream.Stream; - -import static de.steamwar.bausystem.tracer.recorder.RecordManager.stopAuto; - -public class TNTRecorder { - - private static BukkitTask task = null; - public static long recordStart = System.currentTimeMillis(); - public static long lastExplosion = System.currentTimeMillis(); - - static void update() { - if (task == null) return; - if (RecordManager.status != RecordManager.Status.RECORD_AUTO) return; - lastExplosion = System.currentTimeMillis(); - } - - static void startRecording() { - if (task != null) return; - recordStart = System.currentTimeMillis(); - lastExplosion = System.currentTimeMillis(); - task = Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), TNTRecorder::run, 1, 1); - run(); - } - - static void stopRecording() { - if (task == null) return; - task.cancel(); - task = null; - } - - private static void run() { - Stream tntPrimedStream = RecordManager.world.getEntities() - .stream() - .filter(e -> e instanceof TNTPrimed) - .map(e -> (TNTPrimed)e); - TraceListener.onTick(tntPrimedStream); - - if (RecordManager.status == RecordManager.Status.RECORD_AUTO && System.currentTimeMillis() - lastExplosion > 4500) { - stopAuto(); - } - } - -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/tracernew/DataHolder.java b/BauSystem_Main/src/de/steamwar/bausystem/tracernew/DataHolder.java deleted file mode 100644 index c9c1bbd..0000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/tracernew/DataHolder.java +++ /dev/null @@ -1,45 +0,0 @@ -package de.steamwar.bausystem.tracernew; - -import de.steamwar.bausystem.commands.CommandTPSLimiter; -import de.steamwar.bausystem.tracernew.data.RecordStatus; -import org.bukkit.Bukkit; -import org.bukkit.World; - -public class DataHolder { - - public static final World world = Bukkit.getWorlds().get(0); - - public static RecordStatus status = RecordStatus.IDLE; - public static long recordStart = System.currentTimeMillis(); - public static long lastExplosion = System.currentTimeMillis(); - - public static boolean isAutoStop() { - if (!isRecordingAuto()) return false; - return System.currentTimeMillis() - lastExplosion > (20.0 / CommandTPSLimiter.getCurrentTPSLimit()) * 50 * 80; - } - - public static boolean isRecording() { - return status == RecordStatus.RECORD || status == RecordStatus.RECORD_AUTO; - } - - public static boolean isRecordingAuto() { - return status == RecordStatus.RECORD_AUTO; - } - - public static boolean isRecordingNotAuto() { - return status == RecordStatus.RECORD; - } - - public static boolean isIdle() { - return status == RecordStatus.IDLE || status == RecordStatus.IDLE_AUTO; - } - - public static boolean isIdleAuto() { - return status == RecordStatus.IDLE_AUTO; - } - - public static boolean isIdleNotAuto() { - return status == RecordStatus.IDLE; - } - -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/tracernew/TraceHolder.java b/BauSystem_Main/src/de/steamwar/bausystem/tracernew/TraceHolder.java deleted file mode 100644 index 6d1115b..0000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/tracernew/TraceHolder.java +++ /dev/null @@ -1,4 +0,0 @@ -package de.steamwar.bausystem.tracernew; - -public class TraceHolder { -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/tracernew/data/TNTTrace.java b/BauSystem_Main/src/de/steamwar/bausystem/tracernew/data/TNTTrace.java deleted file mode 100644 index 0f58dbf..0000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/tracernew/data/TNTTrace.java +++ /dev/null @@ -1,4 +0,0 @@ -package de.steamwar.bausystem.tracernew.data; - -public class TNTTrace { -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/tracernew/recorder/ExplodeListener.java b/BauSystem_Main/src/de/steamwar/bausystem/tracernew/recorder/ExplodeListener.java deleted file mode 100644 index e0ed975..0000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/tracernew/recorder/ExplodeListener.java +++ /dev/null @@ -1,22 +0,0 @@ -package de.steamwar.bausystem.tracernew.recorder; - -import de.steamwar.bausystem.tracernew.DataHolder; -import org.bukkit.entity.TNTPrimed; -import org.bukkit.event.Listener; -import org.bukkit.event.entity.EntityExplodeEvent; - -public class ExplodeListener implements Listener { - - public void onEntityExplode(EntityExplodeEvent event) { - if (!(event.getEntity() instanceof TNTPrimed)) - return; - - if (DataHolder.isRecordingAuto()) - RecordManager.stopAuto(); - if (DataHolder.isIdleAuto()) - RecordManager.updateAuto(); - - - } - -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/tracernew/recorder/RecordManager.java b/BauSystem_Main/src/de/steamwar/bausystem/tracernew/recorder/RecordManager.java deleted file mode 100644 index eb8efc4..0000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/tracernew/recorder/RecordManager.java +++ /dev/null @@ -1,91 +0,0 @@ -package de.steamwar.bausystem.tracernew.recorder; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.tracer.TraceManager; -import de.steamwar.bausystem.tracernew.DataHolder; -import de.steamwar.bausystem.tracernew.data.RecordStatus; -import net.md_5.bungee.api.ChatMessageType; -import net.md_5.bungee.api.chat.TextComponent; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - -import static de.steamwar.bausystem.tracernew.recorder.TNTRecorder.*; - -public class RecordManager { - - private RecordManager() { - throw new IllegalStateException("Utility class"); - } - - public static void recordCommands(Player player, String[] args) { - switch (args[0].toLowerCase()) { - case "start": - start(); - player.sendMessage(BauSystem.PREFIX + "§aAufnahme gestartet"); - break; - case "stop": - stop(); - player.sendMessage(BauSystem.PREFIX + "§cTNT-Tracer gestoppt"); - break; - case "auto": - case "toggleauto": - toggleAuto(); - if (DataHolder.isIdleNotAuto() || DataHolder.isRecordingNotAuto()) { - player.sendMessage(BauSystem.PREFIX + "§cAutomatischer TNT-Tracer deaktiviert"); - } else { - player.sendMessage(BauSystem.PREFIX + "§aAutomatischer TNT-Tracer aktiviert"); - } - break; - } - } - - private static void toggleAuto() { - switch (DataHolder.status) { - case IDLE: - DataHolder.status = RecordStatus.IDLE_AUTO; - break; - case RECORD: - DataHolder.status = RecordStatus.RECORD_AUTO; - break; - case IDLE_AUTO: - DataHolder.status = RecordStatus.IDLE; - break; - case RECORD_AUTO: - DataHolder.status = RecordStatus.RECORD; - break; - default: - break; - } - } - - public static void start() { - DataHolder.status = RecordStatus.RECORD; - TraceManager.startFrame(); - startRecording(); - } - - public static void startAuto() { - DataHolder.status = RecordStatus.RECORD_AUTO; - Bukkit.getOnlinePlayers().forEach(player -> player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText("§7Automatischer TNT-Tracer §8- §aAufnahme gestartet"))); - TraceManager.startFrame(); - startRecording(); - } - - public static void updateAuto() { - update(); - } - - public static void stop() { - DataHolder.status = RecordStatus.IDLE; - stopRecording(); - TraceManager.stopFrame(); - } - - static void stopAuto() { - DataHolder.status = RecordStatus.IDLE_AUTO; - Bukkit.getOnlinePlayers().forEach(player -> player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText("§7Automatischer TNT-Tracer §8- §aAufnahme gestoppt"))); - stopRecording(); - TraceManager.stopFrame(); - } - -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/tracernew/recorder/TNTRecorder.java b/BauSystem_Main/src/de/steamwar/bausystem/tracernew/recorder/TNTRecorder.java deleted file mode 100644 index e5ea32a..0000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/tracernew/recorder/TNTRecorder.java +++ /dev/null @@ -1,51 +0,0 @@ -package de.steamwar.bausystem.tracernew.recorder; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.tracer.TraceListener; -import de.steamwar.bausystem.tracernew.DataHolder; -import org.bukkit.Bukkit; -import org.bukkit.entity.TNTPrimed; -import org.bukkit.scheduler.BukkitTask; - -import java.util.stream.Stream; - -import static de.steamwar.bausystem.tracernew.recorder.RecordManager.stopAuto; - -public class TNTRecorder { - - private static BukkitTask task = null; - - static void update() { - if (task == null) return; - if (!DataHolder.isRecordingAuto()) return; - DataHolder.lastExplosion = System.currentTimeMillis(); - } - - static void startRecording() { - if (task != null) return; - DataHolder.recordStart = System.currentTimeMillis(); - DataHolder.lastExplosion = System.currentTimeMillis(); - task = Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), TNTRecorder::run, 1, 1); - run(); - } - - static void stopRecording() { - if (task == null) return; - task.cancel(); - task = null; - } - - private static void run() { - DataHolder.world.getEntitiesByClass(TNTPrimed.class).stream() - Stream tntPrimedStream = DataHolder.world.getEntities() - .stream() - .filter(e -> e instanceof TNTPrimed) - .map(e -> (TNTPrimed)e); - TraceListener.onTick(tntPrimedStream); - - if (DataHolder.isAutoStop()) { - stopAuto(); - } - } - -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/BauScoreboard.java b/BauSystem_Main/src/de/steamwar/bausystem/world/BauScoreboard.java index 117a4ee..8f71247 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/BauScoreboard.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/BauScoreboard.java @@ -22,9 +22,8 @@ package de.steamwar.bausystem.world; import de.steamwar.bausystem.commands.CommandFreeze; import de.steamwar.bausystem.commands.CommandTNT; import de.steamwar.bausystem.commands.CommandTPSLimiter; +import de.steamwar.bausystem.tracer.RecordManager; import de.steamwar.bausystem.tracer.TraceManager; -import de.steamwar.bausystem.tracer.recorder.RecordManager; -import de.steamwar.bausystem.tracer.recorder.TNTRecorder; import de.steamwar.core.TPSWatcher; import de.steamwar.scoreboard.SWScoreboard; import de.steamwar.scoreboard.ScoreboardCallback; @@ -62,14 +61,14 @@ public class BauScoreboard implements Listener { strings.add("§2"); strings.add("§eTNT§8: " + (!CommandTNT.getInstance().isOn() ? "§aan" : "§caus")); strings.add("§eFreeze§8: " + (CommandFreeze.getInstance().isOn() ? "§aan" : "§caus")); - strings.add("§eTrace§8: " + RecordManager.getStatus().getValue()); + strings.add("§eTrace§8: " + RecordManager.getRecordStatus().getName()); strings.add("§eLoader§8: " + (AutoLoader.hasLoader(p) ? "§aan" : "§caus")); - if (RecordManager.getStatus().isTracing()) { + if (RecordManager.getRecordStatus().isTracing()) { strings.add("§3"); - strings.add("§eTrace-Start§8: §7" + new SimpleDateFormat("HH:mm:ss").format(new Date(TNTRecorder.recordStart))); + strings.add("§eTrace-Start§8: §7" + new SimpleDateFormat("HH:mm:ss").format(new Date(RecordManager.getStartTime()))); strings.add("§eTicks§8: §7" + traceTicks()); - strings.add("§eAnzahl TNT§8: §7" + TraceManager.currentFrameSize()); + strings.add("§eAnzahl TNT§8: §7" + TraceManager.getRecordSize()); } strings.add("§4"); @@ -83,7 +82,7 @@ public class BauScoreboard implements Listener { } private long traceTicks() { - return (System.currentTimeMillis() - TNTRecorder.recordStart) / 50; + return (System.currentTimeMillis() - RecordManager.getStartTime()) / 50; } private String tpsColor() { @@ -103,4 +102,5 @@ public class BauScoreboard implements Listener { } return "§8/§7" + CommandTPSLimiter.getCurrentTPSLimit(); } + }