From c694d5f1033ac65d0e6cc3ed93b57015037aeebd Mon Sep 17 00:00:00 2001 From: jojo Date: Mon, 8 Feb 2021 17:53:28 +0100 Subject: [PATCH 1/2] Add TPSWatcher.getTPSLimited --- SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java b/SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java index 314f246..e900586 100644 --- a/SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java +++ b/SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java @@ -29,7 +29,7 @@ public class TPSWatcher { private static final TPSWatcher tps_TenSecond = new TPSWatcher(10000); private long lastTime = System.currentTimeMillis(); - private double tps = 20.0; + private double tps = TICK_DEFAULT; private TPSWatcher(long timeInterval) { Bukkit.getScheduler().runTaskTimer(Core.getInstance(), () -> { @@ -46,12 +46,20 @@ public class TPSWatcher { return getTPS(TPSType.ONE_SECOND); } + public static double getTPSLimited(double limit) { + return getTPSLimited(TPSType.ONE_SECOND, limit); + } + public static double getTPSUnlimited() { return getTPSUnlimited(TPSType.ONE_SECOND); } + public static double getTPSLimited(TPSType tpsType, double limit) { + return Math.min(getTPSUnlimited(tpsType), limit); + } + public static double getTPS(TPSType tpsType) { - return Math.min(getTPSUnlimited(tpsType), 20.0); + return Math.min(getTPSUnlimited(tpsType), TICK_DEFAULT); } public static double getTPSUnlimited(TPSType tpsType) { From e28d4af9de12819c3aa1fc396329a2e0f48e1898 Mon Sep 17 00:00:00 2001 From: jojo Date: Mon, 8 Feb 2021 18:00:01 +0100 Subject: [PATCH 2/2] Simplify TPSWatcher --- SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java b/SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java index e900586..cb92fcf 100644 --- a/SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java +++ b/SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java @@ -46,20 +46,20 @@ public class TPSWatcher { return getTPS(TPSType.ONE_SECOND); } - public static double getTPSLimited(double limit) { - return getTPSLimited(TPSType.ONE_SECOND, limit); + public static double getTPS(double limit) { + return getTPS(TPSType.ONE_SECOND, limit); } public static double getTPSUnlimited() { return getTPSUnlimited(TPSType.ONE_SECOND); } - public static double getTPSLimited(TPSType tpsType, double limit) { - return Math.min(getTPSUnlimited(tpsType), limit); + public static double getTPS(TPSType tpsType) { + return getTPS(tpsType, TICK_DEFAULT); } - public static double getTPS(TPSType tpsType) { - return Math.min(getTPSUnlimited(tpsType), TICK_DEFAULT); + public static double getTPS(TPSType tpsType, double limit) { + return Math.min(getTPSUnlimited(tpsType), limit); } public static double getTPSUnlimited(TPSType tpsType) {