catch NumberFormatException, fixed off-by-one error
This commit is contained in:
parent
d26c620541
commit
f92247c170
BIN
dist/DiscoSheep.jar
vendored
BIN
dist/DiscoSheep.jar
vendored
Binary file not shown.
@ -74,7 +74,7 @@ public class DiscoParty {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public DiscoParty setDuration(int duration) throws IllegalArgumentException {
|
public DiscoParty setDuration(int duration) throws IllegalArgumentException {
|
||||||
if (duration < DiscoParty.maxDuration) {
|
if (duration <= DiscoParty.maxDuration) {
|
||||||
this.duration = duration;
|
this.duration = duration;
|
||||||
return this;
|
return this;
|
||||||
} else {
|
} else {
|
||||||
@ -92,7 +92,7 @@ public class DiscoParty {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public DiscoParty setRadius(int radius) throws IllegalArgumentException {
|
public DiscoParty setRadius(int radius) throws IllegalArgumentException {
|
||||||
if (radius < DiscoParty.maxRadius) {
|
if (radius <= DiscoParty.maxRadius) {
|
||||||
this.radius = radius;
|
this.radius = radius;
|
||||||
return this;
|
return this;
|
||||||
} else {
|
} else {
|
||||||
@ -101,7 +101,7 @@ public class DiscoParty {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public DiscoParty setSheep(int sheep) throws IllegalArgumentException {
|
public DiscoParty setSheep(int sheep) throws IllegalArgumentException {
|
||||||
if (sheep < DiscoParty.maxSheep) {
|
if (sheep <= DiscoParty.maxSheep) {
|
||||||
this.sheep = sheep;
|
this.sheep = sheep;
|
||||||
return this;
|
return this;
|
||||||
} else {
|
} else {
|
||||||
|
@ -15,7 +15,6 @@ public class DiscoSheepCommandExecutor implements CommandExecutor {
|
|||||||
public DiscoSheepCommandExecutor(DiscoSheep parent) {
|
public DiscoSheepCommandExecutor(DiscoSheep parent) {
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String PERMISSION_PARTY = "discosheep.party";
|
private static final String PERMISSION_PARTY = "discosheep.party";
|
||||||
private static final String PERMISSION_ALL = "discosheep.partyall";
|
private static final String PERMISSION_ALL = "discosheep.partyall";
|
||||||
private static final String PERMISSION_FIREWORKS = "discosheep.fireworks";
|
private static final String PERMISSION_FIREWORKS = "discosheep.fireworks";
|
||||||
@ -42,7 +41,11 @@ public class DiscoSheepCommandExecutor implements CommandExecutor {
|
|||||||
|
|
||||||
private int parseNextIntArg(String[] args, int i) {
|
private int parseNextIntArg(String[] args, int i) {
|
||||||
if (i < args.length - 1) {
|
if (i < args.length - 1) {
|
||||||
return Integer.parseInt(args[i + 1]);
|
try {
|
||||||
|
return Integer.parseInt(args[i + 1]);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user