Class TickUtils

java.lang.Object
at.noahb.utils.minecraft.TickUtils

public class TickUtils extends Object
Author:
Sam (GitHub: Sam's GitHub)

Static class for listening to/getting data about tick timings.

You can check the server's average MSPT over the last 20 ticks, the server's average TPS over the last 20 ticks, and if the server is healthy. (TPS >= 19.5)
  • Constructor Details

    • TickUtils

      public TickUtils()
  • Method Details

    • init

      public static void init(org.bukkit.plugin.java.JavaPlugin parent)
      Initializes the Listener to begin tracking tick timings.
      Parameters:
      parent - The plugin to register the listener with.
    • getMSPT

      public static double getMSPT(int ticks)
      Parameters:
      ticks - The number of ticks to get the average MSPT for. Must be between 0 and 12,000, inclusive.
      Returns:
      The average MSPT of the last 20 ticks.
    • getMSPTOfLastSeconds

      public static double getMSPTOfLastSeconds(int seconds)
      Parameters:
      seconds - The number of seconds to get the average MSPT from. Numbers less than 1 will return 0 and numbers grater than 600 will only return 600 seconds worth of data.
      Returns:
      The average MSPT of the last `seconds` seconds.
    • getMSPTOfLastSecond

      public static double getMSPTOfLastSecond()
      Returns:
      The average MSPT of the last 20 ticks.
    • getMSPTOfLastMinute

      public static double getMSPTOfLastMinute()
      Returns:
      The average MSPT of the last 1,200 ticks.
    • getMSPTOfLast5Minutes

      public static double getMSPTOfLast5Minutes()
      Returns:
      The average MSPT of the last 6,000 ticks.
    • getMSPTOfLast10Minutes

      public static double getMSPTOfLast10Minutes()
      Returns:
      The average MSPT of the last 12,000 ticks.
    • getTPS

      public static double getTPS()
      Returns:
      The average TPS of the last 20 ticks.
    • isServerHealthy

      public static boolean isServerHealthy()
      Check if the server is able to keep up or if it is lagging.
      Returns:
      Whether the server TPS is healthy.