-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
80 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,98 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: AlphaKR93 <[email protected]> | ||
Date: Fri, 24 Mar 2023 23:54:51 +0900 | ||
Date: Sun, 5 Nov 2023 10:26:26 +0900 | ||
Subject: [PATCH] Add more metrics | ||
|
||
|
||
diff --git a/src/main/java/com/destroystokyo/paper/Metrics.java b/src/main/java/com/destroystokyo/paper/Metrics.java | ||
index 7d80d2cf5d607d6051e99e4b08bc1b76098a79da..067bcbcb81802a3a52ecff737ddf2c033696ecfb 100644 | ||
index 7d80d2cf5d607d6051e99e4b08bc1b76098a79da..057fb0be810930b1d1a18d7d572c18ac066ac849 100644 | ||
--- a/src/main/java/com/destroystokyo/paper/Metrics.java | ||
+++ b/src/main/java/com/destroystokyo/paper/Metrics.java | ||
@@ -636,12 +636,63 @@ public class Metrics { | ||
@@ -636,38 +636,59 @@ public class Metrics { | ||
return map; | ||
})); | ||
|
||
+ // Plazma start | ||
+ metrics.addCustomChart(new Metrics.DrilldownPie("datapacks", () -> { | ||
+ Map<String, Map<String, Integer>> map = new HashMap<>(); | ||
+ int datapacks = Bukkit.getServer().getDatapackManager().getEnabledPacks().size(); | ||
+ Map<String, Integer> entry = new HashMap<>(); | ||
+ entry.put(String.valueOf(datapacks), 1); | ||
- metrics.addCustomChart(new Metrics.DrilldownPie("legacy_plugins", () -> { | ||
- Map<String, Map<String, Integer>> map = new HashMap<>(); | ||
+ // Plazma start - Add more metrics information | ||
+ metrics.addCustomChart(new DrilldownPie("datapacks", () -> { | ||
+ int datapacks = Bukkit.getDatapackManager().getEnabledPacks().size(); | ||
+ Map<String, Integer> entry = Collections.singletonMap(String.valueOf(datapacks), 1); | ||
+ | ||
+ if (datapacks == 0) | ||
+ map.put("0", entry); | ||
+ else if (datapacks <= 5) | ||
+ map.put("1-5", entry); | ||
+ else if (datapacks <= 10) | ||
+ map.put("6-10", entry); | ||
+ else if (datapacks <= 25) | ||
+ map.put("11-25", entry); | ||
+ else | ||
+ map.put("26+", entry); | ||
+ | ||
+ return map; | ||
+ if (datapacks == 0) return Collections.singletonMap("0", entry); | ||
+ else if (datapacks <= 5) return Collections.singletonMap("1-5", entry); | ||
+ else if (datapacks <= 10) return Collections.singletonMap("6-10", entry); | ||
+ else if (datapacks <= 25) return Collections.singletonMap("11-25", entry); | ||
+ else if (datapacks <= 50) return Collections.singletonMap("26-50", entry); | ||
+ else if (datapacks <= 100) return Collections.singletonMap("51+", entry); | ||
+ else return Collections.singletonMap("101+ \uD83D\uDE2E", entry); | ||
+ })); | ||
+ | ||
+ List<Plugin> plugins = new ArrayList<>(); | ||
+ for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) { | ||
+ if (plugin.isEnabled()) { | ||
+ plugins.add(plugin); | ||
+ } | ||
+ } | ||
+ | ||
+ metrics.addCustomChart(new Metrics.DrilldownPie("plugins", () -> { | ||
+ Map<String, Map<String, Integer>> map = new HashMap<>(); | ||
+ int plugins1 = plugins.size(); | ||
+ Map<String, Integer> entry = new HashMap<>(); | ||
+ entry.put(String.valueOf(plugins1), 1); | ||
|
||
- // count legacy plugins | ||
- int legacy = 0; | ||
- for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) { | ||
- if (CraftMagicNumbers.isLegacy(plugin.getDescription())) { | ||
- legacy++; | ||
- } | ||
- } | ||
+ metrics.addCustomChart(new DrilldownPie("plugins", () -> { | ||
+ int pluginCount = Arrays.stream(Bukkit.getPluginManager().getPlugins()).filter(Plugin::isEnabled).toList().size(); | ||
+ Map<String, Integer> entry = Collections.singletonMap(String.valueOf(pluginCount), 1); | ||
+ | ||
+ if (plugins1 == 0) | ||
+ map.put("0", entry); | ||
+ else if (plugins1 <= 5) | ||
+ map.put("1-5", entry); | ||
+ else if (plugins1 <= 10) | ||
+ map.put("6-10", entry); | ||
+ else if (plugins1 <= 25) | ||
+ map.put("11-25", entry); | ||
+ else if (plugins1 <= 50) | ||
+ map.put("26-50", entry); | ||
+ else | ||
+ map.put("51+", entry); | ||
+ if (pluginCount == 0) return Collections.singletonMap("0", entry); | ||
+ else if (pluginCount <= 5) return Collections.singletonMap("1-5", entry); | ||
+ else if (pluginCount <= 10) return Collections.singletonMap("6-10", entry); | ||
+ else if (pluginCount <= 25) return Collections.singletonMap("11-25", entry); | ||
+ else if (pluginCount <= 50) return Collections.singletonMap("26-50", entry); | ||
+ else if (pluginCount <= 100) return Collections.singletonMap("51-100", entry); | ||
+ else return Collections.singletonMap("101+ \uD83D\uDE2E", entry); | ||
+ })); | ||
|
||
- // 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: | ||
- } | ||
+ metrics.addCustomChart(new DrilldownPie("disabled_plugins", () -> { | ||
+ int disabled = Arrays.stream(Bukkit.getPluginManager().getPlugins()).filter(it -> !it.isEnabled()).toList().size(); | ||
+ Map<String, Integer> entry = Collections.singletonMap(String.valueOf(disabled), 1); | ||
+ | ||
+ return map; | ||
+ if (disabled == 0) return Collections.singletonMap("0 \uD83D\uDE0E", entry); // :sunglasses: | ||
+ else if (disabled <= 5) return Collections.singletonMap("1-5", entry); | ||
+ else if (disabled <= 10) return Collections.singletonMap("6-10", entry); | ||
+ else if (disabled <= 25) return Collections.singletonMap("11-25", entry); | ||
+ else if (disabled <= 50) return Collections.singletonMap("26-50", entry); | ||
+ else if (disabled <= 100) return Collections.singletonMap("51-100 \uD83D\uDE2D", entry); // :cry: | ||
+ else return Collections.singletonMap("101+ \uD83D\uDC80", entry); // :skull: | ||
+ })); | ||
+ // Plazma end | ||
|
||
- return map; | ||
+ metrics.addCustomChart(new Metrics.DrilldownPie("legacy_plugins", () -> { | ||
+ int legacy = (int) Arrays.stream(Bukkit.getPluginManager().getPlugins()).filter(p -> CraftMagicNumbers.isLegacy(p.getDescription())).count(); // Plazma | ||
+ Map<String, Integer> entry = Collections.singletonMap(String.valueOf(legacy), 1); | ||
+ | ||
metrics.addCustomChart(new Metrics.DrilldownPie("legacy_plugins", () -> { | ||
Map<String, Map<String, Integer>> map = new HashMap<>(); | ||
+ if (legacy == 0) return Collections.singletonMap("0 \uD83D\uDE0E", entry); // :sunglasses: | ||
+ else if (legacy <= 5) return Collections.singletonMap("1-5", entry); | ||
+ else if (legacy <= 10) return Collections.singletonMap("6-10", entry); | ||
+ else if (legacy <= 25) return Collections.singletonMap("11-25", entry); | ||
+ else if (legacy <= 50) return Collections.singletonMap("26-50", entry); | ||
+ else if (legacy <= 100) return Collections.singletonMap("51-100 \uD83D\uDE2D", entry); // :cry: | ||
+ else return Collections.singletonMap("101+ \uD83D\uDC80", entry); // :skull: | ||
})); | ||
+ // Plazma end - Add more metrics information | ||
} | ||
|
||
// count legacy plugins | ||
int legacy = 0; | ||
- for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) { | ||
+ for (Plugin plugin : plugins) { // Plazma | ||
if (CraftMagicNumbers.isLegacy(plugin.getDescription())) { | ||
legacy++; | ||
} | ||
} |