feat(hamster-core-bukkit): 添加 runtime 指令
This commit is contained in:
@@ -16,6 +16,7 @@ public class ParentCoreCommand extends ParentCommand {
|
|||||||
addChildCommand(YamlCommand.INSTANCE);
|
addChildCommand(YamlCommand.INSTANCE);
|
||||||
addChildCommand(InfoModeCommand.INSTANCE);
|
addChildCommand(InfoModeCommand.INSTANCE);
|
||||||
addChildCommand(ReloadCommand.INSTANCE);
|
addChildCommand(ReloadCommand.INSTANCE);
|
||||||
|
addChildCommand(RuntimeCommand.INSTANCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -0,0 +1,50 @@
|
|||||||
|
package cn.hamster3.mc.plugin.core.bukkit.command.core.sub;
|
||||||
|
|
||||||
|
import cn.hamster3.mc.plugin.core.bukkit.command.ChildCommand;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class RuntimeCommand extends ChildCommand {
|
||||||
|
public static final RuntimeCommand INSTANCE = new RuntimeCommand();
|
||||||
|
|
||||||
|
private RuntimeCommand() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull String getName() {
|
||||||
|
return "runtime";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull String getUsage() {
|
||||||
|
return "runtime";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasPermission(@NotNull CommandSender sender) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull String getDescription() {
|
||||||
|
return "查看JVM信息";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||||
|
Runtime runtime = Runtime.getRuntime();
|
||||||
|
sender.sendMessage("空闲内存:" + runtime.freeMemory() / 1024.0);
|
||||||
|
sender.sendMessage("已用内存:" + runtime.totalMemory() / 1024.0);
|
||||||
|
sender.sendMessage("最大可用内存:" + runtime.maxMemory() / 1024.0);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user