Error handling for user entering non-integer value for radius of safeclaim and warclaim, along with usage info

This commit is contained in:
Brettflan 2011-08-03 15:38:54 -05:00
parent 3bcfd5cff5
commit a38267fe74
2 changed files with 18 additions and 2 deletions

View File

@ -36,7 +36,15 @@ public class FCommandSafeclaim extends FBaseCommand {
// Was a radius set?
if (parameters.size() > 0) {
int radius = Integer.parseInt(parameters.get(0));
int radius;
try {
radius = Integer.parseInt(parameters.get(0));
}
catch(NumberFormatException ex) {
sendMessage("Usage: " + getUseageTemplate(false));
sendMessage("The radius value must be an integer.");
return;
}
FLocation from = playerFlocation.getRelative(radius, radius);
FLocation to = playerFlocation.getRelative(-radius, -radius);

View File

@ -35,7 +35,15 @@ public class FCommandWarclaim extends FBaseCommand {
// Was a radius set?
if (parameters.size() > 0) {
int radius = Integer.parseInt(parameters.get(0));
int radius;
try {
radius = Integer.parseInt(parameters.get(0));
}
catch(NumberFormatException ex) {
sendMessage("Usage: " + getUseageTemplate(false));
sendMessage("The radius value must be an integer.");
return;
}
FLocation from = playerFlocation.getRelative(radius, radius);
FLocation to = playerFlocation.getRelative(-radius, -radius);