lazy implementation of a more specific os name i guess

This commit is contained in:
Chipmunk 2023-02-18 17:48:53 -05:00
parent 968632e46c
commit e90a964110

View file

@ -56,8 +56,9 @@ public class InfoCommand extends Command {
public int sendServerInfo (CommandContext<CommandSource> context) {
final CommandSource source = context.getSource();
final Runtime runtime = Runtime.getRuntime();
final OperatingSystemMXBean os = ManagementFactory.getOperatingSystemMXBean();
final RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
final RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
final MemoryMXBean memory = ManagementFactory.getMemoryMXBean();
// ? Should I send a single message that uses newlines instead?
@ -69,20 +70,26 @@ public class InfoCommand extends Command {
} catch (Exception ignored) {
}
source.sendOutput(formatEntry(Component.translatable("OS name"), Component.text(os.getName())), false);
source.sendOutput(formatEntry(Component.translatable("OS Name"), Component.text(os.getName())), false);
source.sendOutput(formatEntry(Component.translatable("OS version"), Component.text(os.getVersion())), false);
source.sendOutput(formatEntry(Component.translatable("OS architecture"), Component.text(os.getArch())), false);
source.sendOutput(formatEntry(Component.translatable("CPU cores"), Component.text(os.getAvailableProcessors())), false);
source.sendOutput(formatEntry(Component.translatable("CPU load"), Component.text(os.getSystemLoadAverage())), false);
try {
final String uname = new String(runtime.exec(new String[] {"uname", "-a"}).getInputStream().readAllBytes()).trim();
source.sendOutput(formatEntry(Component.translatable("uname -a"), Component.text(uname)), false);
} catch (IOException ignored) {
}
try {
final String cpuModel = CPUInfo.readCpuInfo().get("model name");
source.sendOutput(formatEntry(Component.translatable("CPU model"), Component.text(cpuModel)), false);
} catch (IOException ignored) {
}
source.sendOutput(formatEntry(Component.translatable("Java VM"), Component.text(runtime.getVmName())), false);
source.sendOutput(formatEntry(Component.translatable("Java version"), Component.text(runtime.getVmVersion())), false);
source.sendOutput(formatEntry(Component.translatable("Java VM"), Component.text(runtimeMXBean.getVmName())), false);
source.sendOutput(formatEntry(Component.translatable("Java version"), Component.text(runtimeMXBean.getVmVersion())), false);
source.sendOutput(formatEntry(Component.translatable("Heap memory usage"), formatMemoryUsage(memory.getHeapMemoryUsage())), false);