Add Minecraft timings to /lag

This commit is contained in:
Shaun Bennett 2015-12-07 04:40:34 -05:00
parent 6e67f34db1
commit 4354133de9

View File

@ -5,6 +5,7 @@ import java.util.HashSet;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
@ -18,6 +19,7 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
import net.minecraft.server.v1_8_R3.MinecraftServer;
public class LagMeter extends MiniPlugin
{
@ -129,8 +131,26 @@ public class LagMeter extends MiniPlugin
}
}
private String getPrefix(double value)
{
if (value >= 18.0)
return C.cGreen;
else if (value >= 15)
return C.cYellow;
else
return C.cRed;
}
private void sendUpdate(Player player)
{
double[] tps = MinecraftServer.getServer().recentTps;
String mcString = "";
for (int i = 0; i < tps.length; i++)
{
mcString += getPrefix(tps[i]) + (double)Math.round(tps[i] * 100.0D) / 100.0D;
if (i < tps.length - 1) mcString += C.cWhite + ", ";
}
player.sendMessage(" ");
player.sendMessage(" ");
player.sendMessage(" ");
@ -138,6 +158,8 @@ public class LagMeter extends MiniPlugin
player.sendMessage(" ");
player.sendMessage(F.main(getName(), ChatColor.GRAY + "Live-------" + ChatColor.YELLOW + String.format("%.00f", _ticksPerSecond)));
player.sendMessage(F.main(getName(), ChatColor.GRAY + "Avg--------" + ChatColor.YELLOW + String.format("%.00f", _ticksPerSecondAverage * 20)));
player.sendMessage(F.main(getName(), ChatColor.YELLOW + "MC Timings"));
player.sendMessage(F.main(getName(), ChatColor.GRAY + "5m, 10m, 15m Avg---" + mcString));
player.sendMessage(F.main(getName(), ChatColor.YELLOW + "MEM"));
player.sendMessage(F.main(getName(), ChatColor.GRAY + "Free-------" + ChatColor.YELLOW + (Runtime.getRuntime().freeMemory() / 1048576) + "MB"));
player.sendMessage(F.main(getName(), ChatColor.GRAY + "Max--------" + ChatColor.YELLOW + (Runtime.getRuntime().maxMemory() / 1048576)) + "MB");