From 5cdd0edffcefcdab4980657af86eac7d12837d9e Mon Sep 17 00:00:00 2001 From: carm Date: Fri, 5 Jan 2024 01:44:26 +0800 Subject: [PATCH] feat(stats): Add bstats support. --- README.md | 2 +- .../java/com/artformgames/plugin/usersuffix/Main.java | 7 ++++++- .../artformgames/plugin/usersuffix/conf/PluginConfig.java | 8 ++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ac6f127..e84a0ec 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ Will be generated on the first boot up. ## Statistics -[![bStats](https://bstats.org/signatures/bukkit/TemplatePlugin.svg)](https://bstats.org/plugin/bukkit/TemplatePlugin/18946) +[![bStats](https://bstats.org/signatures/bukkit/UserSuffix.svg)](https://bstats.org/plugin/bukkit/UserSuffix/20648) ## Open Source Licence diff --git a/src/main/java/com/artformgames/plugin/usersuffix/Main.java b/src/main/java/com/artformgames/plugin/usersuffix/Main.java index fa65d82..9d207c0 100644 --- a/src/main/java/com/artformgames/plugin/usersuffix/Main.java +++ b/src/main/java/com/artformgames/plugin/usersuffix/Main.java @@ -10,6 +10,7 @@ import com.artformgames.plugin.usersuffix.hooker.SuffixPlaceholder; import com.artformgames.plugin.usersuffix.user.SuffixLoader; import dev.rollczi.litecommands.LiteCommands; +import org.bstats.bukkit.Metrics; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; @@ -40,6 +41,11 @@ protected boolean initialize() { this.commands = ArtCore.createCommand().commands(UserSuffixCommands.class).build(); this.commands.register(); + if (PluginConfig.METRICS.getNotNull()) { + log("Initializing bStats..."); + new Metrics(this, 20648); + } + if (PluginConfig.CHECK_UPDATE.getNotNull()) { log("Start to check the plugin versions..."); getScheduler().runAsync(GHUpdateChecker.runner(this)); @@ -47,7 +53,6 @@ protected boolean initialize() { log("Version checker is disabled, skipped."); } - log("Register placeholders..."); if (Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI")) { new SuffixPlaceholder(this, getName()); diff --git a/src/main/java/com/artformgames/plugin/usersuffix/conf/PluginConfig.java b/src/main/java/com/artformgames/plugin/usersuffix/conf/PluginConfig.java index cbb306b..c33b979 100644 --- a/src/main/java/com/artformgames/plugin/usersuffix/conf/PluginConfig.java +++ b/src/main/java/com/artformgames/plugin/usersuffix/conf/PluginConfig.java @@ -11,6 +11,14 @@ public interface PluginConfig extends Configuration { ConfiguredValue DEBUG = ConfiguredValue.of(false); + @HeaderComment({ + "Statistics Settings", + "This option is used to help developers count plug-in versions and usage, and it will never affect performance and user experience.", + "Of course, you can also choose to turn it off here for this plugin,", + "or turn it off for all plugins in the configuration file under \"plugins/bStats\"." + }) + ConfiguredValue METRICS = ConfiguredValue.of(Boolean.class, true); + @HeaderComment({ "Check update settings", "This option is used by the plug-in to determine whether to check for updates.",