fixed stuff (added some more info) check commit diff
This commit is contained in:
@@ -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 {
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user