mirror of
https://github.com/YatopiaMC/Yatopia.git
synced 2024-11-22 10:35:42 +01:00
Add getLastTickMs() api
This commit is contained in:
parent
5d9f3c437d
commit
ae0c3c0c84
52
patches/api/0032-Add-getLastTickMs-api.patch
Normal file
52
patches/api/0032-Add-getLastTickMs-api.patch
Normal file
@ -0,0 +1,52 @@
|
||||
From 8ad98f5fbf4542b3cb48d754448ff847bd45bab0 Mon Sep 17 00:00:00 2001
|
||||
From: tr7zw <tr7zw@live.de>
|
||||
Date: Thu, 5 Mar 2020 21:13:14 +0100
|
||||
Subject: [PATCH] Add getLastTickMs() api
|
||||
|
||||
---
|
||||
src/main/java/org/bukkit/Bukkit.java | 8 ++++++++
|
||||
src/main/java/org/bukkit/Server.java | 11 +++++++++++
|
||||
2 files changed, 19 insertions(+)
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
|
||||
index 355bd2e2..f603f99f 100644
|
||||
--- a/src/main/java/org/bukkit/Bukkit.java
|
||||
+++ b/src/main/java/org/bukkit/Bukkit.java
|
||||
@@ -1618,6 +1618,14 @@ public final class Bukkit {
|
||||
return server.getCurrentTick();
|
||||
}
|
||||
// Paper end
|
||||
+
|
||||
+ // YAPFA start
|
||||
+
|
||||
+ public static long getLastTickMs() {
|
||||
+ return server.getLastTickMs();
|
||||
+ }
|
||||
+
|
||||
+ // YAPFA end
|
||||
|
||||
@NotNull
|
||||
public static Server.Spigot spigot() {
|
||||
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
||||
index 98e7ba90..7cebe608 100644
|
||||
--- a/src/main/java/org/bukkit/Server.java
|
||||
+++ b/src/main/java/org/bukkit/Server.java
|
||||
@@ -1416,4 +1416,15 @@ public interface Server extends PluginMessageRecipient {
|
||||
*/
|
||||
int getCurrentTick();
|
||||
// Paper end
|
||||
+
|
||||
+ // YAPFA start
|
||||
+
|
||||
+ /**
|
||||
+ * Get the ms the last servertick took
|
||||
+ *
|
||||
+ * @return Last ticks ms
|
||||
+ */
|
||||
+ long getLastTickMs();
|
||||
+
|
||||
+ // YAPFA end
|
||||
}
|
||||
--
|
||||
2.25.1.windows.1
|
||||
|
80
patches/server/0042-Add-getLastTickMs-api.patch
Normal file
80
patches/server/0042-Add-getLastTickMs-api.patch
Normal file
@ -0,0 +1,80 @@
|
||||
From 90e8bcd5384daf77b5d94744e1f40fbaf71526e5 Mon Sep 17 00:00:00 2001
|
||||
From: tr7zw <tr7zw@live.de>
|
||||
Date: Thu, 5 Mar 2020 21:13:33 +0100
|
||||
Subject: [PATCH] Add getLastTickMs() api
|
||||
|
||||
---
|
||||
src/main/java/net/minecraft/server/MinecraftServer.java | 7 +++++++
|
||||
src/main/java/org/bukkit/craftbukkit/CraftServer.java | 9 +++++++++
|
||||
src/main/java/org/spigotmc/TicksPerSecondCommand.java | 2 +-
|
||||
3 files changed, 17 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index 6ea3833fc..d5efea027 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -886,6 +886,8 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
|
||||
private static final java.math.BigDecimal TPS_BASE = new java.math.BigDecimal(1E9).multiply(new java.math.BigDecimal(SAMPLE_INTERVAL));
|
||||
// Paper End
|
||||
// Spigot End
|
||||
+
|
||||
+ public static long lastTickMs = 0; // YAPFA
|
||||
|
||||
public void run() {
|
||||
try {
|
||||
@@ -936,9 +938,13 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
|
||||
this.methodProfiler.d().d();
|
||||
}
|
||||
|
||||
+
|
||||
+
|
||||
this.methodProfiler.a();
|
||||
this.methodProfiler.enter("tick");
|
||||
+ long tickStart = System.currentTimeMillis(); // YAPFA
|
||||
this.a(this::canSleepForTick);
|
||||
+ lastTickMs = System.currentTimeMillis() - tickStart; // YAPFA
|
||||
this.methodProfiler.exitEnter("nextTickWait");
|
||||
this.ac = true;
|
||||
this.ab = Math.max(SystemUtils.getMonotonicMillis() + 50L, this.nextTick);
|
||||
@@ -946,6 +952,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
|
||||
this.methodProfiler.exit();
|
||||
this.methodProfiler.b();
|
||||
this.hasTicked = true;
|
||||
+
|
||||
}
|
||||
} else {
|
||||
this.a((CrashReport) null);
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index 19b74f3ca..e9c5bb9dd 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -2189,4 +2189,13 @@ public final class CraftServer implements Server {
|
||||
return net.minecraft.server.MinecraftServer.currentTick;
|
||||
}
|
||||
// Paper end
|
||||
+
|
||||
+ // YAPFA start
|
||||
+
|
||||
+ @Override
|
||||
+ public long getLastTickMs() {
|
||||
+ return net.minecraft.server.MinecraftServer.lastTickMs;
|
||||
+ }
|
||||
+
|
||||
+ // YAPFA end
|
||||
}
|
||||
diff --git a/src/main/java/org/spigotmc/TicksPerSecondCommand.java b/src/main/java/org/spigotmc/TicksPerSecondCommand.java
|
||||
index 6d21c3269..ce23b407d 100644
|
||||
--- a/src/main/java/org/spigotmc/TicksPerSecondCommand.java
|
||||
+++ b/src/main/java/org/spigotmc/TicksPerSecondCommand.java
|
||||
@@ -30,7 +30,7 @@ public class TicksPerSecondCommand extends Command
|
||||
for ( int i = 0; i < tps.length; i++) {
|
||||
tpsAvg[i] = format( tps[i] );
|
||||
}
|
||||
- sender.sendMessage( ChatColor.GOLD + "TPS from last 1m, 5m, 15m: " + org.apache.commons.lang.StringUtils.join(tpsAvg, ", "));
|
||||
+ sender.sendMessage( ChatColor.GOLD + "TPS from last 1m, 5m, 15m: " + org.apache.commons.lang.StringUtils.join(tpsAvg, ", ") + " Last tick time: " + org.bukkit.Bukkit.getLastTickMs() + "ms"); // YAPFA
|
||||
// Paper end
|
||||
|
||||
return true;
|
||||
--
|
||||
2.25.1.windows.1
|
||||
|
Loading…
Reference in New Issue
Block a user