From 8bb76d656fc9a6394da756f9b2a4198ec054615b Mon Sep 17 00:00:00 2001 From: jojo Date: Tue, 26 Jan 2021 10:31:55 +0100 Subject: [PATCH] Remove unused fields --- .../bausystem/commands/CommandTPSLimiter.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java index 0b9f4d7..97cee3a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java @@ -35,11 +35,15 @@ import org.bukkit.scheduler.BukkitTask; public class CommandTPSLimiter implements CommandExecutor { + private static final World WORLD = Bukkit.getWorlds().get(0); private static double currentTPSLimit = 20; + private long lastTime = System.nanoTime(); private long currentTime = System.nanoTime(); - private static World world = Bukkit.getWorlds().get(0); + private double delay = 0; + private int loops = 0; + private long sleepDelay = 0; private BukkitTask tpsLimiter = null; @@ -96,6 +100,10 @@ public class CommandTPSLimiter implements CommandExecutor { } private void tpsLimiter() { + delay = 50 * (20 / currentTPSLimit); + loops = (int)Math.ceil(delay / 50.0); + sleepDelay = (long) delay / loops; + if (currentTPSLimit == 20) { if (tpsLimiter == null) return; tpsLimiter.cancel(); @@ -103,12 +111,8 @@ public class CommandTPSLimiter implements CommandExecutor { } else { if (tpsLimiter != null) return; tpsLimiter = Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), () -> { - VersionedRunnable.call(new VersionedRunnable(() -> TPSLimit_12.createTickCache(world), 8), - new VersionedRunnable(() -> TPSLimit_15.createTickCache(world), 14)); - - double delay = 50 * (20 / currentTPSLimit); - int loops = (int)Math.ceil(delay / 50.0); - long sleepDelay = (long) delay / loops; + VersionedRunnable.call(new VersionedRunnable(() -> TPSLimit_12.createTickCache(WORLD), 8), + new VersionedRunnable(() -> TPSLimit_15.createTickCache(WORLD), 14)); for (int i = 0; i < loops; i++) { sleepUntilNextTick(sleepDelay);