From 112d3f0f08168762d40a9db7bea5df310a26d893 Mon Sep 17 00:00:00 2001 From: RangerMauve Date: Sun, 30 Jun 2013 18:48:39 -0400 Subject: [PATCH] Made sure to cancel previously scheduled update before starting a new loop of them. --- src/gibstick/bukkit/discosheep/DiscoSheep.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/gibstick/bukkit/discosheep/DiscoSheep.java b/src/gibstick/bukkit/discosheep/DiscoSheep.java index 6b26082..a020b87 100644 --- a/src/gibstick/bukkit/discosheep/DiscoSheep.java +++ b/src/gibstick/bukkit/discosheep/DiscoSheep.java @@ -29,7 +29,7 @@ public final class DiscoSheep extends JavaPlugin { DyeColor.CYAN, DyeColor.PURPLE }; // array of accetable disco colours (order not important) - private DiscoUpdater updater = new DiscoUpdater(this); + private DiscoUpdater updater; // radius for random sheep spawns around player private final int sheepSpawnRadius = 5; private final int defaultSheepAmount = 10; @@ -116,7 +116,8 @@ public final class DiscoSheep extends JavaPlugin { } void scheduleUpdate() { - new DiscoUpdater(this).runTaskLater(this, this.frequency); + updater = new DiscoUpdater(this); + updater.runTaskLater(this, this.frequency); } void startDisco(int duration, List players) { @@ -140,5 +141,8 @@ public final class DiscoSheep extends JavaPlugin { removeAllSheep(); this.playerArray.clear(); this.duration = 0; + if(updater != null) + updater.cancel(); + updater = null; } }