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 5a74cce889b1c41701e862f854b3c45f4970828c..17c38075b1ac435d2f4446e759548a744e657eed 100644 --- a/src/main/java/org/bukkit/Bukkit.java +++ b/src/main/java/org/bukkit/Bukkit.java @@ -1614,6 +1614,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 cadea9bc73eeb15be32505709caf0e9a99c04967..5cfb1905a5e4b8812aa7128ebdab9ac32644bfa4 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java @@ -1365,6 +1365,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