Move RedstoneListener.tick to TPSUtils for AutostartTime
Dieser Commit ist enthalten in:
Ursprung
8922dd440c
Commit
7b7e10d6cc
@ -21,7 +21,6 @@ package de.steamwar.bausystem.world;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
@ -45,14 +44,6 @@ import java.util.Map;
|
||||
|
||||
public class RedstoneListener implements Listener {
|
||||
|
||||
private static long currentTick = 0;
|
||||
|
||||
static {
|
||||
Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), () -> {
|
||||
currentTick++;
|
||||
}, 1, 1);
|
||||
}
|
||||
|
||||
private static class RedstoneTester {
|
||||
|
||||
private final Player player;
|
||||
@ -72,17 +63,17 @@ public class RedstoneListener implements Listener {
|
||||
return;
|
||||
}
|
||||
if (loc1.equals(location)) {
|
||||
if (currentTick - lastTick > 100) {
|
||||
if (TPSUtils.currentTick.get() - lastTick > 100) {
|
||||
tick = null;
|
||||
}
|
||||
lastTick = currentTick;
|
||||
lastTick = TPSUtils.currentTick.get();
|
||||
if (tick == null) {
|
||||
tick = currentTick;
|
||||
tick = TPSUtils.currentTick.get();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (tick != null && loc2.equals(location)) {
|
||||
player.sendMessage(BauSystem.PREFIX + "Differenz§8: §e" + (currentTick - tick) + "§8 - §7in GameTicks");
|
||||
player.sendMessage(BauSystem.PREFIX + "Differenz§8: §e" + (TPSUtils.currentTick.get() - tick) + "§8 - §7in GameTicks");
|
||||
}
|
||||
}
|
||||
|
||||
@ -115,6 +106,8 @@ public class RedstoneListener implements Listener {
|
||||
playerMap.computeIfAbsent(event.getPlayer(), RedstoneTester::new).loc2 = block.getLocation();
|
||||
sendLocation(event.getPlayer(), "POS2", block.getLocation());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,8 @@ import de.steamwar.core.TPSWatcher;
|
||||
import de.steamwar.core.VersionedRunnable;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class TPSUtils {
|
||||
|
||||
private TPSUtils() {
|
||||
@ -36,12 +38,20 @@ public class TPSUtils {
|
||||
private static long nanoOffset = 0;
|
||||
private static long nanoDOffset = 0;
|
||||
|
||||
private static long ticksSinceServerStart = 0;
|
||||
@SuppressWarnings("java:S4276")
|
||||
public static final Supplier<Long> currentTick = () -> ticksSinceServerStart;
|
||||
|
||||
public static void init() {
|
||||
VersionedRunnable.call(new VersionedRunnable(() -> warp = false, 8),
|
||||
new VersionedRunnable(() -> {
|
||||
Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), () -> nanoOffset += nanoDOffset, 1, 1);
|
||||
TPSUtils_15.init(() -> nanoOffset);
|
||||
}, 15));
|
||||
|
||||
Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), () -> {
|
||||
ticksSinceServerStart++;
|
||||
}, 1, 1);
|
||||
}
|
||||
|
||||
public static void setTPS(double tps) {
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren