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 683c9dc0f183cdee8dd909835c0cb0fe9b033075..2d73a06dc6b6a5163696750cb563d52e327ab4d1 100644 --- a/src/main/java/org/bukkit/Bukkit.java +++ b/src/main/java/org/bukkit/Bukkit.java @@ -1464,6 +1464,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 af9f834f468cefbb72f798d63b9eb7b10811ed9f..a15e672be066cef7828a8e0c5b09209d8c268181 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java @@ -1232,6 +1232,21 @@ public interface Server extends PluginMessageRecipient { */ @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