mirror of
https://github.com/YatopiaMC/Yatopia.git
synced 2024-08-24 23:03:00 +02:00
69 lines
3.8 KiB
Diff
69 lines
3.8 KiB
Diff
From 0000000000000000000000000000000000000000 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
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
index 6949761d8b1b07f49accb47d78840fd801a83b88..ca166e498c188a5f4dc979de475d827c6d75361b 100644
|
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
@@ -933,6 +933,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
|
|
|
|
protected void v() {
|
|
try {
|
|
@@ -997,7 +999,9 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
|
|
this.a(gameprofilertick);
|
|
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.X = true;
|
|
this.W = Math.max(SystemUtils.getMonotonicMillis() + 50L, this.nextTick);
|
|
@@ -1006,6 +1010,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
|
|
this.methodProfiler.b();
|
|
this.b(gameprofilertick);
|
|
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 c29002ac45f007db9eb4d0609b9b4b97a8dc199a..b0dff61d1bb03d7699b345277d49bc3ebaded9e0 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
@@ -2381,4 +2381,13 @@ public final class CraftServer implements Server {
|
|
return mobGoals;
|
|
}
|
|
// 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 7218f23df4d06ff1ca612286e4a404246389ab18..a4f6df8606b0a96803f9917dc831148ea6f5bb0c 100644
|
|
--- a/src/main/java/org/spigotmc/TicksPerSecondCommand.java
|
|
+++ b/src/main/java/org/spigotmc/TicksPerSecondCommand.java
|
|
@@ -33,7 +33,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
|
|
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) {
|