mirror of
https://github.com/kaboomserver/extras.git
synced 2025-08-03 02:55:49 +00:00
Fix behavior when OSHI can't run (#379)
* Fix fallback behavior * Catch class load errors
This commit is contained in:
parent
f6baa88cd0
commit
a06a8e9cea
2 changed files with 6 additions and 4 deletions
|
@ -17,7 +17,7 @@ import java.lang.management.ManagementFactory;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
|
|
||||||
public final class CommandServerInfo implements CommandExecutor {
|
public final class CommandServerInfo implements CommandExecutor {
|
||||||
private static final @Nullable String[] GPU_DEVICES;
|
private static final String[] GPU_DEVICES;
|
||||||
private static final @Nullable String PROCESSOR_NAME;
|
private static final @Nullable String PROCESSOR_NAME;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
@ -48,7 +48,7 @@ public final class CommandServerInfo implements CommandExecutor {
|
||||||
);
|
);
|
||||||
|
|
||||||
if (hardwareInfo == null) {
|
if (hardwareInfo == null) {
|
||||||
GPU_DEVICES = null;
|
GPU_DEVICES = new String[0];
|
||||||
PROCESSOR_NAME = null;
|
PROCESSOR_NAME = null;
|
||||||
} else {
|
} else {
|
||||||
GPU_DEVICES = hardwareInfo.first();
|
GPU_DEVICES = hardwareInfo.first();
|
||||||
|
@ -95,7 +95,9 @@ public final class CommandServerInfo implements CommandExecutor {
|
||||||
+ ManagementFactory.getRuntimeMXBean().getVmVersion()
|
+ ManagementFactory.getRuntimeMXBean().getVmVersion()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (PROCESSOR_NAME != null) {
|
||||||
sendInfoMessage(sender, "CPU model", PROCESSOR_NAME);
|
sendInfoMessage(sender, "CPU model", PROCESSOR_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
sendInfoMessage(sender, "CPU cores",
|
sendInfoMessage(sender, "CPU cores",
|
||||||
String.valueOf(Runtime.getRuntime().availableProcessors())
|
String.valueOf(Runtime.getRuntime().availableProcessors())
|
||||||
|
|
|
@ -45,7 +45,7 @@ public final class Utility {
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
return composer.apply(callable.call());
|
return composer.apply(callable.call());
|
||||||
} catch (Exception e) {
|
} catch (Throwable ex) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue