From a10a60a0de8d4710d258480b2debb5f9b60a2d4a Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 3 Apr 2021 18:00:56 +0200 Subject: [PATCH] Fix CommandTPSLimiter bug --- .../src/de/steamwar/bausystem/BauSystem.java | 1 + .../bausystem/commands/CommandTPSLimiter.java | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index de7d888..337ea4a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -157,6 +157,7 @@ public class BauSystem extends JavaPlugin implements Listener { if (autoShutdown != null) { autoShutdown.cancel(); } + CommandTPSLimiter.setTPS(20.0); autoShutdown = Bukkit.getScheduler().runTaskTimer(this, new Runnable() { int count = 0; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java index 4169f1f..a592cb6 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java @@ -40,6 +40,12 @@ import java.util.List; public class CommandTPSLimiter extends SWCommand { + private static CommandTPSLimiter instance = null; + + { + instance = this; + } + private static final World WORLD = Bukkit.getWorlds().get(0); private static double currentTPSLimit = 20; @@ -158,4 +164,11 @@ public class CommandTPSLimiter extends SWCommand { return (double) Math.round(currentTPSLimit * 10.0D) / 10.0D; } + public static void setTPS(double d) { + if (d < 0.5) d = 0.5; + if (d > (TPSUtils.isWarpAllowed() ? 40 : 20)) d = (TPSUtils.isWarpAllowed() ? 40 : 20); + currentTPSLimit = d; + instance.tpsLimiter(); + } + }