44 lines
1.1 KiB
Java
44 lines
1.1 KiB
Java
package cn.citycraft.CTZServer.commands;
|
|
|
|
import cn.citycraft.CTZServer.CTZServer;
|
|
import cn.citycraft.CTZServer.ServerThread;
|
|
import cn.citycraft.utils.StringUtil;
|
|
import cn.citycraft.utils.SystemUtil;
|
|
import net.md_5.bungee.api.ChatColor;
|
|
|
|
public class CommandGc extends BaseCommand {
|
|
ServerThread serverThread;
|
|
|
|
public CommandGc(ServerThread serverThread) {
|
|
super("gc", "mem");
|
|
this.serverThread = serverThread;
|
|
}
|
|
|
|
@Override
|
|
public void execute(String label, String[] args) {
|
|
Runtime rt = Runtime.getRuntime();
|
|
if (label.equalsIgnoreCase("gc"))
|
|
rt.gc();
|
|
CTZServer.print("运行时间: " + StringUtil.formatDate(SystemUtil.getRunTime()));
|
|
CTZServer.print("最大内存: " + StringUtil.b2mb(rt.maxMemory()));
|
|
CTZServer.print("使用内存: " + StringUtil.b2mb(rt.totalMemory()));
|
|
CTZServer.print("空闲内存: " + StringUtil.b2mb(rt.freeMemory()));
|
|
}
|
|
|
|
@Override
|
|
public String getDescription() {
|
|
return ChatColor.GREEN + "查看服务器内存占用";
|
|
}
|
|
|
|
@Override
|
|
public int getMinimumArguments() {
|
|
return 0;
|
|
}
|
|
|
|
@Override
|
|
public String getPossibleArguments() {
|
|
return "";
|
|
}
|
|
|
|
}
|