3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-15 12:30:06 +01:00
Paper/patches/api-unmapped/0190-Add-tick-times-API.patch
2021-06-11 14:02:28 +02: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 49bf621a2c0e5e9641b334a42b2769944c991d5d..4bae8a4387b86c868149f06b490ef6dfced2ff41 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -1590,6 +1590,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 e448ae78304974f7664b7ef18568a547833ece9f..bea7ffdb00e6de1391e9143901c62f0aceaaf727 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -1345,6 +1345,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