Start metrics async

This commit is contained in:
vemacs 2015-07-05 09:27:53 -06:00
parent cf9c9f7073
commit d03d85b52b

View File

@ -56,6 +56,7 @@ import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.plugin.java.JavaPluginLoader; import org.bukkit.plugin.java.JavaPluginLoader;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitScheduler; import org.bukkit.scheduler.BukkitScheduler;
import org.bukkit.scheduler.BukkitTask; import org.bukkit.scheduler.BukkitTask;
import org.yaml.snakeyaml.error.YAMLException; import org.yaml.snakeyaml.error.YAMLException;
@ -205,13 +206,18 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
execTimer.mark("RegHandler"); execTimer.mark("RegHandler");
if (!metrics.isOptOut()) { if (!metrics.isOptOut()) {
try {
getLogger().info("Starting Metrics. Opt-out using the global PluginMetrics config."); getLogger().info("Starting Metrics. Opt-out using the global PluginMetrics config.");
metrics = new MetricsLite(this); new BukkitRunnable() {
@Override
public void run() {
try {
metrics = new MetricsLite(Essentials.this);
metrics.start(); metrics.start();
} catch (IOException e) { } catch (IOException e) {
// Failed to submit the stats :-( // Failed to submit the stats :-(
} }
}
}.runTaskAsynchronously(this);
} else { } else {
getLogger().info("Metrics disabled per PluginMetrics config."); getLogger().info("Metrics disabled per PluginMetrics config.");
} }