Renamed cycleSheepColours to randomizeSheepColours, and implemented it using a lookup table of accetable disco colours
This commit is contained in:
parent
65122cc098
commit
c3008d9608
@ -1,6 +1,8 @@
|
|||||||
package gibstick.bukkit.discosheep;
|
package gibstick.bukkit.discosheep;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Random;
|
||||||
|
import org.bukkit.DyeColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
@ -12,6 +14,19 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||||||
public final class DiscoSheep extends JavaPlugin {
|
public final class DiscoSheep extends JavaPlugin {
|
||||||
|
|
||||||
private ArrayList<Sheep> sheepArray = new ArrayList<Sheep>();
|
private ArrayList<Sheep> sheepArray = new ArrayList<Sheep>();
|
||||||
|
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);
|
private DiscoUpdater updater = new DiscoUpdater(this);
|
||||||
// radius for random sheep spawns around player
|
// radius for random sheep spawns around player
|
||||||
private static int sheepSpawnRadius = 5;
|
private static int sheepSpawnRadius = 5;
|
||||||
@ -59,10 +74,10 @@ public final class DiscoSheep extends JavaPlugin {
|
|||||||
sheepArray.clear();
|
sheepArray.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cycle colours of all sheep in the array
|
// Set a random colour for all sheep in array
|
||||||
void cycleSheepColours() {
|
void randomizeSheepColours() {
|
||||||
for (int i = 0; i < sheepArray.size(); i++) {
|
for (int i = 0; i < sheepArray.size(); i++) {
|
||||||
//sheepArray.get(i) something something
|
sheepArray.get(i).setColor(discoColours[(int)Math.random() * discoColours.length]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ public class DiscoUpdater extends BukkitRunnable {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (duration > 0) {
|
if (duration > 0) {
|
||||||
parent.cycleSheepColours();
|
parent.randomizeSheepColours();
|
||||||
parent.playSounds();
|
parent.playSounds();
|
||||||
duration -= frequency;
|
duration -= frequency;
|
||||||
parent.scheduleUpdate();
|
parent.scheduleUpdate();
|
||||||
|
Loading…
Reference in New Issue
Block a user