fixed stuff (added some more info) check commit diff
This commit is contained in:
@@ -136,7 +136,7 @@ class Server_info : JavaPlugin() {
|
|||||||
} else {
|
} else {
|
||||||
// If CPU time not supported, use a basic estimate ( If this happens please check the server for issues! )
|
// If CPU time not supported, use a basic estimate ( If this happens please check the server for issues! )
|
||||||
val threadCount = ManagementFactory.getThreadMXBean().threadCount
|
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 = (threadCount * 100.0) / (processors * 20.0)
|
||||||
cpuUsage = cpuUsage.coerceIn(0.0, 100.0)
|
cpuUsage = cpuUsage.coerceIn(0.0, 100.0)
|
||||||
}
|
}
|
||||||
@@ -170,10 +170,10 @@ class Server_info : JavaPlugin() {
|
|||||||
|
|
||||||
private fun getTabListFooter(): Component {
|
private fun getTabListFooter(): Component {
|
||||||
val runtime = Runtime.getRuntime()
|
val runtime = Runtime.getRuntime()
|
||||||
val maxMemory = runtime.maxMemory() / (1024 * 1024)
|
val maxMemory = runtime.maxMemory()
|
||||||
val allocatedMemory = runtime.totalMemory() / (1024 * 1024)
|
val totalMemory = runtime.totalMemory()
|
||||||
val freeMemory = runtime.freeMemory() / (1024 * 1024)
|
val freeMemory = runtime.freeMemory()
|
||||||
val usedMemory = allocatedMemory - freeMemory
|
val usedMemory = totalMemory - freeMemory
|
||||||
|
|
||||||
val tpsColor = when {
|
val tpsColor = when {
|
||||||
tps >= 18.0 -> "§2"
|
tps >= 18.0 -> "§2"
|
||||||
@@ -190,15 +190,18 @@ class Server_info : JavaPlugin() {
|
|||||||
|
|
||||||
fun getServerInfo(): String {
|
fun getServerInfo(): String {
|
||||||
val runtime = Runtime.getRuntime()
|
val runtime = Runtime.getRuntime()
|
||||||
val maxMemory = runtime.maxMemory() / (1024 * 1024)
|
val maxMemory = runtime.maxMemory()
|
||||||
val allocatedMemory = runtime.totalMemory() / (1024 * 1024)
|
val totalMemory = runtime.totalMemory()
|
||||||
val freeMemory = runtime.freeMemory() / (1024 * 1024)
|
val freeMemory = runtime.freeMemory()
|
||||||
val usedMemory = allocatedMemory - freeMemory
|
val usedMemory = totalMemory - freeMemory
|
||||||
|
val jvmFreeMemory = maxMemory - usedMemory
|
||||||
|
|
||||||
return buildString {
|
return buildString {
|
||||||
append("§6--- ServerInfo ---\n")
|
append("§6--- ServerInfo ---\n")
|
||||||
append("§6Title: §f$serverTitle\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("§aMax RAM: §f${formatMemory(maxMemory)}\n")
|
||||||
append("§aCPU Load: ${formatCPU(cpuUsage)}%\n")
|
append("§aCPU Load: ${formatCPU(cpuUsage)}%\n")
|
||||||
append("§aTPS: ${formatTPS(tps)}\n")
|
append("§aTPS: ${formatTPS(tps)}\n")
|
||||||
@@ -213,12 +216,13 @@ class Server_info : JavaPlugin() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun formatMemory(valueInMB: Long): String {
|
private fun formatMemory(valueInBytes: Long): String {
|
||||||
return if (valueInMB >= 1000) {
|
val mbValue = valueInBytes / (1024 * 1024)
|
||||||
val gb = valueInMB / 1024.0
|
return if (mbValue >= 1024) {
|
||||||
"${df.format(gb)} GB"
|
val gbValue = mbValue / 1024.0
|
||||||
|
"${df.format(gbValue)} GB"
|
||||||
} else {
|
} else {
|
||||||
"$valueInMB MB"
|
"$mbValue MB"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,6 +244,7 @@ class Server_info : JavaPlugin() {
|
|||||||
-1
|
-1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create CommandClass that stores the Commands that can be used
|
// Create CommandClass that stores the Commands that can be used
|
||||||
private inner class ServerInfoCommand(private val plugin: Server_info) : CommandExecutor, TabCompleter {
|
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