mirror of
https://github.com/PlayPro/CoreProtect.git
synced 2024-11-15 10:45:21 +01:00
Fixed errors pertaining the CPU lib on startup on some systems (fixes #591)
This commit is contained in:
parent
64eedb0aa3
commit
d2bffb2103
6
pom.xml
6
pom.xml
@ -155,9 +155,9 @@
|
|||||||
<version>5.0.1</version>
|
<version>5.0.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jhardware</groupId>
|
<groupId>com.github.oshi</groupId>
|
||||||
<artifactId>jHardware</artifactId>
|
<artifactId>oshi-core</artifactId>
|
||||||
<version>0.8.6</version>
|
<version>6.6.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.logging.log4j</groupId>
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
@ -104,18 +104,18 @@ public class StatusCommand {
|
|||||||
try {
|
try {
|
||||||
String cpuInfo = "";
|
String cpuInfo = "";
|
||||||
if (ConfigHandler.processorInfo != null) {
|
if (ConfigHandler.processorInfo != null) {
|
||||||
String modelName = ConfigHandler.processorInfo.getModelName();
|
String modelName = ConfigHandler.processorInfo.getProcessorIdentifier().getName();
|
||||||
if (modelName.contains(" CPU")) {
|
if (modelName.contains(" CPU")) {
|
||||||
String[] split = ConfigHandler.processorInfo.getModelName().split(" CPU")[0].split(" ");
|
String[] split = modelName.split(" CPU")[0].split(" ");
|
||||||
modelName = split[split.length - 1];
|
modelName = split[split.length - 1];
|
||||||
}
|
}
|
||||||
else if (modelName.contains(" Processor")) {
|
else if (modelName.contains(" Processor")) {
|
||||||
String[] split = ConfigHandler.processorInfo.getModelName().split(" Processor")[0].split(" ");
|
String[] split = modelName.split(" Processor")[0].split(" ");
|
||||||
modelName = split[split.length - 1];
|
modelName = split[split.length - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
String cpuSpeed = ConfigHandler.processorInfo.getMhz();
|
String cpuSpeed = String.valueOf(ConfigHandler.processorInfo.getMaxFreq());
|
||||||
cpuSpeed = String.format("%.2f", Double.valueOf(cpuSpeed) / 1000.0);
|
cpuSpeed = String.format("%.2f", Long.valueOf(cpuSpeed) / 1000000000.0);
|
||||||
cpuInfo = modelName + " " + Runtime.getRuntime().availableProcessors() + " x " + cpuSpeed + "GHz.";
|
cpuInfo = modelName + " " + Runtime.getRuntime().availableProcessors() + " x " + cpuSpeed + "GHz.";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -19,7 +19,6 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
import org.jutils.jhardware.model.ProcessorInfo;
|
|
||||||
|
|
||||||
import com.zaxxer.hikari.HikariConfig;
|
import com.zaxxer.hikari.HikariConfig;
|
||||||
import com.zaxxer.hikari.HikariDataSource;
|
import com.zaxxer.hikari.HikariDataSource;
|
||||||
@ -37,6 +36,7 @@ import net.coreprotect.spigot.SpigotAdapter;
|
|||||||
import net.coreprotect.utility.Chat;
|
import net.coreprotect.utility.Chat;
|
||||||
import net.coreprotect.utility.Color;
|
import net.coreprotect.utility.Color;
|
||||||
import net.coreprotect.utility.Util;
|
import net.coreprotect.utility.Util;
|
||||||
|
import oshi.hardware.CentralProcessor;
|
||||||
|
|
||||||
public class ConfigHandler extends Queue {
|
public class ConfigHandler extends Queue {
|
||||||
public static int SERVER_VERSION = 0;
|
public static int SERVER_VERSION = 0;
|
||||||
@ -56,7 +56,7 @@ public class ConfigHandler extends Queue {
|
|||||||
public static int maximumPoolSize = 10;
|
public static int maximumPoolSize = 10;
|
||||||
|
|
||||||
public static HikariDataSource hikariDataSource = null;
|
public static HikariDataSource hikariDataSource = null;
|
||||||
public static final ProcessorInfo processorInfo = Util.getProcessorInfo();
|
public static final CentralProcessor processorInfo = Util.getProcessorInfo();
|
||||||
public static final boolean isSpigot = Util.isSpigot();
|
public static final boolean isSpigot = Util.isSpigot();
|
||||||
public static final boolean isPaper = Util.isPaper();
|
public static final boolean isPaper = Util.isPaper();
|
||||||
public static final boolean isFolia = Util.isFolia();
|
public static final boolean isFolia = Util.isFolia();
|
||||||
|
@ -53,8 +53,6 @@ import org.bukkit.inventory.PlayerInventory;
|
|||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.util.io.BukkitObjectOutputStream;
|
import org.bukkit.util.io.BukkitObjectOutputStream;
|
||||||
import org.jutils.jhardware.HardwareInfo;
|
|
||||||
import org.jutils.jhardware.model.ProcessorInfo;
|
|
||||||
|
|
||||||
import net.coreprotect.CoreProtect;
|
import net.coreprotect.CoreProtect;
|
||||||
import net.coreprotect.bukkit.BukkitAdapter;
|
import net.coreprotect.bukkit.BukkitAdapter;
|
||||||
@ -68,6 +66,8 @@ import net.coreprotect.thread.CacheHandler;
|
|||||||
import net.coreprotect.thread.Scheduler;
|
import net.coreprotect.thread.Scheduler;
|
||||||
import net.coreprotect.utility.serialize.ItemMetaHandler;
|
import net.coreprotect.utility.serialize.ItemMetaHandler;
|
||||||
import net.coreprotect.worldedit.CoreProtectEditSessionEvent;
|
import net.coreprotect.worldedit.CoreProtectEditSessionEvent;
|
||||||
|
import oshi.SystemInfo;
|
||||||
|
import oshi.hardware.CentralProcessor;
|
||||||
|
|
||||||
public class Util extends Queue {
|
public class Util extends Queue {
|
||||||
|
|
||||||
@ -116,11 +116,12 @@ public class Util extends Queue {
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ProcessorInfo getProcessorInfo() {
|
public static CentralProcessor getProcessorInfo() {
|
||||||
ProcessorInfo result = null;
|
CentralProcessor result = null;
|
||||||
try {
|
try {
|
||||||
Configurator.setLevel("com.profesorfalken.jsensors.manager.unix.UnixSensorsManager", Level.OFF);
|
Configurator.setLevel("oshi.hardware.common.AbstractCentralProcessor", Level.OFF);
|
||||||
result = HardwareInfo.getProcessorInfo();
|
SystemInfo systemInfo = new SystemInfo();
|
||||||
|
result = systemInfo.getHardware().getProcessor();
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
// unable to read processor information
|
// unable to read processor information
|
||||||
|
Loading…
Reference in New Issue
Block a user