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

View File

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