From 565492aa3450b41e2f88ebce69a30d0d66a6beb9 Mon Sep 17 00:00:00 2001 From: Warrior <50800980+Warriorrrr@users.noreply.github.com> Date: Sun, 15 Feb 2026 15:59:04 +0100 Subject: [PATCH] Add proxy_online_mode chart to metrics --- .../java/com/destroystokyo/paper/Metrics.java | 48 +++++++++---------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/paper-server/src/main/java/com/destroystokyo/paper/Metrics.java b/paper-server/src/main/java/com/destroystokyo/paper/Metrics.java index 9f4d73fd321f..acaaf456969b 100644 --- a/paper-server/src/main/java/com/destroystokyo/paper/Metrics.java +++ b/paper-server/src/main/java/com/destroystokyo/paper/Metrics.java @@ -1,5 +1,6 @@ package com.destroystokyo.paper; +import io.papermc.paper.configuration.GlobalConfiguration; import net.minecraft.server.MinecraftServer; import org.bukkit.Bukkit; import org.bukkit.configuration.file.YamlConfiguration; @@ -8,6 +9,7 @@ import org.json.simple.JSONArray; import org.json.simple.JSONObject; +import org.spigotmc.SpigotConfig; import javax.net.ssl.HttpsURLConnection; import java.io.ByteArrayOutputStream; @@ -23,14 +25,12 @@ import java.util.concurrent.TimeUnit; import java.util.logging.Level; import java.util.logging.Logger; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import java.util.zip.GZIPOutputStream; /** * bStats collects some data for plugin authors. - * - * Check out https://bstats.org/ to learn more about bStats! + *

+ * Check out bstats.org to learn more about bStats! */ public class Metrics { @@ -602,7 +602,7 @@ public static void startMetrics() { })); 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("online_mode", () -> Bukkit.getServerConfig().isProxyOnlineMode() ? "online" : "offline")); final String paperVersion; final String implVersion = org.bukkit.craftbukkit.Main.class.getPackage().getImplementationVersion(); if (implVersion != null) { @@ -619,26 +619,7 @@ public static void startMetrics() { Map entry = new HashMap<>(); entry.put(javaVersion, 1); - // http://openjdk.java.net/jeps/223 - // Java decided to change their versioning scheme and in doing so modified the java.version system - // property to return $major[.$minor][.$security][-ea], as opposed to 1.$major.0_$identifier - // we can handle pre-9 by checking if the "major" is equal to "1", otherwise, 9+ - String majorVersion = javaVersion.split("\\.")[0]; - String release; - - int indexOf = javaVersion.lastIndexOf('.'); - - if (majorVersion.equals("1")) { - release = "Java " + javaVersion.substring(0, indexOf); - } else { - // of course, it really wouldn't be all that simple if they didn't add a quirk, now would it - // valid strings for the major may potentially include values such as -ea to deannotate a pre release - Matcher versionMatcher = Pattern.compile("\\d+").matcher(majorVersion); - if (versionMatcher.find()) { - majorVersion = versionMatcher.group(0); - } - release = "Java " + majorVersion; - } + String release = "Java " + Runtime.version().feature(); map.put(release, entry); return map; @@ -676,6 +657,23 @@ public static void startMetrics() { return map; })); + + metrics.addCustomChart(new Metrics.DrilldownPie("proxy_online_mode", () -> { + final Map> map = new HashMap<>(); + + final Map entry = new HashMap<>(); + entry.put(Bukkit.getServer().getServerConfig().isProxyOnlineMode() ? "Online" : "Offline", 1); + + if (GlobalConfiguration.get().proxies.velocity.enabled) { + map.put("Velocity", entry); + } else if (SpigotConfig.bungee) { + map.put("BungeeCord", entry); + } else { + map.put("None", entry); + } + + return map; + })); } }