/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package me.vaqxine.NetworkManager.tasks;
/**
*
* @author devan_000
*/
public class TPSTask implements Runnable {
public static int TICK_COUNT = 0;
public static long[] TICKS = new long[600];
public static long LAST_TICK = 0L;
public static double getTPS() {
return getTPS(100);
}
public static double getTPS(int ticks) {
if (TICK_COUNT < ticks) {
return 20.0D;
}
int target = (TICK_COUNT - 1 - ticks) % TICKS.length;
long elapsed = System.currentTimeMillis() - TICKS[target];
return ticks / (elapsed / 1000.0D);
}
public static long getElapsed(int tickID) {
if (TICK_COUNT - tickID >= TICKS.length) {
}
long time = TICKS[(tickID % TICKS.length)];
return System.currentTimeMillis() - time;
}
public void run() {
TICKS[(TICK_COUNT % TICKS.length)] = System.currentTimeMillis();
TICK_COUNT += 1;
}
}