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 4a45ae0ebedb1b45c7167a8a8b9a79797302eea8..9a5888032602616996a27aa93dbe3b89356acd05 100644 --- a/src/main/java/org/bukkit/Bukkit.java +++ b/src/main/java/org/bukkit/Bukkit.java @@ -1671,6 +1671,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 de0bf2b6b4ca4cc5ca3f53fb195db9fcd8000894..685b4af3a0a041c4c65e3435f42ab83d2feb5d4e 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java @@ -1418,6 +1418,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