From f7727eb01c9549e94bbef395654bb76a942dbe67 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 21 Apr 2024 13:23:15 +0200 Subject: [PATCH] Add TraceScoreboardElement --- .../steamwar/bausystem/features/tracer/TraceRecorder.java | 6 ++++++ .../bausystem/features/tracer/TraceScoreboardElement.java | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceRecorder.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceRecorder.java index a706433b..b7ac25a1 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceRecorder.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceRecorder.java @@ -184,6 +184,12 @@ public class TraceRecorder implements Listener { return activeTraces.containsKey(region); } + public long getStartTimeOfTraceInRegion(Region region) { + TraceRecordingWrapper wrapper = activeTraces.get(region); + if (wrapper == null) return 0; + return wrapper.getStartTick(); + } + /** * Event for TNTs beeing spawn. * Registers newly spawned TNT to be traced if reqired diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceScoreboardElement.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceScoreboardElement.java index 7a34f29a..f7b20f8c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceScoreboardElement.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceScoreboardElement.java @@ -21,6 +21,7 @@ package de.steamwar.bausystem.features.tracer; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; +import de.steamwar.bausystem.features.tpslimit.TPSUtils; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.utils.ScoreboardElement; import de.steamwar.linkage.Linked; @@ -45,7 +46,7 @@ public class TraceScoreboardElement implements ScoreboardElement { public String get(Region region, Player p) { if (!Permission.BUILD.hasPermission(p)) return null; if (TraceRecorder.instance.isTraceActiveInRegion(region)) { - return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_TRACE", p) + "§8: " + BauSystem.MESSAGE.parse("TRACE_RECORD", p); + return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_TRACE", p) + "§8: " + BauSystem.MESSAGE.parse("TRACE_RECORD", p) + " §8| §e" + (TPSUtils.currentRealTick.get() - TraceRecorder.instance.getStartTimeOfTraceInRegion(region)) + " §7" + BauSystem.MESSAGE.parse("SCOREBOARD_TRACE_TICKS", p); } else if (TraceRecorder.instance.isAutoTraceEnabledInRegion(region)) { return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_TRACE", p) + "§8: " + BauSystem.MESSAGE.parse("TRACE_IDLE_AUTO", p); }