1
mirror of https://github.com/CarmJos/UserPrefix.git synced 2026-06-05 00:35:02 +08:00

[v2.2.1] [U] 添加统计数据获取与开关设定。

This commit is contained in:
2021-12-31 01:57:53 +08:00
parent 42b71714aa
commit 7e4ca870b5
4 changed files with 75 additions and 45 deletions
+15 -1
View File
@@ -6,7 +6,7 @@
<groupId>cc.carm.plugin</groupId> <groupId>cc.carm.plugin</groupId>
<artifactId>userprefix</artifactId> <artifactId>userprefix</artifactId>
<version>2.2.0</version> <version>2.2.1</version>
<name>UserPrefix</name> <name>UserPrefix</name>
<description>轻便、高效、实时的用户前缀系统。</description> <description>轻便、高效、实时的用户前缀系统。</description>
@@ -120,6 +120,13 @@
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId>
<version>2.2.1</version>
<scope>compile</scope>
</dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
@@ -199,6 +206,13 @@
</execution> </execution>
</executions> </executions>
<configuration> <configuration>
<relocations>
<relocation>
<pattern>org.bstats</pattern>
<!-- Replace this with your package! -->
<shadedPattern>cc.carm.plugin.userprefix.bstats</shadedPattern>
</relocation>
</relocations>
<filters> <filters>
<filter> <filter>
<artifact>*:*</artifact> <artifact>*:*</artifact>
@@ -14,6 +14,8 @@ import cc.carm.plugin.userprefix.manager.UserManager;
import cc.carm.plugin.userprefix.util.ColorParser; import cc.carm.plugin.userprefix.util.ColorParser;
import cc.carm.plugin.userprefix.util.MessageUtil; import cc.carm.plugin.userprefix.util.MessageUtil;
import net.luckperms.api.event.user.UserDataRecalculateEvent; import net.luckperms.api.event.user.UserDataRecalculateEvent;
import org.bstats.bukkit.Metrics;
import org.bstats.charts.SingleLineChart;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.PluginCommand; import org.bukkit.command.PluginCommand;
@@ -26,6 +28,7 @@ import org.jetbrains.annotations.Nullable;
public class Main extends JavaPlugin { public class Main extends JavaPlugin {
private static Main instance; private static Main instance;
private static Metrics metrics;
@Override @Override
public void onEnable() { public void onEnable() {
@@ -55,6 +58,11 @@ public class Main extends JavaPlugin {
log("若您想使用变量进行前缀的显示,请安装PlaceholderAPI"); log("若您想使用变量进行前缀的显示,请安装PlaceholderAPI");
} }
if (PrefixConfig.METRICS.get()) {
log("启用统计数据...");
metrics = new Metrics(this, 13776);
metrics.addCustomChart(new SingleLineChart("active_prefixes", () -> PrefixManager.getPrefixes().size()));
}
log("加载完成 ,共耗时 " + (System.currentTimeMillis() - startTime) + " ms 。"); log("加载完成 ,共耗时 " + (System.currentTimeMillis() - startTime) + " ms 。");
@@ -64,6 +72,7 @@ public class Main extends JavaPlugin {
Bukkit.getOnlinePlayers().forEach(UserManager::initPlayer); // 适配热重载 Bukkit.getOnlinePlayers().forEach(UserManager::initPlayer); // 适配热重载
} }
} }
@Override @Override
@@ -11,6 +11,8 @@ public class PrefixConfig {
public static ConfigValue<Boolean> DEBUG = new ConfigValue<>("debug", Boolean.class, false); public static ConfigValue<Boolean> DEBUG = new ConfigValue<>("debug", Boolean.class, false);
public static ConfigValue<Boolean> METRICS = new ConfigValue<>("metrics", Boolean.class, true);
public static class CustomStorage { public static class CustomStorage {
public static ConfigValue<Boolean> ENABLE = new ConfigValue<>("custom-storage.enable", Boolean.class, false); public static ConfigValue<Boolean> ENABLE = new ConfigValue<>("custom-storage.enable", Boolean.class, false);
+5
View File
@@ -2,6 +2,11 @@ version: ${project.version} #配置文件版本,若与插件版本不同请记
debug: false debug: false
# 统计数据设定
# 改选项用于帮助开发者统计插件版本与使用情况,且绝不会影响性能与使用体验。
# 当然,您也可以选择在这里关闭,或在plugins/bStats下的配置文件中关闭。
metrics: true
custom-storage: custom-storage:
# 自定义存储位置 # 自定义存储位置
# 默认存储位置为 “插件文件夹”/prefixes # 默认存储位置为 “插件文件夹”/prefixes