mirror of
https://github.com/PaperMC/Paper.git
synced 2025-02-16 18:31:53 +01:00
Fix TPS command output (#9091)
* Fix TPS command output * Cleanup + rebase --------- Co-authored-by: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
This commit is contained in:
parent
b0f2d4916c
commit
cec73ac951
1 changed files with 13 additions and 5 deletions
|
@ -194,12 +194,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
- sb.append( ", " );
|
||||
+ // Paper start - Further improve tick handling
|
||||
+ double[] tps = org.bukkit.Bukkit.getTPS();
|
||||
+ String[] tpsAvg = new String[tps.length];
|
||||
+ net.kyori.adventure.text.Component[] tpsAvg = new net.kyori.adventure.text.Component[tps.length];
|
||||
+
|
||||
+ for ( int i = 0; i < tps.length; i++) {
|
||||
+ tpsAvg[i] = TicksPerSecondCommand.format( tps[i] );
|
||||
+ }
|
||||
+ sender.sendMessage(net.kyori.adventure.text.Component.text("TPS from last 1m, 5m, 15m: " + org.apache.commons.lang.StringUtils.join(tpsAvg, ", "), net.kyori.adventure.text.format.NamedTextColor.GOLD));
|
||||
+
|
||||
+ net.kyori.adventure.text.TextComponent.Builder builder = net.kyori.adventure.text.Component.text();
|
||||
+ builder.append(net.kyori.adventure.text.Component.text("TPS from last 1m, 5m, 15m: ", net.kyori.adventure.text.format.NamedTextColor.GOLD));
|
||||
+ builder.append(net.kyori.adventure.text.Component.join(net.kyori.adventure.text.JoinConfiguration.commas(true), tpsAvg));
|
||||
+ sender.sendMessage(builder.asComponent());
|
||||
+ if (args.length > 0 && args[0].equals("mem") && sender.hasPermission("bukkit.command.tpsmemory")) {
|
||||
+ sender.sendMessage(net.kyori.adventure.text.Component.text()
|
||||
+ .append(net.kyori.adventure.text.Component.text("Current Memory Usage: ", net.kyori.adventure.text.format.NamedTextColor.GOLD))
|
||||
|
@ -220,10 +224,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
|
||||
- private String format(double tps)
|
||||
+ private boolean hasShownMemoryWarning; // Paper
|
||||
+ private static String format(double tps) // Paper - Made static
|
||||
+ private static net.kyori.adventure.text.Component format(double tps) // Paper - Made static
|
||||
{
|
||||
return ( ( tps > 18.0 ) ? ChatColor.GREEN : ( tps > 16.0 ) ? ChatColor.YELLOW : ChatColor.RED ).toString()
|
||||
- return ( ( tps > 18.0 ) ? ChatColor.GREEN : ( tps > 16.0 ) ? ChatColor.YELLOW : ChatColor.RED ).toString()
|
||||
- + ( ( tps > 20.0 ) ? "*" : "" ) + Math.min( Math.round( tps * 100.0 ) / 100.0, 20.0 );
|
||||
+ + ( ( 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
|
||||
+ // Paper
|
||||
+ net.kyori.adventure.text.format.TextColor color = ( ( tps > 18.0 ) ? net.kyori.adventure.text.format.NamedTextColor.GREEN : ( tps > 16.0 ) ? net.kyori.adventure.text.format.NamedTextColor.YELLOW : net.kyori.adventure.text.format.NamedTextColor.RED );
|
||||
+ String amount = Math.min(Math.round(tps * 100.0) / 100.0, 20.0) + (tps > 21.0 ? "*" : ""); // Paper - only print * at 21, we commonly peak to 20.02 as the tick sleep is not accurate enough, stop the noise
|
||||
+ return net.kyori.adventure.text.Component.text(amount, color);
|
||||
+ // Paper end
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue