63 lines
2.2 KiB
Diff
63 lines
2.2 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Ivan Pekov <ivan@mrivanplays.com>
|
|
Date: Sun, 27 Sep 2020 18:30:10 +0300
|
|
Subject: [PATCH] (Sugarcane) Add last tick time API
|
|
|
|
Co-authored-by: tr7zw <tr7zw@live.de>
|
|
|
|
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 d36e4bc3c3713407704b865574cba28662f17315..2b5132582c4e3b08d3fa7a5f0e4a92e09530cdd8 100644
|
|
--- a/src/main/java/org/bukkit/Bukkit.java
|
|
+++ b/src/main/java/org/bukkit/Bukkit.java
|
|
@@ -2039,6 +2039,16 @@ public final class Bukkit {
|
|
public static boolean isStopping() {
|
|
return server.isStopping();
|
|
}
|
|
+
|
|
+ // Sugarcane start
|
|
+ @Deprecated
|
|
+ public static long getLastTickMs() {
|
|
+ return server.getLastTickMs();
|
|
+ }
|
|
+ @NotNull public static java.time.Duration getLastTickTime() {
|
|
+ return server.getLastTickTime();
|
|
+ }
|
|
+ // Sugarcane 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 24cc40453507b0da510b06b29e49b415afa6e4e8..70f210533f5e412da8a19e052ccd6978ad2d029a 100644
|
|
--- a/src/main/java/org/bukkit/Server.java
|
|
+++ b/src/main/java/org/bukkit/Server.java
|
|
@@ -1786,6 +1786,26 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
|
* @return true if server is in the process of being shutdown
|
|
*/
|
|
boolean isStopping();
|
|
+
|
|
+ // Sugarcane 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();
|
|
+ // Sugarcane end
|
|
|
|
/**
|
|
* Returns the {@link com.destroystokyo.paper.entity.ai.MobGoals} manager
|