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 e32094b8e7710158f75450c477c91110d83ba71b..82940fa20f5f958e6473f318ee2c5da3647e0228 100644 --- a/src/main/java/org/bukkit/Bukkit.java +++ b/src/main/java/org/bukkit/Bukkit.java @@ -1980,6 +1980,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 fc8a6468c61a84a1fe719505adb274d48e24e8f4..ffd1f47690083b40aa349ed0f92d6fc2fdc56609 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java @@ -1673,6 +1673,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