lazy implementation of a more specific os name i guess
This commit is contained in:
parent
968632e46c
commit
e90a964110
1 changed files with 11 additions and 4 deletions
|
@ -56,8 +56,9 @@ public class InfoCommand extends Command {
|
||||||
public int sendServerInfo (CommandContext<CommandSource> context) {
|
public int sendServerInfo (CommandContext<CommandSource> context) {
|
||||||
final CommandSource source = context.getSource();
|
final CommandSource source = context.getSource();
|
||||||
|
|
||||||
|
final Runtime runtime = Runtime.getRuntime();
|
||||||
final OperatingSystemMXBean os = ManagementFactory.getOperatingSystemMXBean();
|
final OperatingSystemMXBean os = ManagementFactory.getOperatingSystemMXBean();
|
||||||
final RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
|
final RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
|
||||||
final MemoryMXBean memory = ManagementFactory.getMemoryMXBean();
|
final MemoryMXBean memory = ManagementFactory.getMemoryMXBean();
|
||||||
|
|
||||||
// ? Should I send a single message that uses newlines instead?
|
// ? Should I send a single message that uses newlines instead?
|
||||||
|
@ -69,20 +70,26 @@ public class InfoCommand extends Command {
|
||||||
} catch (Exception ignored) {
|
} 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 version"), Component.text(os.getVersion())), false);
|
||||||
source.sendOutput(formatEntry(Component.translatable("OS architecture"), Component.text(os.getArch())), 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 cores"), Component.text(os.getAvailableProcessors())), false);
|
||||||
source.sendOutput(formatEntry(Component.translatable("CPU load"), Component.text(os.getSystemLoadAverage())), 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 {
|
try {
|
||||||
final String cpuModel = CPUInfo.readCpuInfo().get("model name");
|
final String cpuModel = CPUInfo.readCpuInfo().get("model name");
|
||||||
source.sendOutput(formatEntry(Component.translatable("CPU model"), Component.text(cpuModel)), false);
|
source.sendOutput(formatEntry(Component.translatable("CPU model"), Component.text(cpuModel)), false);
|
||||||
} catch (IOException ignored) {
|
} catch (IOException ignored) {
|
||||||
}
|
}
|
||||||
|
|
||||||
source.sendOutput(formatEntry(Component.translatable("Java VM"), Component.text(runtime.getVmName())), false);
|
source.sendOutput(formatEntry(Component.translatable("Java VM"), Component.text(runtimeMXBean.getVmName())), false);
|
||||||
source.sendOutput(formatEntry(Component.translatable("Java version"), Component.text(runtime.getVmVersion())), 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);
|
source.sendOutput(formatEntry(Component.translatable("Heap memory usage"), formatMemoryUsage(memory.getHeapMemoryUsage())), false);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue