aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/api/0186-Add-tick-times-API.patch
blob: 40cbc279eb8faa3855ff5e662f8ac316dfb55c72 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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 d1e1c49ecf6a1ede71548fbac6143e38ba6dfea1..385be33869f3850f8b1d3e690c8e0fc43adcbdce 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -2170,6 +2170,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 cf242e2e6d538d3d38b7b10321ab375e018b24b1..d6d83b22389aee98967adda2631fa65ecbf00781 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -1836,6 +1836,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