diff --git a/pom.xml b/pom.xml index 7dfab636..66ffd9e3 100755 --- a/pom.xml +++ b/pom.xml @@ -155,9 +155,9 @@ 5.0.1 - org.jhardware - jHardware - 0.8.6 + com.github.oshi + oshi-core + 6.6.2 org.apache.logging.log4j diff --git a/src/main/java/net/coreprotect/command/StatusCommand.java b/src/main/java/net/coreprotect/command/StatusCommand.java index b6d1e497..c60031a4 100755 --- a/src/main/java/net/coreprotect/command/StatusCommand.java +++ b/src/main/java/net/coreprotect/command/StatusCommand.java @@ -104,18 +104,18 @@ else if (instance.getServer().getPluginManager().getPlugin("WorldEdit") != null) try { String cpuInfo = ""; if (ConfigHandler.processorInfo != null) { - String modelName = ConfigHandler.processorInfo.getModelName(); + String modelName = ConfigHandler.processorInfo.getProcessorIdentifier().getName(); 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]; } 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]; } - String cpuSpeed = ConfigHandler.processorInfo.getMhz(); - cpuSpeed = String.format("%.2f", Double.valueOf(cpuSpeed) / 1000.0); + String cpuSpeed = String.valueOf(ConfigHandler.processorInfo.getMaxFreq()); + cpuSpeed = String.format("%.2f", Long.valueOf(cpuSpeed) / 1000000000.0); cpuInfo = modelName + " " + Runtime.getRuntime().availableProcessors() + " x " + cpuSpeed + "GHz."; } else { diff --git a/src/main/java/net/coreprotect/config/ConfigHandler.java b/src/main/java/net/coreprotect/config/ConfigHandler.java index 06be249b..09dcf716 100644 --- a/src/main/java/net/coreprotect/config/ConfigHandler.java +++ b/src/main/java/net/coreprotect/config/ConfigHandler.java @@ -19,7 +19,6 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginManager; -import org.jutils.jhardware.model.ProcessorInfo; import com.zaxxer.hikari.HikariConfig; import com.zaxxer.hikari.HikariDataSource; @@ -37,6 +36,7 @@ import net.coreprotect.utility.Chat; import net.coreprotect.utility.Color; import net.coreprotect.utility.Util; +import oshi.hardware.CentralProcessor; public class ConfigHandler extends Queue { public static int SERVER_VERSION = 0; @@ -56,7 +56,7 @@ public class ConfigHandler extends Queue { public static int maximumPoolSize = 10; 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 isPaper = Util.isPaper(); public static final boolean isFolia = Util.isFolia(); diff --git a/src/main/java/net/coreprotect/utility/Util.java b/src/main/java/net/coreprotect/utility/Util.java index d14877e4..114a8f86 100755 --- a/src/main/java/net/coreprotect/utility/Util.java +++ b/src/main/java/net/coreprotect/utility/Util.java @@ -53,8 +53,6 @@ import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.plugin.Plugin; import org.bukkit.util.io.BukkitObjectOutputStream; -import org.jutils.jhardware.HardwareInfo; -import org.jutils.jhardware.model.ProcessorInfo; import net.coreprotect.CoreProtect; import net.coreprotect.bukkit.BukkitAdapter; @@ -68,6 +66,8 @@ import net.coreprotect.thread.Scheduler; import net.coreprotect.utility.serialize.ItemMetaHandler; import net.coreprotect.worldedit.CoreProtectEditSessionEvent; +import oshi.SystemInfo; +import oshi.hardware.CentralProcessor; public class Util extends Queue { @@ -116,11 +116,12 @@ public static String getPluginName() { return name; } - public static ProcessorInfo getProcessorInfo() { - ProcessorInfo result = null; + public static CentralProcessor getProcessorInfo() { + CentralProcessor result = null; try { - Configurator.setLevel("com.profesorfalken.jsensors.manager.unix.UnixSensorsManager", Level.OFF); - result = HardwareInfo.getProcessorInfo(); + Configurator.setLevel("oshi.hardware.common.AbstractCentralProcessor", Level.OFF); + SystemInfo systemInfo = new SystemInfo(); + result = systemInfo.getHardware().getProcessor(); } catch (Exception e) { // unable to read processor information