catch NumberFormatException, fixed off-by-one error

This commit is contained in:
Gibstick 2013-07-19 11:28:41 -04:00
parent d26c620541
commit f92247c170
3 changed files with 8 additions and 5 deletions

BIN
dist/DiscoSheep.jar vendored

Binary file not shown.

View File

@ -74,7 +74,7 @@ public class DiscoParty {
}
public DiscoParty setDuration(int duration) throws IllegalArgumentException {
if (duration < DiscoParty.maxDuration) {
if (duration <= DiscoParty.maxDuration) {
this.duration = duration;
return this;
} else {
@ -92,7 +92,7 @@ public class DiscoParty {
}
public DiscoParty setRadius(int radius) throws IllegalArgumentException {
if (radius < DiscoParty.maxRadius) {
if (radius <= DiscoParty.maxRadius) {
this.radius = radius;
return this;
} else {
@ -101,7 +101,7 @@ public class DiscoParty {
}
public DiscoParty setSheep(int sheep) throws IllegalArgumentException {
if (sheep < DiscoParty.maxSheep) {
if (sheep <= DiscoParty.maxSheep) {
this.sheep = sheep;
return this;
} else {

View File

@ -15,7 +15,6 @@ public class DiscoSheepCommandExecutor implements CommandExecutor {
public DiscoSheepCommandExecutor(DiscoSheep parent) {
this.parent = parent;
}
private static final String PERMISSION_PARTY = "discosheep.party";
private static final String PERMISSION_ALL = "discosheep.partyall";
private static final String PERMISSION_FIREWORKS = "discosheep.fireworks";
@ -42,7 +41,11 @@ public class DiscoSheepCommandExecutor implements CommandExecutor {
private int parseNextIntArg(String[] args, int i) {
if (i < args.length - 1) {
try {
return Integer.parseInt(args[i + 1]);
} catch (NumberFormatException e) {
return -1;
}
}
return -1;
}