From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
Date: Fri, 5 Jun 2020 21:30:19 -0500
Subject: [PATCH] Timings stuff


diff --git a/src/main/java/co/aikar/timings/TimingsExport.java b/src/main/java/co/aikar/timings/TimingsExport.java
index 5dfa0658838c4801cdf260eae8b98163f729e5af..dae2e5d70756c5b61163d57099b65f7e415b288c 100644
--- a/src/main/java/co/aikar/timings/TimingsExport.java
+++ b/src/main/java/co/aikar/timings/TimingsExport.java
@@ -227,10 +227,14 @@ public class TimingsExport extends Thread {
         // Information on the users Config
 
         parent.put("config", createObject(
-            pair("spigot", mapAsJSON(Bukkit.spigot().getSpigotConfig(), null)),
-            pair("bukkit", mapAsJSON(Bukkit.spigot().getBukkitConfig(), null)),
-            pair("paper", mapAsJSON(Bukkit.spigot().getPaperConfig(), null)), // Tuinity - add config to timings report
-            pair("tuinity", mapAsJSON(Bukkit.spigot().getTuinityConfig(), null)) // Tuinity - add config to timings report
+                // Purpur start
+                pair("server.properties", mapAsJSON(Bukkit.spigot().getServerProperties())),
+                pair("bukkit", mapAsJSON(Bukkit.spigot().getBukkitConfig(), null)),
+                pair("spigot", mapAsJSON(Bukkit.spigot().getSpigotConfig(), null)),
+                pair("paper", mapAsJSON(Bukkit.spigot().getPaperConfig(), null)),
+                pair("tuinity", mapAsJSON(Bukkit.spigot().getTuinityConfig(), null)), // Tuinity - add config to timings report
+                pair("purpur", mapAsJSON(Bukkit.spigot().getPurpurConfig(), null))
+                // Purpur end
         ));
 
         new TimingsExport(listeners, parent, history).start();
@@ -271,6 +275,19 @@ public class TimingsExport extends Thread {
         return timingsCost;
     }
 
+    // Purpur start
+    private static JSONObject mapAsJSON(java.util.Properties properties) {
+        JSONObject object = new JSONObject();
+        for (String key : properties.stringPropertyNames()) {
+            if (key.startsWith("rcon") || key.startsWith("query") ||  key.equals("level-seed") || TimingsManager.hiddenConfigs.contains(key)) {
+                continue;
+            }
+            object.put(key, valAsJSON(properties.get(key), key));
+        }
+        return object;
+    }
+    // Purpur end
+
     private static JSONObject mapAsJSON(ConfigurationSection config, String parentKey) {
 
         JSONObject object = new JSONObject();
@@ -307,7 +324,7 @@ public class TimingsExport extends Thread {
         String response = null;
         String timingsURL = null;
         try {
-            HttpURLConnection con = (HttpURLConnection) new URL("http://timings.aikar.co/post").openConnection();
+            HttpURLConnection con = (HttpURLConnection) new URL(net.pl3x.purpur.PurpurConfig.timingsUrl + "/post").openConnection(); // Purpur
             con.setDoOutput(true);
             String hostName = "BrokenHost";
             try {
diff --git a/src/main/java/net/pl3x/purpur/PurpurConfig.java b/src/main/java/net/pl3x/purpur/PurpurConfig.java
index cd3272520eb78a9c663bac3bfdb2b63d611d48a1..00eb196f8caa2e4f2478972c14f4596071adbd2a 100644
--- a/src/main/java/net/pl3x/purpur/PurpurConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurConfig.java
@@ -127,4 +127,10 @@ public class PurpurConfig {
         config.addDefault(path, def);
         return config.getString(path, config.getString(path));
     }
+
+    public static String timingsUrl = "https://timings.pl3x.net";
+    private static void timingsSettings() {
+        timingsUrl = getString("settings.timings.url", timingsUrl);
+        if (!TimingsManager.hiddenConfigs.contains("server-ip")) TimingsManager.hiddenConfigs.add("server-ip");
+    }
 }
