Advertisement
Guest User

Untitled

a guest
Dec 15th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. package de.commandsender.listener;
  2.  
  3. public class ClearLagManager
  4. implements Runnable
  5. {
  6. public static int TICK_COUNT= 0;
  7. public static long[] TICKS= new long[600];
  8. public static long LAST_TICK= 0L;
  9.  
  10. public static double getTPS(){
  11. return getTPS(100);
  12. }
  13.  
  14. public static double getTPS(int ticks)
  15. {
  16. if (TICK_COUNT< ticks) {
  17. return 20.0D;
  18. }
  19. int target = (TICK_COUNT- 1 - ticks) % TICKS.length;
  20. long elapsed = System.currentTimeMillis() - TICKS[target];
  21.  
  22. return ticks / (elapsed / 1000.0D);
  23. }
  24.  
  25. public static long getElapsed(int tickID)
  26. {
  27. if (TICK_COUNT- tickID >= TICKS.length)
  28. {
  29. }
  30.  
  31. long time = TICKS[(tickID % TICKS.length)];
  32. return System.currentTimeMillis() - time;
  33. }
  34.  
  35. public void run()
  36. {
  37. TICKS[(TICK_COUNT% TICKS.length)] = System.currentTimeMillis();
  38.  
  39. TICK_COUNT+= 1;
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement