SteamWar/BauSystem2.0
Archiviert
12
0

Fix tpslimit 0 with all necessary features
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2023-06-20 17:56:26 +02:00
Ursprung a317891685
Commit 6c6b17eb30
19 geänderte Dateien mit 97 neuen und 48 gelöschten Zeilen

Datei anzeigen

@ -21,6 +21,10 @@ package de.steamwar.bausystem;
import com.comphenix.tinyprotocol.TinyProtocol; import com.comphenix.tinyprotocol.TinyProtocol;
import de.steamwar.bausystem.configplayer.Config; 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.features.world.RamUsage;
import de.steamwar.bausystem.region.loader.PrototypeLoader; import de.steamwar.bausystem.region.loader.PrototypeLoader;
import de.steamwar.bausystem.region.loader.RegionLoader; import de.steamwar.bausystem.region.loader.RegionLoader;
@ -32,11 +36,16 @@ import lombok.Getter;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.io.PrintStream; import java.io.PrintStream;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Consumer;
import java.util.logging.Level; import java.util.logging.Level;
public class BauSystem extends JavaPlugin implements Listener { 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<BukkitTask> consumer, long delay, long period) {
AtomicReference<BukkitTask> task = new AtomicReference<>();
task.set(runTaskTimer(plugin, () -> consumer.accept(task.get()), delay, period));
}
} }

Datei anzeigen

@ -88,7 +88,7 @@ public class AutostartListener implements Listener {
} else { } else {
BauSystem.MESSAGE.send("AUTOSTART_MESSAGE_START", player); BauSystem.MESSAGE.send("AUTOSTART_MESSAGE_START", player);
} }
regionStartTime.put(region, TPSUtils.currentTick.get()); regionStartTime.put(region, TPSUtils.currentRealTick.get());
} }
@EventHandler @EventHandler
@ -101,7 +101,7 @@ public class AutostartListener implements Listener {
if (!regionStartTime.containsKey(region)) return; if (!regionStartTime.containsKey(region)) return;
if (!region.hasType(RegionType.TESTBLOCK)) return; if (!region.hasType(RegionType.TESTBLOCK)) return;
if (!region.inRegion(block.getLocation(), RegionType.TESTBLOCK, RegionExtensionType.EXTENSION)) 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 -> { 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))); return BauSystem.MESSAGE.parse("AUTOSTART_MESSAGE_RESULT1", player, new SimpleDateFormat(BauSystem.MESSAGE.parse("AUTOSTART_MESSAGE_DATE_PATTERN", player)).format(new Date(tickDiff * 50)));
}); });

Datei anzeigen

