2020-04-11 15:47:44 +02:00
|
|
|
From 4982075f1218213d9c347e80638ada92db49e86c Mon Sep 17 00:00:00 2001
|
2020-03-05 21:14:17 +01:00
|
|
|
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
|
2020-04-11 15:47:44 +02:00
|
|
|
index 20e318396..a68c91686 100644
|
2020-03-05 21:14:17 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
2020-04-11 15:47:44 +02:00
|
|
|
@@ -888,6 +888,8 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
|
2020-03-05 21:14:17 +01:00
|
|
|
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 {
|
2020-04-11 15:47:44 +02:00
|
|
|
@@ -939,9 +941,13 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
|
2020-03-05 21:14:17 +01:00
|
|
|
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);
|
2020-04-11 15:47:44 +02:00
|
|
|
@@ -949,6 +955,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
|
2020-03-05 21:14:17 +01:00
|
|
|
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
|
2020-04-11 15:47:44 +02:00
|
|
|
index f48c69e0e..6382f2e8f 100644
|
2020-03-05 21:14:17 +01:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
2020-04-11 15:47:44 +02:00
|
|
|
@@ -2237,4 +2237,13 @@ public final class CraftServer implements Server {
|
|
|
|
return !net.minecraft.server.MinecraftServer.getServer().isRunning();
|
2020-03-05 21:14:17 +01:00
|
|
|
}
|
|
|
|
// 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
|
2020-03-22 16:40:40 +01:00
|
|
|
index 6d21c3269..ce23b407d 100644
|
2020-03-05 21:14:17 +01:00
|
|
|
--- 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
|
|
|
|
|