mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-19 15:09:25 +00:00
71 lines
4.5 KiB
Diff
71 lines
4.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
|
Date: Sat, 26 Nov 2022 21:02:58 +0100
|
|
Subject: [PATCH] Show last tick time in /tps command
|
|
|
|
License: MIT (https://opensource.org/licenses/MIT)
|
|
Gale - https://galemc.org
|
|
|
|
This patch is based on the following patch:
|
|
"Add getLastTickMs api"
|
|
By: tr7zw <tr7zw@live.de>
|
|
As part of: YAPFA (https://github.com/tr7zw/YAPFA)
|
|
Licensed under: MIT (https://opensource.org/licenses/MIT)
|
|
|
|
* YAPFA copyright *
|
|
|
|
Copyright 2020 tr7zw
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
|
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
diff --git a/src/main/java/org/spigotmc/TicksPerSecondCommand.java b/src/main/java/org/spigotmc/TicksPerSecondCommand.java
|
|
index d336b27ee314366fe44760db6fdb68370ab3995a..e1532490b14d15fd5687f242137d470d5b82ea12 100644
|
|
--- a/src/main/java/org/spigotmc/TicksPerSecondCommand.java
|
|
+++ b/src/main/java/org/spigotmc/TicksPerSecondCommand.java
|
|
@@ -46,6 +46,24 @@ public class TicksPerSecondCommand extends Command {
|
|
builder.append(text("TPS from last 5s, 1m, 5m, 15m: ", NamedTextColor.GOLD)); // Gale - Purpur - 5 second TPS average
|
|
builder.append(Component.join(JoinConfiguration.commas(true), tpsAvg));
|
|
sender.sendMessage(builder.asComponent());
|
|
+ // Gale start - YAPFA - last tick time - in TPS command
|
|
+ if (org.galemc.gale.configuration.GaleGlobalConfiguration.get().misc.lastTickTimeInTpsCommand.enabled) {
|
|
+ long lastTickProperTime = net.minecraft.server.MinecraftServer.lastTickProperTime;
|
|
+ long lastTickOversleepTime = net.minecraft.server.MinecraftServer.lastTickOversleepTime;
|
|
+ var lastTickTimeMessage = text("Last tick: ")
|
|
+ .append(formatTickTimeDuration(lastTickProperTime, 44, 50, 51));
|
|
+
|
|
+ if (org.galemc.gale.configuration.GaleGlobalConfiguration.get().misc.lastTickTimeInTpsCommand.addOversleep) {
|
|
+ lastTickTimeMessage = lastTickTimeMessage.append(text(" self + "))
|
|
+ .append(formatTickTimeDuration(lastTickOversleepTime, Math.max(1, 51 - lastTickProperTime), Math.max(2, 52 - lastTickProperTime), Math.max(3, 53 - lastTickProperTime)))
|
|
+ .append(text(" oversleep = "))
|
|
+ .append(formatTickTimeDuration(lastTickProperTime + lastTickOversleepTime, 51, 52, 53));
|
|
+ }
|
|
+
|
|
+ lastTickTimeMessage = lastTickTimeMessage.color(NamedTextColor.GOLD);
|
|
+ sender.sendMessage(lastTickTimeMessage);
|
|
+ }
|
|
+ // Gale end - YAPFA - last tick time - in TPS command
|
|
if (args.length > 0 && args[0].equals("mem") && sender.hasPermission("bukkit.command.tpsmemory")) {
|
|
sender.sendMessage(text()
|
|
.append(text("Current Memory Usage: ", NamedTextColor.GOLD))
|
|
@@ -68,4 +86,16 @@ public class TicksPerSecondCommand extends Command {
|
|
return text(amount, color);
|
|
// Paper end
|
|
}
|
|
+
|
|
+ // Gale start - YAPFA - last tick time - in TPS command
|
|
+ private static final TextColor safeColor = NamedTextColor.GREEN;
|
|
+ private static final TextColor closeColor = NamedTextColor.YELLOW;
|
|
+ private static final TextColor problematicColor = TextColor.color(0xf77c1e);
|
|
+ private static final TextColor severeColor = NamedTextColor.RED;
|
|
+
|
|
+ private static Component formatTickTimeDuration(long ms, long safeLimit, long closeLimit, long nonSevereLimit) {
|
|
+ return text(ms + " ", ms <= safeLimit ? safeColor : ms <= closeLimit ? closeColor : ms <= nonSevereLimit ? problematicColor : severeColor)
|
|
+ .append(text("ms", NamedTextColor.GOLD));
|
|
+ }
|
|
+ // Gale end - YAPFA - last tick time - in TPS command
|
|
}
|