2020-07-05 16:50:40 +02:00
|
|
|
From 264d5684617fdf1410e4409c7a6df21833d26dc0 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
|
|
|
|
|
|
|
|
---
|
2020-06-27 15:45:01 +02:00
|
|
|
src/main/java/net/minecraft/server/MinecraftServer.java | 5 +++++
|
2020-03-05 21:14:17 +01:00
|
|
|
src/main/java/org/bukkit/craftbukkit/CraftServer.java | 9 +++++++++
|
|
|
|
src/main/java/org/spigotmc/TicksPerSecondCommand.java | 2 +-
|
2020-06-27 15:45:01 +02:00
|
|
|
3 files changed, 15 insertions(+), 1 deletion(-)
|
2020-03-05 21:14:17 +01:00
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
2020-07-02 22:37:50 +02:00
|
|
|
index 6949761d8b..ca166e498c 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-06-27 15:45:01 +02:00
|
|
|
@@ -933,6 +933,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
|
|
|
|
|
2020-06-27 15:45:01 +02:00
|
|
|
protected void v() {
|
2020-04-27 00:29:45 +02:00
|
|
|
try {
|
2020-06-27 15:45:01 +02:00
|
|
|
@@ -997,7 +999,9 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
|
|
|
|
this.a(gameprofilertick);
|
2020-03-05 21:14:17 +01:00
|
|
|
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");
|
2020-06-27 15:45:01 +02:00
|
|
|
this.X = true;
|
|
|
|
this.W = Math.max(SystemUtils.getMonotonicMillis() + 50L, this.nextTick);
|
|
|
|
@@ -1006,6 +1010,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
|
2020-03-05 21:14:17 +01:00
|
|
|
this.methodProfiler.b();
|
2020-06-27 15:45:01 +02:00
|
|
|
this.b(gameprofilertick);
|
2020-03-05 21:14:17 +01:00
|
|
|
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-07-05 16:50:40 +02:00
|
|
|
index c29002ac45..b0dff61d1b 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-07-05 16:50:40 +02:00
|
|
|
@@ -2381,4 +2381,13 @@ public final class CraftServer implements Server {
|
2020-05-07 16:59:29 +02:00
|
|
|
return mobGoals;
|
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-06-30 16:39:06 +02:00
|
|
|
index 7218f23df4..a4f6df8606 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
|
2020-06-28 15:31:41 +02:00
|
|
|
@@ -33,7 +33,7 @@ public class TicksPerSecondCommand extends Command
|
2020-03-05 21:14:17 +01:00
|
|
|
for ( int i = 0; i < tps.length; i++) {
|
|
|
|
tpsAvg[i] = format( tps[i] );
|
|
|
|
}
|
2020-06-28 15:31:41 +02:00
|
|
|
- sender.sendMessage(ChatColor.GOLD + "TPS from last 1m, 5m, 15m: " + org.apache.commons.lang.StringUtils.join(tpsAvg, ", "));
|
2020-03-05 21:14:17 +01:00
|
|
|
+ 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
|
2020-06-30 16:39:06 +02:00
|
|
|
if (args.length > 0 && args[0].equals("mem") && sender.hasPermission("bukkit.command.tpsmemory")) {
|
|
|
|
sender.sendMessage(ChatColor.GOLD + "Current Memory Usage: " + ChatColor.GREEN + ((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / (1024 * 1024)) + "/" + (Runtime.getRuntime().totalMemory() / (1024 * 1024)) + " mb (Max: " + (Runtime.getRuntime().maxMemory() / (1024 * 1024)) + " mb)");
|
|
|
|
if (!hasShownMemoryWarning) {
|
2020-03-05 21:14:17 +01:00
|
|
|
--
|
|
|
|
2.25.1.windows.1
|
|
|
|
|