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 92a1462261029e804da73da2743bbd68e57841e9..89babe7bec9eee5034aada0907de8d1d805bcdfe 100644 --- a/src/main/java/org/bukkit/Bukkit.java +++ b/src/main/java/org/bukkit/Bukkit.java @@ -2397,6 +2397,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 b3421340e3cd0c091f6db2e1cb1b2f3201079a7e..7a202fb00f0f81de8c657d60a4d0fd9d3d653e58 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java @@ -2096,6 +2096,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 *