Made sure to cancel previously scheduled update before starting a new loop of them.

This commit is contained in:
RangerMauve 2013-06-30 18:48:39 -04:00
parent 9d4f65cec9
commit 112d3f0f08

View File

@ -29,7 +29,7 @@ public final class DiscoSheep extends JavaPlugin {
DyeColor.CYAN, DyeColor.CYAN,
DyeColor.PURPLE DyeColor.PURPLE
}; // array of accetable disco colours (order not important) }; // array of accetable disco colours (order not important)
private DiscoUpdater updater = new DiscoUpdater(this); private DiscoUpdater updater;
// radius for random sheep spawns around player // radius for random sheep spawns around player
private final int sheepSpawnRadius = 5; private final int sheepSpawnRadius = 5;
private final int defaultSheepAmount = 10; private final int defaultSheepAmount = 10;
@ -116,7 +116,8 @@ public final class DiscoSheep extends JavaPlugin {
} }
void scheduleUpdate() { void scheduleUpdate() {
new DiscoUpdater(this).runTaskLater(this, this.frequency); updater = new DiscoUpdater(this);
updater.runTaskLater(this, this.frequency);
} }
void startDisco(int duration, List<Player> players) { void startDisco(int duration, List<Player> players) {
@ -140,5 +141,8 @@ public final class DiscoSheep extends JavaPlugin {
removeAllSheep(); removeAllSheep();
this.playerArray.clear(); this.playerArray.clear();
this.duration = 0; this.duration = 0;
if(updater != null)
updater.cancel();
updater = null;
} }
} }