3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-15 19:10:09 +01:00

Fix metrics reporting unknown paper version (#8683)

Co-authored-by: BillyGalbreath <Blake.Galbreath@GMail.com>
Dieser Commit ist enthalten in:
Jake Potrebic 2022-12-16 09:37:06 -08:00 committet von GitHub
Ursprung 39d3a03bff
Commit aa9c200ea1
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23

Datei anzeigen

@ -15,10 +15,10 @@ 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..5a19e30a9b7e65a70f68a429b8ca741f788a303b
index 0000000000000000000000000000000000000000..6aaed8e8bf8c721fc834da5c76ac72a4c3e92458
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/Metrics.java
@@ -0,0 +1,670 @@
@@ -0,0 +1,678 @@
+package com.destroystokyo.paper;
+
+import net.minecraft.server.MinecraftServer;
@ -619,7 +619,15 @@ index 0000000000000000000000000000000000000000..5a19e30a9b7e65a70f68a429b8ca741f
+
+ metrics.addCustomChart(new Metrics.SingleLineChart("players", () -> Bukkit.getOnlinePlayers().size()));
+ metrics.addCustomChart(new Metrics.SimplePie("online_mode", () -> Bukkit.getOnlineMode() ? "online" : "offline"));
+ metrics.addCustomChart(new Metrics.SimplePie("paper_version", () -> (Metrics.class.getPackage().getImplementationVersion() != null) ? Metrics.class.getPackage().getImplementationVersion() : "unknown"));
+ final String paperVersion;
+ final String implVersion = org.bukkit.craftbukkit.Main.class.getPackage().getImplementationVersion();
+ if (implVersion != null) {
+ final String buildOrHash = implVersion.substring(implVersion.lastIndexOf('-') + 1);
+ paperVersion = "git-Paper-%s-%s".formatted(Bukkit.getServer().getMinecraftVersion(), buildOrHash);
+ } else {
+ paperVersion = "unknown";
+ }
+ metrics.addCustomChart(new Metrics.SimplePie("paper_version", () -> paperVersion));
+
+ metrics.addCustomChart(new Metrics.DrilldownPie("java_version", () -> {
+ Map<String, Map<String, Integer>> map = new HashMap<>();