diff --git a/src/gibstick/bukkit/discosheep/DiscoSheep.java b/src/gibstick/bukkit/discosheep/DiscoSheep.java index 856c60b..93c15b3 100644 --- a/src/gibstick/bukkit/discosheep/DiscoSheep.java +++ b/src/gibstick/bukkit/discosheep/DiscoSheep.java @@ -11,7 +11,8 @@ import org.bukkit.entity.Player; public final class DiscoSheep extends JavaPlugin { private ArrayList sheepArray = new ArrayList<>(); - + private DiscoUpdater updater = new DiscoUpdater(); + @Override public void onEnable() { getCommand("ds").setExecutor(new DiscoSheepCommandExecutor(this)); @@ -52,6 +53,35 @@ public final class DiscoSheep extends JavaPlugin { //sheepArray.get(i) something something } } - - + + public void playSounds(){ + // TODO: generate list of players to send sounds to + } + + public void playSounds(Player player){ + //TODO: Add sound playing here + } + + /* + Called after discosheep is stopped + */ + public void cleanUp(){ + removeAllSheep(); + } + + void scheduleUpdate(){ + updater.runTaskLater(updater,frequency); + } + + public void startDisco(int frequency, int duration){ + updater.start(frequency, duration); + } + + public void startDisco(){ + this.startDisco(); + } + + public void stopDisco(){ + updater.stop(); + } } diff --git a/src/gibstick/bukkit/discosheep/DiscoUpdater.java b/src/gibstick/bukkit/discosheep/DiscoUpdater.java new file mode 100644 index 0000000..d152def --- /dev/null +++ b/src/gibstick/bukkit/discosheep/DiscoUpdater.java @@ -0,0 +1,35 @@ +public class DiscoUpdater extends BukkitRunnable{ + private final int defaultDuration = 1000;// ticks + private final int defaultFrequency = 20;// ticks per state change + + int frequency=0,duration=0; + + private DiscoSheep parent; + + public DiscoUpdater(DiscoSheep parent){ + this.parent = parent; + + } + + public void stop(){ + this.duration = 0; + parent.cleanUp(); + } + + public void start(int duration, int frequency){ + this.frequency = this.defaultFrequency; + this.durtion = this.defaultDuration; + parent.scheduleUpdate(); + } + + public void run(){ + if(duration > 0){ + cycleSheepColours(); + playSounds(); + duration -= frequency; + parent.scheduleUpdate(this); + } else { + this.stop(); + } + } +} \ No newline at end of file