mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 23:38:25 +01:00
Add legacy plugin count to metrics
This commit is contained in:
parent
7c3f274871
commit
01fe745c90
1 changed files with 37 additions and 0 deletions
|
@ -24,6 +24,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+import net.minecraft.server.MinecraftServer;
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.configuration.file.YamlConfiguration;
|
||||
+import org.bukkit.craftbukkit.util.CraftLegacy;
|
||||
+import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
+import org.bukkit.plugin.Plugin;
|
||||
+
|
||||
+import org.json.simple.JSONArray;
|
||||
+import org.json.simple.JSONObject;
|
||||
+
|
||||
|
@ -641,6 +645,39 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+
|
||||
+ return map;
|
||||
+ }));
|
||||
+
|
||||
+ metrics.addCustomChart(new Metrics.DrilldownPie("legacy_plugins", () -> {
|
||||
+ Map<String, Map<String, Integer>> map = new HashMap<>();
|
||||
+
|
||||
+ // count legacy plugins
|
||||
+ int legacy = 0;
|
||||
+ for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
|
||||
+ if (CraftMagicNumbers.isLegacy(plugin.getDescription())) {
|
||||
+ legacy++;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // insert real value as lower dimension
|
||||
+ Map<String, Integer> entry = new HashMap<>();
|
||||
+ entry.put(String.valueOf(legacy), 1);
|
||||
+
|
||||
+ // create buckets as higher dimension
|
||||
+ if (legacy == 0) {
|
||||
+ map.put("0 \uD83D\uDE0E", entry); // :sunglasses:
|
||||
+ } else if (legacy <= 5) {
|
||||
+ map.put("1-5", entry);
|
||||
+ } else if (legacy <= 10) {
|
||||
+ map.put("6-10", entry);
|
||||
+ } else if (legacy <= 25) {
|
||||
+ map.put("11-25", entry);
|
||||
+ } else if (legacy <= 50) {
|
||||
+ map.put("26-50", entry);
|
||||
+ } else {
|
||||
+ map.put("50+ \uD83D\uDE2D", entry); // :cry:
|
||||
+ }
|
||||
+
|
||||
+ return map;
|
||||
+ }));
|
||||
+ }
|
||||
+
|
||||
+ }
|
||||
|
|
Loading…
Reference in a new issue