From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: William Blake Galbreath Date: Sun, 5 Apr 2020 22:22:58 -0500 Subject: [PATCH] Add tick times API diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java index 80144dc81249f7198bee5e6281362fd704e006d4..a839e8684de0c915f8b7edfe5e87978d774f7bde 100644 --- a/src/main/java/org/bukkit/Bukkit.java +++ b/src/main/java/org/bukkit/Bukkit.java @@ -2141,6 +2141,25 @@ public final class Bukkit { public static double[] getTPS() { return server.getTPS(); } + + /** + * Get a sample of the servers last tick times (in nanos) + * + * @return A sample of the servers last tick times (in nanos) + */ + @NotNull + public static long[] getTickTimes() { + return server.getTickTimes(); + } + + /** + * Get the average tick time (in millis) + * + * @return Average tick time (in millis) + */ + public static double getAverageTickTime() { + return server == null ? 0D : server.getAverageTickTime(); + } // Paper end /** diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java index 031fd20bb361fb9befe62ec8006f42156bfe2747..496e769cb77d856b4a0b4dc63ac466fdf6cbd3f9 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java @@ -1811,6 +1811,21 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi */ @NotNull public double[] getTPS(); + + /** + * Get a sample of the servers last tick times (in nanos) + * + * @return A sample of the servers last tick times (in nanos) + */ + @NotNull + long[] getTickTimes(); + + /** + * Get the average tick time (in millis) + * + * @return Average tick time (in millis) + */ + double getAverageTickTime(); // Paper end // Paper start