Properly check for numbers in pvdevl. Fixes #334

This commit is contained in:
Trent Hensler
2018-02-17 12:25:12 -06:00
parent f6e94682e1
commit 668a3be6a9
2 changed files with 12 additions and 3 deletions
@@ -225,7 +225,7 @@ public class VaultOperations {
if (isLocked()) {
return;
}
if (arg.matches("^[0-9]{1,2}$")) {
if (isNumber(arg)) {
int number = 0;
try {
number = Integer.parseInt(arg);
@@ -261,7 +261,7 @@ public class VaultOperations {
return;
}
if (sender.hasPermission("playervaults.delete")) {
if (arg.matches("^[0-9]{1,2}$")) {
if (isNumber(arg)) {
int number = 0;
try {
number = Integer.parseInt(arg);
@@ -285,4 +285,13 @@ public class VaultOperations {
sender.sendMessage(Lang.TITLE.toString() + Lang.NO_PERMS);
}
}
private static boolean isNumber(String check) {
try {
Integer.parseInt(check);
return true;
} catch (NumberFormatException e) {
return false;
}
}
}