diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index 23293543..0d38af4e 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -21,6 +21,10 @@ package de.steamwar.bausystem; import com.comphenix.tinyprotocol.TinyProtocol; import de.steamwar.bausystem.configplayer.Config; +import de.steamwar.bausystem.features.tpslimit.FreezeUtils; +import de.steamwar.bausystem.features.tpslimit.TPSLimitUtils; +import de.steamwar.bausystem.features.tpslimit.TPSUtils; +import de.steamwar.bausystem.features.tpslimit.TPSWarpUtils; import de.steamwar.bausystem.features.world.RamUsage; import de.steamwar.bausystem.region.loader.PrototypeLoader; import de.steamwar.bausystem.region.loader.RegionLoader; @@ -32,11 +36,16 @@ import lombok.Getter; import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.event.Listener; +import org.bukkit.plugin.Plugin; import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.scheduler.BukkitRunnable; +import org.bukkit.scheduler.BukkitTask; import java.io.IOException; import java.io.OutputStream; import java.io.PrintStream; +import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Consumer; import java.util.logging.Level; public class BauSystem extends JavaPlugin implements Listener { @@ -123,4 +132,45 @@ public class BauSystem extends JavaPlugin implements Listener { } })); } + + public static BukkitTask runTaskLater(Plugin plugin, Runnable runnable, long delay) { + return new BukkitRunnable() { + private int counter = 1; + + @Override + public void run() { + if (FreezeUtils.isFrozen()) return; + if (counter >= delay) { + runnable.run(); + cancel(); + return; + } + counter++; + } + }.runTaskTimer(plugin, 0, 1); + } + + public static BukkitTask runTaskTimer(Plugin plugin, Runnable runnable, long delay, long period) { + return new BukkitRunnable() { + private int counter = 1; + private boolean first = true; + + @Override + public void run() { + if (FreezeUtils.isFrozen()) return; + if (counter >= (first ? delay : period)) { + first = false; + runnable.run(); + counter = 1; + return; + } + counter++; + } + }.runTaskTimer(plugin, 0, 1); + } + + public static void runTaskTimer(Plugin plugin, Consumer consumer, long delay, long period) { + AtomicReference task = new AtomicReference<>(); + task.set(runTaskTimer(plugin, () -> consumer.accept(task.get()), delay, period)); + } } \ No newline at end of file diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutostartListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutostartListener.java index 8d254a3a..66f53359 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutostartListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutostartListener.java @@ -88,7 +88,7 @@ public class AutostartListener implements Listener { } else { BauSystem.MESSAGE.send("AUTOSTART_MESSAGE_START", player); } - regionStartTime.put(region, TPSUtils.currentTick.get()); + regionStartTime.put(region, TPSUtils.currentRealTick.get()); } @EventHandler @@ -101,7 +101,7 @@ public class AutostartListener implements Listener { if (!regionStartTime.containsKey(region)) return; if (!region.hasType(RegionType.TESTBLOCK)) return; if (!region.inRegion(block.getLocation(), RegionType.TESTBLOCK, RegionExtensionType.EXTENSION)) return; - long tickDiff = TPSUtils.currentTick.get() - regionStartTime.remove(region); + long tickDiff = TPSUtils.currentRealTick.get() - regionStartTime.remove(region); RegionUtils.message(region, player -> { return BauSystem.MESSAGE.parse("AUTOSTART_MESSAGE_RESULT1", player, new SimpleDateFormat(BauSystem.MESSAGE.parse("AUTOSTART_MESSAGE_DATE_PATTERN", player)).format(new Date(tickDiff * 50))); }); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/cannon/CannonDetector.java b/BauSystem_Main/src/de/steamwar/bausystem/features/cannon/CannonDetector.java index 801b5aca..09893fd5 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/cannon/CannonDetector.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/cannon/CannonDetector.java @@ -72,7 +72,7 @@ public class CannonDetector implements Listener { return; } - Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> { + BauSystem.runTaskLater(BauSystem.getInstance(), () -> { Map> grouped = new HashMap<>(); velocities.forEach((tntPrimed, vector) -> { grouped.computeIfAbsent(new CannonKey(round(tntPrimed.getLocation().toVector()), round(vector)), ignored -> new ArrayList<>()).add(tntPrimed); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/Loader.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/Loader.java index 6b61f14f..58ac95a6 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/Loader.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/Loader.java @@ -71,7 +71,7 @@ public class Loader implements Listener { if (currentElement >= elements.size()) { currentElement = 0; if (totalDelay == 0) { - Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), this::next, 1); + BauSystem.runTaskLater(BauSystem.getInstance(), this::next, 1); return; } totalDelay = 0; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderRecorder.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderRecorder.java index f42ad0db..a0734231 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderRecorder.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderRecorder.java @@ -46,7 +46,7 @@ public class LoaderRecorder implements Listener { private Player player; private List loaderElementList; - private long lastInteraction = TPSUtils.currentTick.get(); + private long lastInteraction = TPSUtils.currentRealTick.get(); public LoaderRecorder(Player player, List loaderElementList) { this.player = player; @@ -63,15 +63,15 @@ public class LoaderRecorder implements Listener { private void addWaitTime(boolean last) { if (loaderElementList.isEmpty()) { - lastInteraction = TPSUtils.currentTick.get(); + lastInteraction = TPSUtils.currentRealTick.get(); return; } if (loaderElementList.get(loaderElementList.size() - 1) instanceof LoaderWait) { return; } - long diff = TPSUtils.currentTick.get() - lastInteraction; + long diff = TPSUtils.currentRealTick.get() - lastInteraction; if (last && diff > 160) diff = 160; - lastInteraction = TPSUtils.currentTick.get(); + lastInteraction = TPSUtils.currentRealTick.get(); loaderElementList.add(new LoaderWait(diff)); } @@ -165,10 +165,10 @@ public class LoaderRecorder implements Listener { Long startTime = blockSet.remove(fromBlock.getLocation()); LoaderMovement loaderMovement = movementSet.remove(fromBlock.getLocation()); if (loaderMovement != null && startTime != null) { - loaderMovement.setInitialTicks(TPSUtils.currentTick.get() - startTime); + loaderMovement.setInitialTicks(TPSUtils.currentRealTick.get() - startTime); } - blockSet.put(toBlock.getLocation(), TPSUtils.currentTick.get()); + blockSet.put(toBlock.getLocation(), TPSUtils.currentRealTick.get()); addWaitTime(false); loaderMovement = null; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderMovement.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderMovement.java index 55c41fd7..3bc9ebff 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderMovement.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderMovement.java @@ -112,7 +112,7 @@ public class LoaderMovement extends LoaderInteractionElement= 0) { boolean finalWaitFor = waitFor; - Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> { + BauSystem.runTaskLater(BauSystem.getInstance(), () -> { if (blockData instanceof AnaloguePowerable) { AnaloguePowerable analoguePowerable = (AnaloguePowerable) blockData; analoguePowerable.setPower(0); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderTNT.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderTNT.java index 6c95bf71..be2fb913 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderTNT.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderTNT.java @@ -49,7 +49,7 @@ public class LoaderTNT implements LoaderElement { public void execute(Runnable nextAction) { Block block = location.getBlock(); if (block.getType() != Material.AIR && block.getType() != Material.WATER) { - Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> execute(nextAction), 1); + BauSystem.runTaskLater(BauSystem.getInstance(), () -> execute(nextAction), 1); return; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderTicks.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderTicks.java index 098d29ea..e770c258 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderTicks.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderTicks.java @@ -87,7 +87,7 @@ public class LoaderTicks extends LoaderInteractionElement { + BauSystem.runTaskLater(BauSystem.getInstance(), () -> { powerable.setPowered(false); location.getBlock().setBlockData(powerable, true); update(powerable); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderWait.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderWait.java index 0c694a87..527ee624 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderWait.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderWait.java @@ -58,7 +58,7 @@ public class LoaderWait implements LoaderElement, Listener { nextAction.run(); return; } - Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), nextAction, delay); + BauSystem.runTaskLater(BauSystem.getInstance(), nextAction, delay); } @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadtimer/Loadtimer.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadtimer/Loadtimer.java index c321faba..116edba5 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadtimer/Loadtimer.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadtimer/Loadtimer.java @@ -65,9 +65,9 @@ public class Loadtimer implements Listener { this.region = region; this.stage = Stage.WAITING; Bukkit.getPluginManager().registerEvents(this, BauSystem.getInstance()); - task = Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> { + task = BauSystem.runTaskTimer(BauSystem.getInstance(), () -> { if (stage == Stage.COUNTING) { - long timeSinceStart = TPSUtils.currentTick.get() - start; + long timeSinceStart = TPSUtils.currentRealTick.get() - start; long timeSinceHalf = timeSinceStart / 2; double timeSec = (timeSinceStart / 20d); String sec = new DecimalFormat("#.#").format(timeSec); @@ -119,7 +119,7 @@ public class Loadtimer implements Listener { public void onTntPlace(BlockPlaceEvent event) { if (stage == Stage.WAITING) { this.stage = Stage.COUNTING; - this.start = TPSUtils.currentTick.get(); + this.start = TPSUtils.currentRealTick.get(); } if (stage == Stage.COUNTING) { @@ -146,9 +146,9 @@ public class Loadtimer implements Listener { public void onTntSpawn() { if ((stage == Stage.COUNTING || stage == Stage.ACTIVATED)) { stage = Stage.IGNITION; - ignite = TPSUtils.currentTick.get(); + ignite = TPSUtils.currentRealTick.get(); if (activate == -1) - activate = TPSUtils.currentTick.get(); + activate = TPSUtils.currentRealTick.get(); if (finishOnActive) { stage = Stage.END; print(); @@ -160,14 +160,14 @@ public class Loadtimer implements Listener { public void onTntExplode(EntityExplodeEvent event) { if (region.inRegion(event.getLocation(), RegionType.BUILD, RegionExtensionType.EXTENSION) && stage == Stage.IGNITION) { stage = Stage.END; - explode = TPSUtils.currentTick.get(); + explode = TPSUtils.currentRealTick.get(); print(); delete(); } } private void setActivate() { - activate = TPSUtils.currentTick.get(); + activate = TPSUtils.currentRealTick.get(); stage = Stage.ACTIVATED; if (finishOnActive) { print(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/redstonetester/RedstonetesterUtils.java b/BauSystem_Main/src/de/steamwar/bausystem/features/redstonetester/RedstonetesterUtils.java index 128c79ae..a70b143b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/redstonetester/RedstonetesterUtils.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/redstonetester/RedstonetesterUtils.java @@ -89,18 +89,18 @@ public class RedstonetesterUtils { tick = null; return; } - if (TPSUtils.currentTick.get() - lastTick > 100) { + if (TPSUtils.currentRealTick.get() - lastTick > 100) { tick = null; } if (loc1.equals(location)) { - lastTick = TPSUtils.currentTick.get(); + lastTick = TPSUtils.currentRealTick.get(); if (tick == null) { - tick = TPSUtils.currentTick.get(); + tick = TPSUtils.currentRealTick.get(); } return; } if (tick != null && loc2.equals(location)) { - BauSystem.MESSAGE.send("RT_RESULT", player, (TPSUtils.currentTick.get() - tick), ((TPSUtils.currentTick.get() - tick) / 2.0)); + BauSystem.MESSAGE.send("RT_RESULT", player, (TPSUtils.currentRealTick.get() - tick), ((TPSUtils.currentRealTick.get() - tick) / 2.0)); } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/shieldprinting/ShieldPrinting.java b/BauSystem_Main/src/de/steamwar/bausystem/features/shieldprinting/ShieldPrinting.java index ea3b0fbc..5f093e7d 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/shieldprinting/ShieldPrinting.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/shieldprinting/ShieldPrinting.java @@ -23,7 +23,6 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.utils.bossbar.BauSystemBossbar; import de.steamwar.bausystem.utils.bossbar.BossBarService; -import de.steamwar.bausystem.utils.bossbar.RegionedBossbar; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -38,13 +37,9 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; -import org.bukkit.event.block.BlockFormEvent; import org.bukkit.event.block.BlockPistonExtendEvent; import org.bukkit.event.block.BlockPistonRetractEvent; -import org.bukkit.event.block.EntityBlockFormEvent; -import org.bukkit.event.entity.EntityAirChangeEvent; import org.bukkit.event.entity.EntityChangeBlockEvent; -import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntitySpawnEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerJoinEvent; @@ -57,7 +52,7 @@ public class ShieldPrinting implements Listener { private static final World WORLD = Bukkit.getWorlds().get(0); static { - Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> { + BauSystem.runTaskTimer(BauSystem.getInstance(), () -> { ShieldPrintingCommand.SHIELD_PRINTING_MAP.values().forEach(shieldPrinting -> { shieldPrinting.fallingBlocks.replaceAll((entity, location) -> { if (entity.isDead()) return null; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulator.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulator.java index 46d9779a..d1a71b95 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulator.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulator.java @@ -245,7 +245,7 @@ public class TNTSimulator { }); AtomicInteger currentTick = new AtomicInteger(0); - Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), bukkitTask -> { + BauSystem.runTaskTimer(BauSystem.getInstance(), bukkitTask -> { int tick = currentTick.get(); if (tick > maxTick.get()) bukkitTask.cancel(); currentTick.incrementAndGet(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/blockcounter/BlockCount.java b/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/blockcounter/BlockCount.java index e99a31be..84853b8c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/blockcounter/BlockCount.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/blockcounter/BlockCount.java @@ -40,18 +40,18 @@ public class BlockCount { private Region region; private int count = 0; private int tntCount = 0; - private final long tick = TPSUtils.currentTick.get(); + private final long tick = TPSUtils.currentRealTick.get(); - private long lastUpdate = TPSUtils.currentTick.get(); + private long lastUpdate = TPSUtils.currentRealTick.get(); public BlockCount(Region region) { this.region = region; if (bukkitTask == null) { - bukkitTask = Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> { + bukkitTask = BauSystem.runTaskTimer(BauSystem.getInstance(), () -> { Set toRemove = new HashSet<>(); for (BlockCount blockCount : BlockCounter.blockCountMap.values()) { - if (TPSUtils.currentTick.get() - blockCount.lastUpdate < 60) { + if (TPSUtils.currentRealTick.get() - blockCount.lastUpdate < 60) { continue; } toRemove.add(blockCount.region); @@ -74,6 +74,6 @@ public class BlockCount { public void update(List blocks) { count += blocks.size(); tntCount++; - lastUpdate = TPSUtils.currentTick.get(); + lastUpdate = TPSUtils.currentRealTick.get(); } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSUtils.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSUtils.java index 7a2e3a0e..d920b5fa 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSUtils.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSUtils.java @@ -31,7 +31,11 @@ public class TPSUtils { private static long ticksSinceServerStart = 0; public static final Supplier currentTick = () -> ticksSinceServerStart; // This is intended as Supplier + private static long realTicksSinceServerStart = 0; + public static final Supplier currentRealTick = () -> realTicksSinceServerStart; // This is intended as Supplier + static { Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> ticksSinceServerStart++, 1, 1); + BauSystem.runTaskTimer(BauSystem.getInstance(), () -> realTicksSinceServerStart++, 1, 1); } } \ No newline at end of file diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/AutoTraceRecorder.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/AutoTraceRecorder.java index 2af4146b..f0eeab8c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/AutoTraceRecorder.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/AutoTraceRecorder.java @@ -32,7 +32,7 @@ import java.util.function.Supplier; public abstract class AutoTraceRecorder implements TraceRecorder { protected boolean recording = false; - private long startTime = TPSUtils.currentTick.get(); + private long startTime = TPSUtils.currentRealTick.get(); private long lastExplosion = 0; private final Map recordMap = new HashMap<>(); @@ -40,7 +40,7 @@ public abstract class AutoTraceRecorder implements TraceRecorder { private Supplier recordSupplier; private Record.TNTRecord getRecord(TNTPrimed tntPrimed) { - return recordMap.computeIfAbsent(tntPrimed, __ -> record.spawn(TPSUtils.currentTick.get() - startTime)); + return recordMap.computeIfAbsent(tntPrimed, __ -> record.spawn(TPSUtils.currentRealTick.get() - startTime)); } protected abstract String getInactivityMessage(); @@ -51,7 +51,7 @@ public abstract class AutoTraceRecorder implements TraceRecorder { @Override public final String scoreboard(Player player) { if (recording) { - return BauSystem.MESSAGE.parse("TRACE_RECORD", player) + " §8| §e" + (TPSUtils.currentTick.get() - startTime) + " §7" + BauSystem.MESSAGE.parse("SCOREBOARD_TRACE_TICKS", player); + return BauSystem.MESSAGE.parse("TRACE_RECORD", player) + " §8| §e" + (TPSUtils.currentRealTick.get() - startTime) + " §7" + BauSystem.MESSAGE.parse("SCOREBOARD_TRACE_TICKS", player); } else { return BauSystem.MESSAGE.parse(getInactivityMessage(), player); } @@ -59,7 +59,7 @@ public abstract class AutoTraceRecorder implements TraceRecorder { private void startRecording() { lastExplosion = 0; - startTime = TPSUtils.currentTick.get(); + startTime = TPSUtils.currentRealTick.get(); record = recordSupplier.get(); recording = true; } @@ -130,6 +130,6 @@ public abstract class AutoTraceRecorder implements TraceRecorder { @Override public long scriptTime() { - return TPSUtils.currentTick.get() - startTime; + return TPSUtils.currentRealTick.get() - startTime; } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/Recorder.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/Recorder.java index 3a0bfe7b..7dd12060 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/Recorder.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/Recorder.java @@ -129,7 +129,7 @@ public class Recorder implements Listener { } { - Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> { + BauSystem.runTaskTimer(BauSystem.getInstance(), () -> { tick(); tntTraceRecorderMap.keySet() .stream() diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/SimpleTraceRecorder.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/SimpleTraceRecorder.java index 79e984aa..1077f59a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/SimpleTraceRecorder.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/SimpleTraceRecorder.java @@ -31,13 +31,13 @@ import java.util.function.Supplier; public class SimpleTraceRecorder implements TraceRecorder, ActiveTracer { - private final long startTime = TPSUtils.currentTick.get(); + private final long startTime = TPSUtils.currentRealTick.get(); private final Map recordMap = new HashMap<>(); private Record record; @Override public String scoreboard(Player player) { - return BauSystem.MESSAGE.parse("TRACE_RECORD", player) + " §8| §e" + (TPSUtils.currentTick.get() - startTime) + " §7" + BauSystem.MESSAGE.parse("SCOREBOARD_TRACE_TICKS", player); + return BauSystem.MESSAGE.parse("TRACE_RECORD", player) + " §8| §e" + (TPSUtils.currentRealTick.get() - startTime) + " §7" + BauSystem.MESSAGE.parse("SCOREBOARD_TRACE_TICKS", player); } @Override @@ -51,7 +51,7 @@ public class SimpleTraceRecorder implements TraceRecorder, ActiveTracer { } private Record.TNTRecord getRecord(TNTPrimed tntPrimed) { - return recordMap.computeIfAbsent(tntPrimed, __ -> record.spawn(TPSUtils.currentTick.get() - startTime)); + return recordMap.computeIfAbsent(tntPrimed, __ -> record.spawn(TPSUtils.currentRealTick.get() - startTime)); } @Override @@ -79,6 +79,6 @@ public class SimpleTraceRecorder implements TraceRecorder, ActiveTracer { @Override public long scriptTime() { - return TPSUtils.currentTick.get() - startTime; + return TPSUtils.currentRealTick.get() - startTime; } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/StoredRecords.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/StoredRecords.java index ce90aad7..993e4fdd 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/StoredRecords.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/StoredRecords.java @@ -42,7 +42,7 @@ public class StoredRecords { private static final Map> records = new HashMap<>(); static { - Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> { + BauSystem.runTaskTimer(BauSystem.getInstance(), () -> { replayLoops.forEach((region, playerSupplierMap) -> { playerSupplierMap.forEach((player, integerSupplier) -> { int tick = integerSupplier.get();