mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-11-07 17:36:07 +00:00
Add TPS command and improve the calculation of TPS (#1210)
* Add tps command * Improve tps calculation and tps command * Remove debug log line * Improve if-else statement
This commit is contained in:
parent
4fb47f20c7
commit
236e077e44
3 changed files with 47 additions and 3 deletions
25
MinecraftClient/Commands/Tps.cs
Normal file
25
MinecraftClient/Commands/Tps.cs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MinecraftClient.Commands
|
||||
{
|
||||
class Tps : Command
|
||||
{
|
||||
public override string CMDName { get { return "tps"; } }
|
||||
public override string CMDDesc { get { return "Display server current tps (tick per second). May not be accurate"; } }
|
||||
|
||||
public override string Run(McClient handler, string command, Dictionary<string, object> localVars)
|
||||
{
|
||||
var tps = Math.Round(handler.GetServerTPS(), 2);
|
||||
string color;
|
||||
if (tps < 10)
|
||||
color = "§c"; // Red
|
||||
else if (tps < 15)
|
||||
color = "§e"; // Yellow
|
||||
else color = "§a"; // Green
|
||||
return "Current tps: " + color + tps;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue