diff --git a/src/gibstick/bukkit/discosheep/DiscoSheep.java b/src/gibstick/bukkit/discosheep/DiscoSheep.java index f632069..ba63afc 100644 --- a/src/gibstick/bukkit/discosheep/DiscoSheep.java +++ b/src/gibstick/bukkit/discosheep/DiscoSheep.java @@ -1,6 +1,7 @@ package gibstick.bukkit.discosheep; import java.util.ArrayList; +import org.bukkit.DyeColor; import org.bukkit.Location; import org.bukkit.World; import org.bukkit.entity.EntityType; @@ -12,6 +13,19 @@ import org.bukkit.plugin.java.JavaPlugin; public final class DiscoSheep extends JavaPlugin { private ArrayList sheepArray = new ArrayList(); + private static final DyeColor[] discoColours = { + DyeColor.RED, + DyeColor.ORANGE, + DyeColor.YELLOW, + DyeColor.GREEN, + DyeColor.BLUE, + DyeColor.LIGHT_BLUE, + DyeColor.PINK, + DyeColor.MAGENTA, + DyeColor.LIME, + DyeColor.CYAN, + DyeColor.PURPLE + }; // array of accetable disco colours (order not important) private DiscoUpdater updater = new DiscoUpdater(this); // radius for random sheep spawns around player private static int sheepSpawnRadius = 5; @@ -63,10 +77,10 @@ public final class DiscoSheep extends JavaPlugin { getSheep().clear(); } - // Cycle colours of all sheep in the array - void cycleSheepColours() { - for (Sheep shep : getSheep()) { - //sheepArray.get(i) something something + // Set a random colour for all sheep in array + void randomizeSheepColours() { + for (Sheep sheep : getSheep()) { + sheep.setColor(discoColours[(int)Math.random() * discoColours.length]); } } diff --git a/src/gibstick/bukkit/discosheep/DiscoUpdater.java b/src/gibstick/bukkit/discosheep/DiscoUpdater.java index cf6ff55..d383c84 100644 --- a/src/gibstick/bukkit/discosheep/DiscoUpdater.java +++ b/src/gibstick/bukkit/discosheep/DiscoUpdater.java @@ -27,7 +27,7 @@ public class DiscoUpdater extends BukkitRunnable { @Override public void run() { if (duration > 0) { - parent.cycleSheepColours(); + parent.randomizeSheepColours(); parent.playSounds(); duration -= frequency; parent.scheduleUpdate();