SteamWar/BauSystem
Archiviert
13
0

Remove unused fields

Dieser Commit ist enthalten in:
jojo 2021-01-26 10:31:55 +01:00
Ursprung 55c5c3bda5
Commit 8bb76d656f

Datei anzeigen

@ -35,11 +35,15 @@ import org.bukkit.scheduler.BukkitTask;
public class CommandTPSLimiter implements CommandExecutor { public class CommandTPSLimiter implements CommandExecutor {
private static final World WORLD = Bukkit.getWorlds().get(0);
private static double currentTPSLimit = 20; private static double currentTPSLimit = 20;
private long lastTime = System.nanoTime(); private long lastTime = System.nanoTime();
private long currentTime = 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; private BukkitTask tpsLimiter = null;
@ -96,6 +100,10 @@ public class CommandTPSLimiter implements CommandExecutor {
} }
private void tpsLimiter() { private void tpsLimiter() {
delay = 50 * (20 / currentTPSLimit);
loops = (int)Math.ceil(delay / 50.0);
sleepDelay = (long) delay / loops;
if (currentTPSLimit == 20) { if (currentTPSLimit == 20) {
if (tpsLimiter == null) return; if (tpsLimiter == null) return;
tpsLimiter.cancel(); tpsLimiter.cancel();
@ -103,12 +111,8 @@ public class CommandTPSLimiter implements CommandExecutor {
} else { } else {
if (tpsLimiter != null) return; if (tpsLimiter != null) return;
tpsLimiter = Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), () -> { tpsLimiter = Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), () -> {
VersionedRunnable.call(new VersionedRunnable(() -> TPSLimit_12.createTickCache(world), 8), VersionedRunnable.call(new VersionedRunnable(() -> TPSLimit_12.createTickCache(WORLD), 8),
new VersionedRunnable(() -> TPSLimit_15.createTickCache(world), 14)); 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;
for (int i = 0; i < loops; i++) { for (int i = 0; i < loops; i++) {
sleepUntilNextTick(sleepDelay); sleepUntilNextTick(sleepDelay);