Archiviert
13
0

Add API to get the url in a timing report listener

Dieser Commit ist enthalten in:
Aikar 2017-02-04 23:07:09 -05:00
Ursprung d033b57b47
Commit ee7f13ea3c

Datei anzeigen

@ -1,4 +1,4 @@
From 134c514dd418485e6f07d20930dc0c4398dc76fd Mon Sep 17 00:00:00 2001 From 4f781ea0e66da6e77e8b22812bc9f480bb17f356 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co> From: Aikar <aikar@aikar.co>
Date: Mon, 29 Feb 2016 18:48:17 -0600 Date: Mon, 29 Feb 2016 18:48:17 -0600
Subject: [PATCH] Timings v2 Subject: [PATCH] Timings v2
@ -1599,10 +1599,10 @@ index 00000000..56b10e89
+} +}
diff --git a/src/main/java/co/aikar/timings/TimingsExport.java b/src/main/java/co/aikar/timings/TimingsExport.java diff --git a/src/main/java/co/aikar/timings/TimingsExport.java b/src/main/java/co/aikar/timings/TimingsExport.java
new file mode 100644 new file mode 100644
index 00000000..23a3daa8 index 00000000..df7f4259
--- /dev/null --- /dev/null
+++ b/src/main/java/co/aikar/timings/TimingsExport.java +++ b/src/main/java/co/aikar/timings/TimingsExport.java
@@ -0,0 +1,341 @@ @@ -0,0 +1,342 @@
+/* +/*
+ * This file is licensed under the MIT License (MIT). + * This file is licensed under the MIT License (MIT).
+ * + *
@ -1873,6 +1873,7 @@ index 00000000..23a3daa8
+ +
+ +
+ String response = null; + String response = null;
+ String timingsURL = null;
+ try { + try {
+ HttpURLConnection con = (HttpURLConnection) new URL("http://timings.aikar.co/post").openConnection(); + HttpURLConnection con = (HttpURLConnection) new URL("http://timings.aikar.co/post").openConnection();
+ con.setDoOutput(true); + con.setDoOutput(true);
@ -1903,8 +1904,8 @@ index 00000000..23a3daa8
+ return; + return;
+ } + }
+ +
+ String location = con.getHeaderField("Location"); + timingsURL = con.getHeaderField("Location");
+ listeners.sendMessage(ChatColor.GREEN + "View Timings Report: " + location); + listeners.sendMessage(ChatColor.GREEN + "View Timings Report: " + timingsURL);
+ +
+ if (response != null && !response.isEmpty()) { + if (response != null && !response.isEmpty()) {
+ Bukkit.getLogger().log(Level.INFO, "Timing Response: " + response); + Bukkit.getLogger().log(Level.INFO, "Timing Response: " + response);
@ -1916,7 +1917,7 @@ index 00000000..23a3daa8
+ } + }
+ Bukkit.getLogger().log(Level.SEVERE, "Could not paste timings", ex); + Bukkit.getLogger().log(Level.SEVERE, "Could not paste timings", ex);
+ } finally { + } finally {
+ this.listeners.done(); + this.listeners.done(timingsURL);
+ } + }
+ } + }
+ +
@ -2148,10 +2149,10 @@ index 00000000..58ed35e0
+} +}
diff --git a/src/main/java/co/aikar/timings/TimingsReportListener.java b/src/main/java/co/aikar/timings/TimingsReportListener.java diff --git a/src/main/java/co/aikar/timings/TimingsReportListener.java b/src/main/java/co/aikar/timings/TimingsReportListener.java
new file mode 100644 new file mode 100644
index 00000000..4d492d4b index 00000000..e7c389c0
--- /dev/null --- /dev/null
+++ b/src/main/java/co/aikar/timings/TimingsReportListener.java +++ b/src/main/java/co/aikar/timings/TimingsReportListener.java
@@ -0,0 +1,62 @@ @@ -0,0 +1,72 @@
+package co.aikar.timings; +package co.aikar.timings;
+ +
+import com.google.common.collect.Lists; +import com.google.common.collect.Lists;
@ -2168,6 +2169,7 @@ index 00000000..4d492d4b
+public class TimingsReportListener implements MessageCommandSender { +public class TimingsReportListener implements MessageCommandSender {
+ private final List<CommandSender> senders; + private final List<CommandSender> senders;
+ private final Runnable onDone; + private final Runnable onDone;
+ private String timingsURL;
+ +
+ public TimingsReportListener(CommandSender senders) { + public TimingsReportListener(CommandSender senders) {
+ this(senders, null); + this(senders, null);
@ -2186,7 +2188,16 @@ index 00000000..4d492d4b
+ this.onDone = onDone; + this.onDone = onDone;
+ } + }
+ +
+ public String getTimingsURL() {
+ return timingsURL;
+ }
+
+ public void done() { + public void done() {
+ done(null);
+ }
+
+ public void done(String url) {
+ this.timingsURL = url;
+ if (onDone != null) { + if (onDone != null) {
+ onDone.run(); + onDone.run();
+ } + }