Files
PlazmaBukkitMC/patches/server/0009-Add-more-metrics.patch
Alpha 922c33171c Rewrite Configuration (#60)
* work

* work

* more work

* complete configuration base

* More work

* more work

* Configurable cave lava sea level, Fix MC-237017

* more more more work

* Updated Upstream (Paper, Pufferfish, Purpur)

* Rework, again

* Cleanup workflows, fix build

* typo

* more work

* more work

- Updated Upstream (Paper)
- [CI-Skip] Update Upstream CacheData (Pufferfish, Purpur)
- Update Dependencies (Paperweight)
- Fix build
- Update Wrapper

* more works

* more more works

* Fix build

* Fix test

* Implemented FixMySpawnR, Added more config optimize

* Fix build
2023-12-09 11:22:36 +09:00

70 lines
4.2 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: AlphaKR93 <dev@alpha93.kr>
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..f006c867ad0765e0f52a629729ab131acec5c2fc 100644
--- a/src/main/java/com/destroystokyo/paper/Metrics.java
+++ b/src/main/java/com/destroystokyo/paper/Metrics.java
@@ -636,16 +636,52 @@ public class Metrics {
return map;
}));
+ // Plazma start
+ metrics.addCustomChart(new DrilldownPie("datapacks", () -> {
+ int datapacks = Bukkit.getDatapackManager().getEnabledPacks().size();
+ Map<String, Integer> entry = Collections.singletonMap(String.valueOf(datapacks), 1);
+
+ 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 return Collections.singletonMap("50+", entry);
+ }));
+
+ List<Plugin> plugins = Arrays.stream(Bukkit.getPluginManager().getPlugins()).toList();
+
+ metrics.addCustomChart(new DrilldownPie("plugins", () -> {
+ int pluginCount = (int) plugins.stream().filter(Plugin::isEnabled).count();
+ Map<String, Integer> entry = Collections.singletonMap(String.valueOf(pluginCount), 1);
+
+ 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 return Collections.singletonMap("50+", entry);
+ }));
+
+ metrics.addCustomChart(new DrilldownPie("disabled_plugins", () -> {
+ int disabled = (int) plugins.stream().filter(java.util.function.Predicate.not(Plugin::isEnabled)).count();
+ Map<String, Integer> entry = Collections.singletonMap(String.valueOf(disabled), 1);
+
+ 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("50-100 \uD83D\uDE2D", entry); // :cry:
+ else return Collections.singletonMap("101+ \uD83D\uDC80", entry); // :skull:
+ }));
+ // Plazma end
+
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++;
- }
- }
+ int legacy = (int) plugins.stream().filter(p -> CraftMagicNumbers.isLegacy(p.getDescription())).count(); // Plazma
// insert real value as lower dimension
Map<String, Integer> entry = new HashMap<>();