Paper/patches/api/0180-Add-tick-times-API.patch
2024-06-14 14:07:44 -07:00

63 Zeilen
1.9 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
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 21f7d4c0e62058df9e8e0d37886e24649a7fab67..b9b4a7574763b0a22d1f6faf6170eb127d488b18 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -2191,6 +2191,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 5889209e9855d26f07d4cb4b8f9d448fd31e4c87..d52c81212187a1aea1e666ba2f16bbf273a23594 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -1856,6 +1856,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