From 15573b52aa7ab5a9a2dfc05ed9ebda156a5083e7 Mon Sep 17 00:00:00 2001 From: Ghost_chu <2908803755@qq.com> Date: Sat, 6 Oct 2018 20:52:57 +0800 Subject: [PATCH] still not working? Former-commit-id: 0a61d7bd24d439d952d7ff22ec549dcf2f3c5bed --- src/main/java/org/maxgamer/quickshop/Metrics.java | 11 +++++++---- src/main/java/org/maxgamer/quickshop/QuickShop.java | 1 + 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/maxgamer/quickshop/Metrics.java b/src/main/java/org/maxgamer/quickshop/Metrics.java index ed671cbdd..2b92c25f1 100644 --- a/src/main/java/org/maxgamer/quickshop/Metrics.java +++ b/src/main/java/org/maxgamer/quickshop/Metrics.java @@ -67,10 +67,11 @@ public class Metrics { */ public Metrics(JavaPlugin plugin) { if (plugin == null) { + throw new IllegalArgumentException("Plugin cannot be null!"); } this.plugin = plugin; - + plugin.getLogger().info("bStats module loaded."); // Get the config file File bStatsFolder = new File(plugin.getDataFolder().getParentFile(), "bStats"); File configFile = new File(bStatsFolder, "config.yml"); @@ -237,8 +238,9 @@ public class Metrics { * Collects the data and sends it afterwards. */ public void submitData() { + final JSONObject data = getServerData(); - + plugin.getLogger().info("Posting stats data..."); JSONArray pluginData = new JSONArray(); // Search for all other bStats Metrics classes to get their plugin data for (Class service : Bukkit.getServicesManager().getKnownServices()) { @@ -260,6 +262,7 @@ public class Metrics { public void run() { try { // Send the data + plugin.getLogger().info("Sending stats data..."); sendData(data); } catch (Exception e) { // Something went wrong! :( @@ -277,7 +280,7 @@ public class Metrics { * @param data The data to send. * @throws Exception If the request failed. */ - private static void sendData(JSONObject data) throws Exception { + private void sendData(JSONObject data) throws Exception { if (data == null) { throw new IllegalArgumentException("Data cannot be null!"); } @@ -305,7 +308,7 @@ public class Metrics { outputStream.flush(); outputStream.close(); String result = new BufferedReader(new InputStreamReader(connection.getInputStream())).readLine(); - QuickShop.instance.getLogger().info("bStats data sended:"+result); + plugin.getLogger().info("Complete to send stats to bStats:"+result); connection.getInputStream().close(); // We don't care about the response - Just send our data :) } diff --git a/src/main/java/org/maxgamer/quickshop/QuickShop.java b/src/main/java/org/maxgamer/quickshop/QuickShop.java index a1e3d26a5..e9369bf6b 100644 --- a/src/main/java/org/maxgamer/quickshop/QuickShop.java +++ b/src/main/java/org/maxgamer/quickshop/QuickShop.java @@ -267,6 +267,7 @@ public class QuickShop extends JavaPlugin { metrics.addCustomChart(new Metrics.SimplePie("use_protect_explode",() -> use_protect_explode)); metrics.addCustomChart(new Metrics.SimplePie("use_protect_hopper", () ->use_protect_hopper)); metrics.submitData(); //Submit now! + getLogger().info("Mertics submited."); }else { getLogger().info("You have disabled mertics, Skipping..."); }