Fixed bad cast, added more structure for handling multiple players.
This commit is contained in:
parent
c14892f40b
commit
a087e07052
@ -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() {
|
||||||
|
Loading…
Reference in New Issue
Block a user