From b9930b39d5a7f96f524d86bef1e2906ea9655eb8 Mon Sep 17 00:00:00 2001 From: MiniDigger Date: Mon, 11 May 2020 22:18:58 +0200 Subject: [PATCH] Add legacy plugin count to metrics --- .../0005-Paper-Metrics.patch | 41 ++++++++++++++++++- .../0437-Improved-Watchdog-Support.patch | 4 +- 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/Spigot-Server-Patches/0005-Paper-Metrics.patch b/Spigot-Server-Patches/0005-Paper-Metrics.patch index a26eba0d2c..daca5a83fe 100644 --- a/Spigot-Server-Patches/0005-Paper-Metrics.patch +++ b/Spigot-Server-Patches/0005-Paper-Metrics.patch @@ -15,15 +15,19 @@ decisions on behalf of the project. diff --git a/src/main/java/com/destroystokyo/paper/Metrics.java b/src/main/java/com/destroystokyo/paper/Metrics.java new file mode 100644 -index 0000000000000000000000000000000000000000..f2a0a9f5d86820ce8098301256d2faf3d1a7c697 +index 0000000000000000000000000000000000000000..e4923ca371012188793b284cb0ed4280c31f50b6 --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/Metrics.java -@@ -0,0 +1,627 @@ +@@ -0,0 +1,664 @@ +package com.destroystokyo.paper; + +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..f2a0a9f5d86820ce8098301256d2faf3 + + return map; + })); ++ ++ metrics.addCustomChart(new Metrics.DrilldownPie("legacy_plugins", () -> { ++ Map> 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 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; ++ })); + } + + } diff --git a/Spigot-Server-Patches/0437-Improved-Watchdog-Support.patch b/Spigot-Server-Patches/0437-Improved-Watchdog-Support.patch index b3c928be39..9d128877cc 100644 --- a/Spigot-Server-Patches/0437-Improved-Watchdog-Support.patch +++ b/Spigot-Server-Patches/0437-Improved-Watchdog-Support.patch @@ -41,10 +41,10 @@ This also moves all plugins who register "delayed init" tasks to occur just befo are properly accounted for and wont trip watchdog on init. diff --git a/src/main/java/com/destroystokyo/paper/Metrics.java b/src/main/java/com/destroystokyo/paper/Metrics.java -index f2a0a9f5d86820ce8098301256d2faf3d1a7c697..8a19c96499c22f0d4705613ffec38d5677e1a72d 100644 +index e4923ca371012188793b284cb0ed4280c31f50b6..03c95b30d8a0557482d39468c058e7966114f824 100644 --- a/src/main/java/com/destroystokyo/paper/Metrics.java +++ b/src/main/java/com/destroystokyo/paper/Metrics.java -@@ -86,6 +86,9 @@ public class Metrics { +@@ -90,6 +90,9 @@ public class Metrics { timer.scheduleAtFixedRate(new TimerTask() { @Override public void run() {