Error handling for user entering non-integer value for radius of safeclaim and warclaim, along with usage info
This commit is contained in:
parent
3bcfd5cff5
commit
a38267fe74
@ -36,7 +36,15 @@ public class FCommandSafeclaim extends FBaseCommand {
|
|||||||
|
|
||||||
// Was a radius set?
|
// Was a radius set?
|
||||||
if (parameters.size() > 0) {
|
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 from = playerFlocation.getRelative(radius, radius);
|
||||||
FLocation to = playerFlocation.getRelative(-radius, -radius);
|
FLocation to = playerFlocation.getRelative(-radius, -radius);
|
||||||
|
@ -35,7 +35,15 @@ public class FCommandWarclaim extends FBaseCommand {
|
|||||||
|
|
||||||
// Was a radius set?
|
// Was a radius set?
|
||||||
if (parameters.size() > 0) {
|
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 from = playerFlocation.getRelative(radius, radius);
|
||||||
FLocation to = playerFlocation.getRelative(-radius, -radius);
|
FLocation to = playerFlocation.getRelative(-radius, -radius);
|
||||||
|
Loading…
Reference in New Issue
Block a user