From d03d85b52b385ab44300e0f6a7758c88b181c4f0 Mon Sep 17 00:00:00 2001 From: vemacs Date: Sun, 5 Jul 2015 09:27:53 -0600 Subject: [PATCH] Start metrics async --- .../com/earth2me/essentials/Essentials.java | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/Essentials.java b/Essentials/src/com/earth2me/essentials/Essentials.java index fddb75ff1..0543671fb 100644 --- a/Essentials/src/com/earth2me/essentials/Essentials.java +++ b/Essentials/src/com/earth2me/essentials/Essentials.java @@ -56,6 +56,7 @@ import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPluginLoader; +import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitScheduler; import org.bukkit.scheduler.BukkitTask; import org.yaml.snakeyaml.error.YAMLException; @@ -205,13 +206,18 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials { execTimer.mark("RegHandler"); if (!metrics.isOptOut()) { - try { - getLogger().info("Starting Metrics. Opt-out using the global PluginMetrics config."); - metrics = new MetricsLite(this); - metrics.start(); - } catch (IOException e) { - // Failed to submit the stats :-( - } + getLogger().info("Starting Metrics. Opt-out using the global PluginMetrics config."); + new BukkitRunnable() { + @Override + public void run() { + try { + metrics = new MetricsLite(Essentials.this); + metrics.start(); + } catch (IOException e) { + // Failed to submit the stats :-( + } + } + }.runTaskAsynchronously(this); } else { getLogger().info("Metrics disabled per PluginMetrics config."); }