From 316e80b35c143451c9d8df68f52085c9ce0639ec Mon Sep 17 00:00:00 2001 From: "Iain E. Davis" Date: Sat, 3 Aug 2013 18:05:09 -0500 Subject: [PATCH] added public method that will cancel the metrics task. --- .../src/main/java/org/mcstats/Metrics.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/mods/bukkit/metrics/src/main/java/org/mcstats/Metrics.java b/mods/bukkit/metrics/src/main/java/org/mcstats/Metrics.java index 8fbb3ac..57529e1 100644 --- a/mods/bukkit/metrics/src/main/java/org/mcstats/Metrics.java +++ b/mods/bukkit/metrics/src/main/java/org/mcstats/Metrics.java @@ -283,6 +283,17 @@ public void enable() throws IOException { } } + /** + * Cancels the metric task, needed so that a plugin using embedded metrics can shutdown any tasks it started properly. + * + */ + public void cancelTask() { + if (task != null) { + task.cancel(); + task = null; + } + } + /** * Disables metrics for the server by setting "opt-out" to true in the config file and canceling the metrics task. * @@ -298,10 +309,7 @@ public void disable() throws IOException { } // Disable Task, if it is running - if (task != null) { - task.cancel(); - task = null; - } + this.cancelTask(); } }