Bastian / bstats-metrics

The different bStats Metrics classes
https://bStats.org
MIT License
98 stars 113 forks source link

Add Metrics#isEnabled() #94

Closed Bobcat00 closed 2 years ago

Bobcat00 commented 3 years ago

Metrics#isEnabled() was removed in bStats v2. Please add this back so plugins can determine if metrics have been enabled/disabled globally.

The use case is for plugins, in the interests of transparency, to print a message at startup indicating that metrics data collection is enabled for the plugin. Printing such a message when metrics has been globally disabled is confusing and inaccurate.

GeorgeV220 commented 2 years ago

You can try that if you want:

Metrics metrics = new Metrics(this, yourid);
if (YamlConfiguration.loadConfiguration(new File(new File(this.getDataFolder().getParentFile(), "bStats"), "config.yml")).getBoolean("enabled", true)) {
    Bukkit.getLogger().info("[Metrics] Metrics are enabled!");
}
Bastian commented 2 years ago

The use case is for plugins, in the interests of transparency, to print a message at startup indicating that metrics data collection is enabled for the plugin. Printing such a message when metrics has been globally disabled is confusing and inaccurate.

If this was intended, bStats would print such a message itself. Some Metrics classes (and in the future most likely every) log a message when the bStats config file gets created for the first time: https://github.com/Bastian/bStats-Metrics/blob/cb92d2653c5aa478599c5638c446371d247d6123/velocity/src/main/java/org/bstats/velocity/Metrics.java#L87-L94

Additionally, a #isEnabled() method can (and has been) abused by plugin developers, e.g. by delaying server startup time, begging users to enable bStats, etc.