preparations for command switch parsing

This commit is contained in:
Charlie Wang 2013-07-11 19:07:46 -04:00
parent 43fd8815f5
commit 291a39ccc0
2 changed files with 9 additions and 7 deletions

View File

@ -28,7 +28,7 @@ public class DiscoParty {
private int duration, frequency = 20, numSheep = 5;
private final int defaultDuration = 300; // ticks for entire party
private final int defaultFrequency = 10; // ticks per state change
private final int sheepSpawnRadius = 5;
private final int defaultSheepSpawnRadius = 5;
private final int defaultSheepAmount = 10;
private boolean doFireworks = false;
private int state = 0;
@ -67,7 +67,7 @@ public class DiscoParty {
}
// Spawn some number of sheep next to given player
void spawnSheep(int num) {
void spawnSheep(int num, int sheepSpawnRadius) {
Location loc;
World world = player.getWorld();
@ -223,12 +223,12 @@ public class DiscoParty {
updater.runTaskLater(ds, this.frequency);
}
void startDisco(int duration, boolean fireworks) {
void startDisco(int duration, int sheepAmount, int radius, boolean fireworks) {
if (this.duration > 0) {
stopDisco();
}
this.doFireworks = fireworks;
this.spawnSheep(this.defaultSheepAmount);
this.spawnSheep(sheepAmount, radius);
this.frequency = this.defaultFrequency;
this.duration = this.defaultDuration;
this.scheduleUpdate();
@ -236,7 +236,7 @@ public class DiscoParty {
}
void startDisco(boolean fireworks) {
this.startDisco(this.defaultDuration, fireworks);
this.startDisco(this.defaultDuration, this.defaultSheepAmount, this.defaultSheepSpawnRadius, fireworks);
}
void stopDisco() {

View File

@ -37,6 +37,8 @@ public class DiscoSheepCommandExecutor implements CommandExecutor {
Player player = null;
boolean isPlayer = false;
boolean fireworks = false;
int sheepNumber = 0;
int radius = 0;
this.curSender = sender;
if (sender instanceof Player) {
@ -49,8 +51,8 @@ public class DiscoSheepCommandExecutor implements CommandExecutor {
return true;
}
for (String arg : args) {
switch (arg) {
for (int i = 1; i < args.length; i++) {
switch (args[i]) {
case "-fw":
if (senderHasPerm(PERMISSION_FIREWORKS)) {
fireworks = !fireworks;