Fixed bad cast, added more structure for handling multiple players.

This commit is contained in:
RangerMauve 2013-06-30 17:39:57 -04:00
parent c14892f40b
commit a087e07052
2 changed files with 12 additions and 5 deletions

View File

@ -14,6 +14,7 @@ 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 ArrayList<Player> playerArray = new ArrayList<Player>();
private SheepDeshearer deshear = new SheepDeshearer(sheepArray); private SheepDeshearer deshear = new SheepDeshearer(sheepArray);
private static final DyeColor[] discoColours = { private static final DyeColor[] discoColours = {
DyeColor.RED, DyeColor.RED,
@ -51,6 +52,10 @@ public final class DiscoSheep extends JavaPlugin {
return sheepArray; return sheepArray;
} }
ArrayList<Player> getPlayers(){
return this.playerArray;
}
void spawnSheep(World world, Location loc) { void spawnSheep(World world, Location loc) {
Sheep newSheep = (Sheep) world.spawnEntity(loc, EntityType.SHEEP); Sheep newSheep = (Sheep) world.spawnEntity(loc, EntityType.SHEEP);
newSheep.setMaxHealth(10000); newSheep.setMaxHealth(10000);
@ -103,21 +108,23 @@ public final class DiscoSheep extends JavaPlugin {
// Called after discosheep is stopped // Called after discosheep is stopped
void cleanUp() { void cleanUp() {
removeAllSheep(); removeAllSheep();
this.playerArray.clear();
} }
void scheduleUpdate() { void scheduleUpdate() {
updater.runTaskLater((Plugin) updater, updater.frequency); updater.runTaskLater(this, updater.frequency);
} }
void startDisco(int frequency, int duration, List<Player> players) { void startDisco(int duration, List<Player> players) {
this.playerArray.addAll(players);
for(Player player : players){ for(Player player : players){
this.spawnSheep(player, this.defaultSheepAmount); this.spawnSheep(player, this.defaultSheepAmount);
} }
updater.start(frequency, duration); updater.start(duration,this.defaultFrequency);
} }
void startDisco(List<Player> players) { void startDisco(List<Player> players) {
this.startDisco(this.defaultFrequency,this.defaultDuration,players); this.startDisco(this.defaultDuration,players);
} }
void stopDisco() { void stopDisco() {