I cannot into boolean logic (fixed limit checking and exceptions)

This commit is contained in:
Gibstick 2013-07-19 18:34:47 -04:00
parent 4855cf753c
commit dbbe9d5dba
3 changed files with 8 additions and 4 deletions

BIN
dist/DiscoSheep.jar vendored

Binary file not shown.

View File

@ -94,7 +94,7 @@ public class DiscoParty {
}
public DiscoParty setDuration(int duration) throws IllegalArgumentException {
if (duration <= DiscoParty.maxDuration || duration > 0) {
if (duration <= DiscoParty.maxDuration && duration > 0) {
this.duration = duration;
return this;
} else {
@ -103,7 +103,7 @@ public class DiscoParty {
}
public DiscoParty setPeriod(int period) throws IllegalArgumentException {
if (period >= DiscoParty.minPeriod || period <= DiscoParty.maxPeriod) {
if (period >= DiscoParty.minPeriod && period <= DiscoParty.maxPeriod) {
this.period = period;
return this;
} else {
@ -112,7 +112,7 @@ public class DiscoParty {
}
public DiscoParty setRadius(int radius) throws IllegalArgumentException {
if (radius <= DiscoParty.maxRadius || radius > 0) {
if (radius <= DiscoParty.maxRadius && radius > 0) {
this.radius = radius;
return this;
} else {
@ -121,7 +121,7 @@ public class DiscoParty {
}
public DiscoParty setSheep(int sheep) throws IllegalArgumentException {
if (sheep <= DiscoParty.maxSheep || sheep > 0) {
if (sheep <= DiscoParty.maxSheep && sheep > 0) {
this.sheep = sheep;
return this;
} else {

View File

@ -187,6 +187,7 @@ public class DiscoSheepCommandExecutor implements CommandExecutor {
} else if (args[i].equalsIgnoreCase("-r")) {
try {
mainParty.setRadius(parseNextIntArg(args, i));
sender.sendMessage("RADIUS OK");
} catch (IllegalArgumentException e) {
sender.sendMessage("Radius must be an integer within the range [1, "
+ DiscoParty.maxRadius + "]");
@ -195,6 +196,7 @@ public class DiscoSheepCommandExecutor implements CommandExecutor {
} else if (args[i].equalsIgnoreCase("-n")) {
try {
mainParty.setSheep(parseNextIntArg(args, i));
sender.sendMessage("SHEEP OK");
} catch (IllegalArgumentException e) {
sender.sendMessage("The number of sheep must be an integer within the range [1, "
+ DiscoParty.maxSheep + "]");
@ -203,6 +205,7 @@ public class DiscoSheepCommandExecutor implements CommandExecutor {
} else if (args[i].equalsIgnoreCase("-t")) {
try {
mainParty.setDuration(parent.toTicks(parseNextIntArg(args, i)));
sender.sendMessage("DURATION OK");
} catch (IllegalArgumentException e) {
sender.sendMessage("The duration in seconds must be an integer within the range [1, "
+ parent.toSeconds(DiscoParty.maxDuration) + "]");
@ -211,6 +214,7 @@ public class DiscoSheepCommandExecutor implements CommandExecutor {
} else if (args[i].equalsIgnoreCase("-p")) {
try {
mainParty.setPeriod(parseNextIntArg(args, i));
sender.sendMessage("PERIOD OK");
} catch (IllegalArgumentException e) {
sender.sendMessage(
"The period in ticks must be within the range ["