mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 16:16:17 +02:00
avoid error on java < 21
This commit is contained in:
parent
e08a02a84a
commit
b532ce7dc6
1 changed files with 23 additions and 13 deletions
|
|
@ -32,6 +32,17 @@ object MetricsUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(metricType.allowFastStats) {
|
if(metricType.allowFastStats) {
|
||||||
|
// Check support java 21 (metric only work in java 21)
|
||||||
|
val versionParts = System.getProperty("java.version").split(".")
|
||||||
|
val majorVersion = versionParts[0].toInt()
|
||||||
|
if (majorVersion >= 21) try {
|
||||||
|
faststatTelemetry(plugin, nmsType, isAlpha)
|
||||||
|
} catch (_: Throwable) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun faststatTelemetry(plugin: CustomAnvil, nmsType: String, isAlpha: Boolean) {
|
||||||
|
val config = ConfigHolder.DEFAULT_CONFIG.config
|
||||||
val reportErrors = config.getBoolean(ConfigOptions.METRIC_COLLECT_ERROR, true)
|
val reportErrors = config.getBoolean(ConfigOptions.METRIC_COLLECT_ERROR, true)
|
||||||
if(reportErrors)
|
if(reportErrors)
|
||||||
ERROR_TRACKER = ErrorTracker.contextAware()
|
ERROR_TRACKER = ErrorTracker.contextAware()
|
||||||
|
|
@ -46,7 +57,6 @@ object MetricsUtil {
|
||||||
|
|
||||||
if(reportErrors) FAST_STATS_METRICS!!.ready()
|
if(reportErrors) FAST_STATS_METRICS!!.ready()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fun shutdownMetrics() {
|
fun shutdownMetrics() {
|
||||||
FAST_STATS_METRICS?.shutdown()
|
FAST_STATS_METRICS?.shutdown()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue