mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-03 15:08:18 +01:00
Update metrics warnings
This commit is contained in:
parent
c2617e5a1d
commit
2ce5797d5e
@ -14,7 +14,9 @@ import java.util.Map;
|
||||
|
||||
public class MetricsWrapper {
|
||||
|
||||
private static final List<String> KNOWN_FORCED_METRICS = ImmutableList.of("ChatControl");
|
||||
private static final List<String> KNOWN_FORCED_METRICS = ImmutableList.of(
|
||||
"ChatControl",
|
||||
"catserver.server.Metrics");
|
||||
private static boolean hasWarned = false;
|
||||
private final Essentials ess;
|
||||
private final Metrics metrics;
|
||||
@ -102,6 +104,20 @@ public class MetricsWrapper {
|
||||
}));
|
||||
}
|
||||
|
||||
private boolean isForcedMetricsClass(Class<?> bStatsService) {
|
||||
for (String identifier : KNOWN_FORCED_METRICS) {
|
||||
if (bStatsService.getCanonicalName().contains(identifier)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
final JavaPlugin owningPlugin = getProvidingPlugin(bStatsService);
|
||||
if (owningPlugin != null && KNOWN_FORCED_METRICS.contains(owningPlugin.getName())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void checkForcedMetrics() {
|
||||
if (hasWarned) return;
|
||||
hasWarned = true;
|
||||
@ -111,8 +127,7 @@ public class MetricsWrapper {
|
||||
try {
|
||||
service.getField("B_STATS_VERSION"); // Identifies bStats classes
|
||||
|
||||
final JavaPlugin owningPlugin = getProvidingPlugin(service);
|
||||
if (owningPlugin != null && KNOWN_FORCED_METRICS.contains(owningPlugin.getName())) {
|
||||
if (isForcedMetricsClass(service)) {
|
||||
warnForcedMetrics(service);
|
||||
} else {
|
||||
try {
|
||||
@ -123,7 +138,7 @@ public class MetricsWrapper {
|
||||
}
|
||||
|
||||
try {
|
||||
service.getDeclaredField("enabled"); // In modified forced metrics classes, this will fail
|
||||
service.getDeclaredField("enabled"); // In some modified forced metrics classes, this will fail
|
||||
} catch (final NoSuchFieldException e) {
|
||||
warnForcedMetrics(service);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user