Files
MiraiMC/patches/api/0005-Sugarcane-Add-last-tick-time-API.patch
2021-10-11 22:08:41 +02:00

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 a4fd6f6e51c478efa9b125d3878c246b5f762999..813ec2b8008c9e454f9884654feff05bd1c5a68b 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -2080,6 +2080,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 b6f0d1e67bb4599a603ff7ea7adffdba07759c3f..81e76ebe63fed051c67a6b44495c8bb013c681e8 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -1822,6 +1822,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