From 27d1371e7c6579bcc83adf071b5cba53c8f7afae Mon Sep 17 00:00:00 2001 From: jojo Date: Fri, 30 Oct 2020 23:14:56 +0100 Subject: [PATCH] Fix default getTPS() limit on 20 TPS --- .../src/de/steamwar/core/TPSWatcher.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java b/SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java index a0dd0b9..b805393 100644 --- a/SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java +++ b/SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java @@ -69,6 +69,10 @@ public class TPSWatcher { return getTPS(TPSType.ONE_SECOND); } + public double getTPSUnlimited() { + return getTPS(TPSType.ONE_SECOND); + } + public double getTPS(TPSType tpsType) { switch (tpsType) { case TEN_SECONDS: @@ -85,6 +89,22 @@ public class TPSWatcher { } } + public double getTPSUnlimited(TPSType tpsType) { + switch (tpsType) { + case TEN_SECONDS: + return roundUnlimited(tps_TenSecond.tps); + case ONE_MINUTE: + return roundUnlimited(getSpigotTPS()[0]); + case FIVE_MINUTES: + return roundUnlimited(getSpigotTPS()[1]); + case TEN_MINUTES: + return roundUnlimited(getSpigotTPS()[2]); + + default: + return roundUnlimited(tps_OneSecond.tps); + } + } + private double[] getSpigotTPS() { switch (Core.getVersion()) { case 8: @@ -104,6 +124,10 @@ public class TPSWatcher { } private double round(double d) { + return Math.min(Math.round(d * 10) / 10.0, 20); + } + + private double roundUnlimited(double d) { return Math.round(d * 10) / 10.0; }