SteamWar/SpigotCore
Archiviert
13
0

Fix TPSWatcher for 10 seconds

Dieser Commit ist enthalten in:
jojo 2020-10-04 18:18:55 +02:00
Ursprung bb2bf2577e
Commit 599755a527

Datei anzeigen

@ -23,7 +23,6 @@ import org.bukkit.Bukkit;
public class TPSWatcher { public class TPSWatcher {
private static final double tickTimeDefault = 1000;
private static final double tickDefault = 20.0; private static final double tickDefault = 20.0;
private static TPSWatcher tps_OneSecond = new TPSWatcher(1000); private static TPSWatcher tps_OneSecond = new TPSWatcher(1000);
@ -34,20 +33,19 @@ public class TPSWatcher {
private double tps = 20.0; private double tps = 20.0;
private TPSWatcher(long timeInterval) { private TPSWatcher(long timeInterval) {
timeInterval = timeInterval / 50;
Bukkit.getScheduler().runTaskTimer(Core.getInstance(), () -> { Bukkit.getScheduler().runTaskTimer(Core.getInstance(), () -> {
long tickTime = System.currentTimeMillis() - lastTime; long tickTime = System.currentTimeMillis() - lastTime;
lastTime = System.currentTimeMillis(); lastTime = System.currentTimeMillis();
double now = 0; double now = 0;
if (tickTime != 0) { if (tickTime != 0) {
now = (tickTimeDefault / tickTime) * tickDefault; now = (timeInterval / (double) tickTime) * tickDefault;
} }
if (now < 0) { if (now < 0) {
now = 0; now = 0;
} }
tps = now; tps = now;
}, timeInterval, timeInterval); }, timeInterval / 50, timeInterval / 50);
} }
public enum TPSType { public enum TPSType {