From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Ivan Pekov Date: Sun, 27 Sep 2020 18:01:50 +0300 Subject: [PATCH] Add last tick time API Original code by YatopiaMC, licensed under MIT You can find the original code on https://github.com/YatopiaMC/Yatopia diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java index 840aaf9e8fc828b5a7ea02252038c6524680f2e0..994e81359154fc52392fe64cbe5f17a7a67e66c0 100644 --- a/src/main/java/org/bukkit/Bukkit.java +++ b/src/main/java/org/bukkit/Bukkit.java @@ -2410,6 +2410,16 @@ public final class Bukkit { return server.isStopping(); } + // Yatopia start + @Deprecated + public static long getLastTickMs() { + return server.getLastTickMs(); + } + @NotNull public static java.time.Duration getLastTickTime() { + return server.getLastTickTime(); + } + // Yatopia end + /** * Returns the {@link com.destroystokyo.paper.entity.ai.MobGoals} manager * diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java index 61026efa7aa6f60f3bc7f137164734bc08c1bc96..f25e6808c9ce7276c3e49c6ad03eda5ffa35e5f8 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java @@ -2107,6 +2107,26 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi */ boolean isStopping(); + // Yatopia start + /** + * Returns the time the last tick took in milliseconds. + * + * @return long time value + * @deprecated newer method with java's Duration and a possibility to convert it from millis to something else + */ + @Deprecated + default long getLastTickMs() { + return getLastTickTime().toMillis(); + } + /** + * Returns the time in {@link java.time.Duration} the last tick took. + * + * @return duration + */ + @NotNull + java.time.Duration getLastTickTime(); + // Yatopia end + /** * Returns the {@link com.destroystokyo.paper.entity.ai.MobGoals} manager *