mirror of
https://github.com/YatopiaMC/Yatopia.git
synced 2024-11-26 12:45:52 +01:00
679a88af3f
* Updated Upstream and Sidestream(s) (Paper/Airplane/Purpur/Empirecraft) Upstream/An Sidestream has released updates that appears to apply and compile correctly This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing. Paper Changes: 4b78c0b80 [CI-SKIP] [Auto] Rebuild Patches 2d9ff13eb forced whitelist: use configuable kick message (fixes #5417) (#5418) 000cec2ab bug #5432 - post modern event even if legacy event is cancelled 6c83bc6e5 Remove from Map by key 857852c28 Make sure to remove correct TE during TE tick f7b4abb25 [Auto] Updated Upstream (Bukkit/CraftBukkit) Airplane Changes: 9a4bd85 Remove Multithreaded Tracker 1068498 Updated Upstream (Tuinity) Purpur Changes: 083a86e [ci-skip] Update for Toothpick changes 8b9b214 Updated Upstream (Paper & Tuinity) Empirecraft Changes: 6b5cffc2 Updated Paper * Updated Upstream and Sidestream(s) (Airplane/Purpur) Upstream/An Sidestream has released updates that appears to apply and compile correctly This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing. Airplane Changes: 3ed988c Use AIR library for configuration parsing Purpur Changes: 9631959 Add 5 sec TPS to GUI (#260) 2a0a5e6 [ci-skip] Bump Toothpick Kotlin version 02b3444 Add back multithreaded entity tracker 43b4a2f Updated Upstream (Paper & Airplane) * update gradle from 6.8.2 to 6.8.3 * fix build (hopefully) * Updated Upstream and Sidestream(s) (Paper) Upstream/An Sidestream has released updates that appears to apply and compile correctly This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing. Paper Changes: 211f8e041 Prevent light queue overfill when no players are online * well that was dumb * FINALLY it works * Updated Upstream and Sidestream(s) (Empirecraft) Upstream/An Sidestream has released updates that appears to apply and compile correctly This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing. Empirecraft Changes: 018fcff7 Updated Paper
75 lines
4.6 KiB
Diff
75 lines
4.6 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Ivan Pekov <ivan@mrivanplays.com>
|
|
Date: Sun, 27 Sep 2020 18:30:10 +0300
|
|
Subject: [PATCH] Add last tick time API
|
|
|
|
Original patch by:
|
|
Co-authored-by: tr7zw <tr7zw@live.de>
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
index f72574fde82307a0e73a9eca6c9dc967d0c48f22..8004b6068e4f9dac2cdda8300615b285b7bf16b2 100644
|
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
@@ -1055,6 +1055,8 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
|
|
// Paper End
|
|
// Spigot End
|
|
|
|
+ public static java.time.Duration lastTickTime = java.time.Duration.ZERO; // Yatopia
|
|
+
|
|
protected void w() {
|
|
try {
|
|
long serverStartTime = SystemUtils.getMonotonicNanos(); // Paper
|
|
@@ -1126,7 +1128,9 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
|
|
this.a(gameprofilertick);
|
|
this.methodProfiler.a();
|
|
this.methodProfiler.enter("tick");
|
|
+ long tickStart = System.nanoTime(); // Yatopia
|
|
this.a(this::canSleepForTick);
|
|
+ lastTickTime = java.time.Duration.ofNanos(System.nanoTime() - tickStart); // Yatopia
|
|
this.methodProfiler.exitEnter("nextTickWait");
|
|
this.X = true;
|
|
// Purpur start - tps catchup
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
index 7771fa5c98809b6c3aeff78ab9d0b8ec2178accc..449fce2d76c701b789dd09326c9a8fc818b39c45 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
@@ -2540,4 +2540,6 @@ public final class CraftServer implements Server {
|
|
return getServer().lagging;
|
|
}
|
|
// Purpur end
|
|
+
|
|
+ @Override public java.time.Duration getLastTickTime() { return net.minecraft.server.MinecraftServer.lastTickTime; } // Yatopia
|
|
}
|
|
diff --git a/src/main/java/org/spigotmc/TicksPerSecondCommand.java b/src/main/java/org/spigotmc/TicksPerSecondCommand.java
|
|
index 312248b5c6febc6a3c10940714fac7fbc3c53b7f..abc9b7aa53e554ef2196dceafe8db8ba65f34e84 100644
|
|
--- a/src/main/java/org/spigotmc/TicksPerSecondCommand.java
|
|
+++ b/src/main/java/org/spigotmc/TicksPerSecondCommand.java
|
|
@@ -32,6 +32,10 @@ public class TicksPerSecondCommand extends Command
|
|
tpsAvg[i] = format( tps[i] );
|
|
}
|
|
sender.sendMessage(ChatColor.GOLD + "TPS from last 5s, 1m, 5m, 15m: " + org.apache.commons.lang.StringUtils.join(tpsAvg, ", ")); // Purpur
|
|
+ // Yatopia start
|
|
+ java.time.Duration lastTickTime = org.bukkit.Bukkit.getLastTickTime();
|
|
+ sender.sendMessage(ChatColor.GOLD + "Last tick: " + formatTo( lastTickTime, java.util.concurrent.TimeUnit.MILLISECONDS ) + " (" + formatTo( lastTickTime, java.util.concurrent.TimeUnit.NANOSECONDS ) + ")");
|
|
+ // Yatopia end
|
|
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) {
|
|
@@ -50,4 +54,16 @@ public class TicksPerSecondCommand extends Command
|
|
return ( ( tps > 18.0 ) ? ChatColor.GREEN : ( tps > 16.0 ) ? ChatColor.YELLOW : ChatColor.RED ).toString()
|
|
+ ( ( tps > 21.0 ) ? "*" : "" ) + Math.min( Math.round( tps * 100.0 ) / 100.0, 20.0 ); // Paper - only print * at 21, we commonly peak to 20.02 as the tick sleep is not accurate enough, stop the noise
|
|
}
|
|
+
|
|
+ // Yatopia start
|
|
+ public static String formatTo(java.time.Duration duration, java.util.concurrent.TimeUnit unit)
|
|
+ {
|
|
+ java.util.concurrent.TimeUnit nanosUnit = java.util.concurrent.TimeUnit.NANOSECONDS;
|
|
+ long nanos = duration.toNanos();
|
|
+ long toAskedUnit = unit.convert( nanos, nanosUnit );
|
|
+ long ms = nanosUnit.toMillis( nanos );
|
|
+ ChatColor startingColor = ms < 40 ? ChatColor.GREEN : ( ms < 50 ) ? ChatColor.YELLOW : ChatColor.RED;
|
|
+ return startingColor.toString() + toAskedUnit + ChatColor.GOLD + org.yatopiamc.yatopia.server.util.TimeUtils.getFriendlyName( unit );
|
|
+ }
|
|
+ // Yatopia end
|
|
}
|