diff --git a/src/main/kotlin/org/server_info/server_info/Server_info.kt b/src/main/kotlin/org/server_info/server_info/Server_info.kt index 97c5b7f..3f1ca27 100644 --- a/src/main/kotlin/org/server_info/server_info/Server_info.kt +++ b/src/main/kotlin/org/server_info/server_info/Server_info.kt @@ -136,7 +136,7 @@ class Server_info : JavaPlugin() { } else { // If CPU time not supported, use a basic estimate ( If this happens please check the server for issues! ) val threadCount = ManagementFactory.getThreadMXBean().threadCount - logger.warning(/* msg = */ "§4Accuarte CPU Monitoring isnt supported! Check Server for Issues!") + logger.warning("§4Accurate CPU Monitoring isn't supported! Check Server for Issues!") cpuUsage = (threadCount * 100.0) / (processors * 20.0) cpuUsage = cpuUsage.coerceIn(0.0, 100.0) } @@ -170,10 +170,10 @@ class Server_info : JavaPlugin() { private fun getTabListFooter(): Component { val runtime = Runtime.getRuntime() - val maxMemory = runtime.maxMemory() / (1024 * 1024) - val allocatedMemory = runtime.totalMemory() / (1024 * 1024) - val freeMemory = runtime.freeMemory() / (1024 * 1024) - val usedMemory = allocatedMemory - freeMemory + val maxMemory = runtime.maxMemory() + val totalMemory = runtime.totalMemory() + val freeMemory = runtime.freeMemory() + val usedMemory = totalMemory - freeMemory val tpsColor = when { tps >= 18.0 -> "§2" @@ -190,15 +190,18 @@ class Server_info : JavaPlugin() { fun getServerInfo(): String { val runtime = Runtime.getRuntime() - val maxMemory = runtime.maxMemory() / (1024 * 1024) - val allocatedMemory = runtime.totalMemory() / (1024 * 1024) - val freeMemory = runtime.freeMemory() / (1024 * 1024) - val usedMemory = allocatedMemory - freeMemory + val maxMemory = runtime.maxMemory() + val totalMemory = runtime.totalMemory() + val freeMemory = runtime.freeMemory() + val usedMemory = totalMemory - freeMemory + val jvmFreeMemory = maxMemory - usedMemory return buildString { append("§6--- ServerInfo ---\n") append("§6Title: §f$serverTitle\n") - append("§aRAM Usage: §f${formatMemory(usedMemory)} / ${formatMemory(allocatedMemory)}\n") + append("§aRAM Usage: §f${formatMemory(usedMemory)} / ${formatMemory(maxMemory)}\n") + append("§aJVM Free: §f${formatMemory(jvmFreeMemory)}\n") + append("§aJVM Allocated: §f${formatMemory(totalMemory)}\n") append("§aMax RAM: §f${formatMemory(maxMemory)}\n") append("§aCPU Load: ${formatCPU(cpuUsage)}%\n") append("§aTPS: ${formatTPS(tps)}\n") @@ -213,12 +216,13 @@ class Server_info : JavaPlugin() { } } - private fun formatMemory(valueInMB: Long): String { - return if (valueInMB >= 1000) { - val gb = valueInMB / 1024.0 - "${df.format(gb)} GB" + private fun formatMemory(valueInBytes: Long): String { + val mbValue = valueInBytes / (1024 * 1024) + return if (mbValue >= 1024) { + val gbValue = mbValue / 1024.0 + "${df.format(gbValue)} GB" } else { - "$valueInMB MB" + "$mbValue MB" } } @@ -240,6 +244,7 @@ class Server_info : JavaPlugin() { -1 } } + // Create CommandClass that stores the Commands that can be used private inner class ServerInfoCommand(private val plugin: Server_info) : CommandExecutor, TabCompleter { diff --git a/target/classes/org/server_info/server_info/Server_info$ServerInfoCommand.class b/target/classes/org/server_info/server_info/Server_info$ServerInfoCommand.class index 102a7a6..9253e3c 100644 Binary files a/target/classes/org/server_info/server_info/Server_info$ServerInfoCommand.class and b/target/classes/org/server_info/server_info/Server_info$ServerInfoCommand.class differ diff --git a/target/classes/org/server_info/server_info/Server_info.class b/target/classes/org/server_info/server_info/Server_info.class index 32b6c05..6bd3754 100644 Binary files a/target/classes/org/server_info/server_info/Server_info.class and b/target/classes/org/server_info/server_info/Server_info.class differ diff --git a/target/original-server_info-1.0-SNAPSHOT.jar b/target/original-server_info-1.0-SNAPSHOT.jar index b732245..b23169f 100644 Binary files a/target/original-server_info-1.0-SNAPSHOT.jar and b/target/original-server_info-1.0-SNAPSHOT.jar differ diff --git a/target/server_info-1.0-SNAPSHOT.jar b/target/server_info-1.0-SNAPSHOT.jar index 3422817..1454d42 100644 Binary files a/target/server_info-1.0-SNAPSHOT.jar and b/target/server_info-1.0-SNAPSHOT.jar differ