Added actual command registering stuff, maybe?
This commit is contained in:
parent
803470a76b
commit
14a349e6a0
@ -1,6 +1,7 @@
|
||||
package gibstick.bukkit.discosheep;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
@ -29,7 +30,11 @@ public final class DiscoSheep extends JavaPlugin {
|
||||
}; // 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;
|
||||
private final int sheepSpawnRadius = 5;
|
||||
private final int defaultSheepAmount = 10;
|
||||
private final int defaultDuration = 1000;// ticks
|
||||
private final int defaultFrequency = 20;// ticks per state change
|
||||
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
@ -104,12 +109,15 @@ public final class DiscoSheep extends JavaPlugin {
|
||||
updater.runTaskLater((Plugin) updater, updater.frequency);
|
||||
}
|
||||
|
||||
void startDisco(int frequency, int duration) {
|
||||
void startDisco(int frequency, int duration, List<Player> players) {
|
||||
for(Player player : players){
|
||||
this.spawnSheep(player, this.defaultSheepAmount);
|
||||
}
|
||||
updater.start(frequency, duration);
|
||||
}
|
||||
|
||||
void startDisco() {
|
||||
this.startDisco();
|
||||
void startDisco(List<Player> players) {
|
||||
this.startDisco(this.defaultFrequency,this.defaultDuration,players);
|
||||
}
|
||||
|
||||
void stopDisco() {
|
||||
|
@ -1,8 +1,11 @@
|
||||
package gibstick.bukkit.discosheep;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class DiscoSheepCommandExecutor implements CommandExecutor {
|
||||
|
||||
@ -14,7 +17,11 @@ public class DiscoSheepCommandExecutor implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
|
||||
if(sender instanceof Player){
|
||||
List<Player> players = new ArrayList<Player>();
|
||||
players.add((Player)sender);
|
||||
parent.startDisco(players);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -4,8 +4,6 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
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;
|
||||
|
||||
@ -19,8 +17,8 @@ public class DiscoUpdater extends BukkitRunnable {
|
||||
}
|
||||
|
||||
public void start(int duration, int frequency) {
|
||||
this.frequency = this.defaultFrequency;
|
||||
this.duration = this.defaultDuration;
|
||||
this.frequency = frequency;
|
||||
this.duration = duration;
|
||||
parent.scheduleUpdate();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user