From ab326343e6701f3c584ff05a976c597cae851c12 Mon Sep 17 00:00:00 2001 From: Rsl1122 <djrapitops@hotmail.com> Date: Tue, 27 Jun 2017 00:17:38 +0300 Subject: [PATCH] Fixed TPS math --- .../plan/data/listeners/TPSCountTimer.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/data/listeners/TPSCountTimer.java b/Plan/src/main/java/com/djrapitops/plan/data/listeners/TPSCountTimer.java index 63dc9a16a..7baf2a0f9 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/listeners/TPSCountTimer.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/listeners/TPSCountTimer.java @@ -46,13 +46,16 @@ public class TPSCountTimer extends RslBukkitRunnable<Plan> { } public TPS calculateTPS(long diff, long now) { - long expectedDiff = 1000000000L; // 1 000 000 000 ns / 1 s - long difference = diff - expectedDiff; - if (difference < 1000000) { // If less than 1 millisecond it is forgiven. - difference = 0; + if (diff < 1000000000L) { // No tick count above 20 + diff = 1000000000L; // 1 000 000 000ns = 1s } - double tpsN = 20 - ((difference / expectedDiff) * 20); int playersOnline = plugin.getServer().getOnlinePlayers().size(); + while (diff > 20000000000L) { + history.add(new TPS(now, 0, playersOnline)); + diff -= 20000000000L; + } + double tpsN = 20000000000L / diff; // 20 000 000 000ns + TPS tps = new TPS(now, tpsN, playersOnline); return tps; }