@ -72,7 +72,7 @@ public class CannonDetector implements Listener {
return; return;
} }
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> { BauSystem.runTaskLater(BauSystem.getInstance(), () -> {
Map<CannonKey, List<TNTPrimed>> grouped = new HashMap<>(); Map<CannonKey, List<TNTPrimed>> grouped = new HashMap<>();
velocities.forEach((tntPrimed, vector) -> { velocities.forEach((tntPrimed, vector) -> {
grouped.computeIfAbsent(new CannonKey(round(tntPrimed.getLocation().toVector()), round(vector)), ignored -> new ArrayList<>()).add(tntPrimed); grouped.computeIfAbsent(new CannonKey(round(tntPrimed.getLocation().toVector()), round(vector)), ignored -> new ArrayList<>()).add(tntPrimed);

Datei anzeigen

@ -71,7 +71,7 @@ public class Loader implements Listener {
if (currentElement >= elements.size()) { if (currentElement >= elements.size()) {
currentElement = 0; currentElement = 0;
if (totalDelay == 0) { if (totalDelay == 0) {
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), this::next, 1); BauSystem.runTaskLater(BauSystem.getInstance(), this::next, 1);
return; return;
} }
totalDelay = 0; totalDelay = 0;

Datei anzeigen

@ -46,7 +46,7 @@ public class LoaderRecorder implements Listener {
private Player player; private Player player;
private List<LoaderElement> loaderElementList; private List<LoaderElement> loaderElementList;
private long lastInteraction = TPSUtils.currentTick.get(); private long lastInteraction = TPSUtils.currentRealTick.get();
public LoaderRecorder(Player player, List<LoaderElement> loaderElementList) { public LoaderRecorder(Player player, List<LoaderElement> loaderElementList) {
this.player = player; this.player = player;
@ -63,15 +63,15 @@ public class LoaderRecorder implements Listener {
private void addWaitTime(boolean last) { private void addWaitTime(boolean last) {
if (loaderElementList.isEmpty()) { if (loaderElementList.isEmpty()) {
lastInteraction = TPSUtils.currentTick.get(); lastInteraction = TPSUtils.currentRealTick.get();
return; return;
} }
if (loaderElementList.get(loaderElementList.size() - 1) instanceof LoaderWait) { if (loaderElementList.get(loaderElementList.size() - 1) instanceof LoaderWait) {
return; return;
} }
long diff = TPSUtils.currentTick.get() - lastInteraction; long diff = TPSUtils.currentRealTick.get() - lastInteraction;
if (last && diff > 160) diff = 160; if (last && diff > 160) diff = 160;
lastInteraction = TPSUtils.currentTick.get(); lastInteraction = TPSUtils.currentRealTick.get();
loaderElementList.add(new LoaderWait(diff)); loaderElementList.add(new LoaderWait(diff));
} }
@ -165,10 +165,10 @@ public class LoaderRecorder implements Listener {
Long startTime = blockSet.remove(fromBlock.getLocation()); Long startTime = blockSet.remove(fromBlock.getLocation());
LoaderMovement loaderMovement = movementSet.remove(fromBlock.getLocation()); LoaderMovement loaderMovement = movementSet.remove(fromBlock.getLocation());
if (loaderMovement != null && startTime != null) { 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); addWaitTime(false);
loaderMovement = null; loaderMovement = null;

Datei anzeigen

@ -112,7 +112,7 @@ public class LoaderMovement extends LoaderInteractionElement<LoaderMovement.Move
if (ticks >= 0) { if (ticks >= 0) {
boolean finalWaitFor = waitFor; boolean finalWaitFor = waitFor;
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> { BauSystem.runTaskLater(BauSystem.getInstance(), () -> {
if (blockData instanceof AnaloguePowerable) { if (blockData instanceof AnaloguePowerable) {
AnaloguePowerable analoguePowerable = (AnaloguePowerable) blockData; AnaloguePowerable analoguePowerable = (AnaloguePowerable) blockData;
analoguePowerable.setPower(0); analoguePowerable.setPower(0);

Datei anzeigen

@ -49,7 +49,7 @@ public class LoaderTNT implements LoaderElement {
public void execute(Runnable nextAction) { public void execute(Runnable nextAction) {
Block block = location.getBlock(); Block block = location.getBlock();
if (block.getType() != Material.AIR && block.getType() != Material.WATER) { 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; return;
} }

Datei anzeigen

@ -87,7 +87,7 @@ public class LoaderTicks extends LoaderInteractionElement<LoaderTicks.TicksSetti
update(powerable); update(powerable);
boolean finalWaitFor = waitFor; boolean finalWaitFor = waitFor;
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> { BauSystem.runTaskLater(BauSystem.getInstance(), () -> {
powerable.setPowered(false); powerable.setPowered(false);
location.getBlock().setBlockData(powerable, true); location.getBlock().setBlockData(powerable, true);
update(powerable); update(powerable);

Datei anzeigen

@ -58,7 +58,7 @@ public class LoaderWait implements LoaderElement, Listener {
nextAction.run(); nextAction.run();
return; return;
} }
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), nextAction, delay); BauSystem.runTaskLater(BauSystem.getInstance(), nextAction, delay);
} }
@Override @Override

Datei anzeigen

@ -65,9 +65,9 @@ public class Loadtimer implements Listener {
this.region = region; this.region = region;
this.stage = Stage.WAITING; this.stage = Stage.WAITING;
Bukkit.getPluginManager().registerEvents(this, BauSystem.getInstance()); Bukkit.getPluginManager().registerEvents(this, BauSystem.getInstance());
task = Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> { task = BauSystem.runTaskTimer(BauSystem.getInstance(), () -> {
if (stage == Stage.COUNTING) { if (stage == Stage.COUNTING) {
long timeSinceStart = TPSUtils.currentTick.get() - start; long timeSinceStart = TPSUtils.currentRealTick.get() - start;
long timeSinceHalf = timeSinceStart / 2; long timeSinceHalf = timeSinceStart / 2;
double timeSec = (timeSinceStart / 20d); double timeSec = (timeSinceStart / 20d);
String sec = new DecimalFormat("#.#").format(timeSec); String sec = new DecimalFormat("#.#").format(timeSec);
@ -119,7 +119,7 @@ public class Loadtimer implements Listener {
public void onTntPlace(BlockPlaceEvent event) { public void onTntPlace(BlockPlaceEvent event) {
if (stage == Stage.WAITING) { if (stage == Stage.WAITING) {
this.stage = Stage.COUNTING; this.stage = Stage.COUNTING;
this.start = TPSUtils.currentTick.get(); this.start = TPSUtils.currentRealTick.get();
} }
if (stage == Stage.COUNTING) { if (stage == Stage.COUNTING) {
@ -146,9 +146,9 @@ public class Loadtimer implements Listener {
public void onTntSpawn() { public void onTntSpawn() {
if ((stage == Stage.COUNTING || stage == Stage.ACTIVATED)) { if ((stage == Stage.COUNTING || stage == Stage.ACTIVATED)) {
stage = Stage.IGNITION; stage = Stage.IGNITION;
ignite = TPSUtils.currentTick.get(); ignite = TPSUtils.currentRealTick.get();
if (activate == -1) if (activate == -1)
activate = TPSUtils.currentTick.get(); activate = TPSUtils.currentRealTick.get();
if (finishOnActive) { if (finishOnActive) {
stage = Stage.END; stage = Stage.END;
print(); print();
@ -160,14 +160,14 @@ public class Loadtimer implements Listener {
public void onTntExplode(EntityExplodeEvent event) { public void onTntExplode(EntityExplodeEvent event) {
if (region.inRegion(event.getLocation(), RegionType.BUILD, RegionExtensionType.EXTENSION) && stage == Stage.IGNITION) { if (region.inRegion(event.getLocation(), RegionType.BUILD, RegionExtensionType.EXTENSION) && stage == Stage.IGNITION) {
stage = Stage.END; stage = Stage.END;
explode = TPSUtils.currentTick.get(); explode = TPSUtils.currentRealTick.get();
print(); print();
delete(); delete();
} }
} }
private void setActivate() { private void setActivate() {
activate = TPSUtils.currentTick.get(); activate = TPSUtils.currentRealTick.get();
stage = Stage.ACTIVATED; stage = Stage.ACTIVATED;
if (finishOnActive) { if (finishOnActive) {
print(); print();

Datei anzeigen

@ -89,18 +89,18 @@ public class RedstonetesterUtils {
tick = null; tick = null;
return; return;
} }
if (TPSUtils.currentTick.get() - lastTick > 100) { if (TPSUtils.currentRealTick.get() - lastTick > 100) {
tick = null; tick = null;
} }
if (loc1.equals(location)) { if (loc1.equals(location)) {
lastTick = TPSUtils.currentTick.get(); lastTick = TPSUtils.currentRealTick.get();
if (tick == null) { if (tick == null) {
tick = TPSUtils.currentTick.get(); tick = TPSUtils.currentRealTick.get();
} }
return; return;
} }
if (tick != null && loc2.equals(location)) { 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));
} }
} }

Datei anzeigen

@ -23,7 +23,6 @@ import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.utils.bossbar.BauSystemBossbar; import de.steamwar.bausystem.utils.bossbar.BauSystemBossbar;
import de.steamwar.bausystem.utils.bossbar.BossBarService; import de.steamwar.bausystem.utils.bossbar.BossBarService;
import de.steamwar.bausystem.utils.bossbar.RegionedBossbar;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -38,13 +37,9 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockFormEvent;
import org.bukkit.event.block.BlockPistonExtendEvent; import org.bukkit.event.block.BlockPistonExtendEvent;
import org.bukkit.event.block.BlockPistonRetractEvent; 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.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntitySpawnEvent; import org.bukkit.event.entity.EntitySpawnEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
@ -57,7 +52,7 @@ public class ShieldPrinting implements Listener {
private static final World WORLD = Bukkit.getWorlds().get(0); private static final World WORLD = Bukkit.getWorlds().get(0);
static { static {
Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> { BauSystem.runTaskTimer(BauSystem.getInstance(), () -> {
ShieldPrintingCommand.SHIELD_PRINTING_MAP.values().forEach(shieldPrinting -> { ShieldPrintingCommand.SHIELD_PRINTING_MAP.values().forEach(shieldPrinting -> {
shieldPrinting.fallingBlocks.replaceAll((entity, location) -> { shieldPrinting.fallingBlocks.replaceAll((entity, location) -> {
if (entity.isDead()) return null; if (entity.isDead()) return null;

Datei anzeigen

@ -245,7 +245,7 @@ public class TNTSimulator {
}); });
AtomicInteger currentTick = new AtomicInteger(0); AtomicInteger currentTick = new AtomicInteger(0);
Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), bukkitTask -> { BauSystem.runTaskTimer(BauSystem.getInstance(), bukkitTask -> {
int tick = currentTick.get(); int tick = currentTick.get();
if (tick > maxTick.get()) bukkitTask.cancel(); if (tick > maxTick.get()) bukkitTask.cancel();
currentTick.incrementAndGet(); currentTick.incrementAndGet();

Datei anzeigen

@ -40,18 +40,18 @@ public class BlockCount {
private Region region; private Region region;
private int count = 0; private int count = 0;
private int tntCount = 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) { public BlockCount(Region region) {
this.region = region; this.region = region;
if (bukkitTask == null) { if (bukkitTask == null) {
bukkitTask = Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> { bukkitTask = BauSystem.runTaskTimer(BauSystem.getInstance(), () -> {
Set<Region> toRemove = new HashSet<>(); Set<Region> toRemove = new HashSet<>();
for (BlockCount blockCount : BlockCounter.blockCountMap.values()) { for (BlockCount blockCount : BlockCounter.blockCountMap.values()) {
if (TPSUtils.currentTick.get() - blockCount.lastUpdate < 60) { if (TPSUtils.currentRealTick.get() - blockCount.lastUpdate < 60) {
continue; continue;
} }
toRemove.add(blockCount.region); toRemove.add(blockCount.region);
@ -74,6 +74,6 @@ public class BlockCount {
public void update(List<Block> blocks) { public void update(List<Block> blocks) {
count += blocks.size(); count += blocks.size();
tntCount++; tntCount++;
lastUpdate = TPSUtils.currentTick.get(); lastUpdate = TPSUtils.currentRealTick.get();
} }
} }

Datei anzeigen

@ -31,7 +31,11 @@ public class TPSUtils {
private static long ticksSinceServerStart = 0; private static long ticksSinceServerStart = 0;
public static final Supplier<Long> currentTick = () -> ticksSinceServerStart; // This is intended as Supplier<Long> public static final Supplier<Long> currentTick = () -> ticksSinceServerStart; // This is intended as Supplier<Long>
private static long realTicksSinceServerStart = 0;
public static final Supplier<Long> currentRealTick = () -> realTicksSinceServerStart; // This is intended as Supplier<Long>
static { static {
Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> ticksSinceServerStart++, 1, 1); Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> ticksSinceServerStart++, 1, 1);
BauSystem.runTaskTimer(BauSystem.getInstance(), () -> realTicksSinceServerStart++, 1, 1);
} }
} }

Datei anzeigen

@ -32,7 +32,7 @@ import java.util.function.Supplier;
public abstract class AutoTraceRecorder implements TraceRecorder { public abstract class AutoTraceRecorder implements TraceRecorder {
protected boolean recording = false; protected boolean recording = false;
private long startTime = TPSUtils.currentTick.get(); private long startTime = TPSUtils.currentRealTick.get();
private long lastExplosion = 0; private long lastExplosion = 0;
private final Map<TNTPrimed, Record.TNTRecord> recordMap = new HashMap<>(); private final Map<TNTPrimed, Record.TNTRecord> recordMap = new HashMap<>();
@ -40,7 +40,7 @@ public abstract class AutoTraceRecorder implements TraceRecorder {
private Supplier<Record> recordSupplier; private Supplier<Record> recordSupplier;
private Record.TNTRecord getRecord(TNTPrimed tntPrimed) { 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(); protected abstract String getInactivityMessage();
@ -51,7 +51,7 @@ public abstract class AutoTraceRecorder implements TraceRecorder {
@Override @Override
public final String scoreboard(Player player) { public final String scoreboard(Player player) {
if (recording) { 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 { } else {
return BauSystem.MESSAGE.parse(getInactivityMessage(), player); return BauSystem.MESSAGE.parse(getInactivityMessage(), player);
} }
@ -59,7 +59,7 @@ public abstract class AutoTraceRecorder implements TraceRecorder {
private void startRecording() { private void startRecording() {
lastExplosion = 0; lastExplosion = 0;
startTime = TPSUtils.currentTick.get(); startTime = TPSUtils.currentRealTick.get();
record = recordSupplier.get(); record = recordSupplier.get();
recording = true; recording = true;
} }
@ -130,6 +130,6 @@ public abstract class AutoTraceRecorder implements TraceRecorder {
@Override @Override
public long scriptTime() { public long scriptTime() {
return TPSUtils.currentTick.get() - startTime; return TPSUtils.currentRealTick.get() - startTime;
} }
} }

Datei anzeigen

@ -129,7 +129,7 @@ public class Recorder implements Listener {
} }
{ {
Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> { BauSystem.runTaskTimer(BauSystem.getInstance(), () -> {
tick(); tick();
tntTraceRecorderMap.keySet() tntTraceRecorderMap.keySet()
.stream() .stream()

Datei anzeigen

@ -31,13 +31,13 @@ import java.util.function.Supplier;
public class SimpleTraceRecorder implements TraceRecorder, ActiveTracer { public class SimpleTraceRecorder implements TraceRecorder, ActiveTracer {
private final long startTime = TPSUtils.currentTick.get(); private final long startTime = TPSUtils.currentRealTick.get();
private final Map<TNTPrimed, Record.TNTRecord> recordMap = new HashMap<>(); private final Map<TNTPrimed, Record.TNTRecord> recordMap = new HashMap<>();
private Record record; private Record record;
@Override @Override
public String scoreboard(Player player) { 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 @Override
@ -51,7 +51,7 @@ public class SimpleTraceRecorder implements TraceRecorder, ActiveTracer {
} }
private Record.TNTRecord getRecord(TNTPrimed tntPrimed) { 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 @Override
@ -79,6 +79,6 @@ public class SimpleTraceRecorder implements TraceRecorder, ActiveTracer {
@Override @Override
public long scriptTime() { public long scriptTime() {
return TPSUtils.currentTick.get() - startTime; return TPSUtils.currentRealTick.get() - startTime;
} }
} }

Datei anzeigen

@ -42,7 +42,7 @@ public class StoredRecords {
private static final Map<Region, List<Record>> records = new HashMap<>(); private static final Map<Region, List<Record>> records = new HashMap<>();
static { static {
Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> { BauSystem.runTaskTimer(BauSystem.getInstance(), () -> {
replayLoops.forEach((region, playerSupplierMap) -> { replayLoops.forEach((region, playerSupplierMap) -> {
playerSupplierMap.forEach((player, integerSupplier) -> { playerSupplierMap.forEach((player, integerSupplier) -> {
int tick = integerSupplier.get(); int tick = integerSupplier.get();