Properly check for numbers in pvdevl. Fixes #334
This commit is contained in:
@@ -30,7 +30,7 @@ public enum Lang {
|
||||
DELETE_VAULT("delete-vault", "&fDeleted vault &a%v"),
|
||||
DELETE_OTHER_VAULT("delete-other-vault", "&fDeleted vault &a%v &fof &a%p"),
|
||||
PLAYER_ONLY("player-only", "&cSorry but that can only be run by a player!"),
|
||||
MUST_BE_NUMBER("must-be-number", "&cYou need to specify a number between 1-99"),
|
||||
MUST_BE_NUMBER("must-be-number", "&cYou need to specify a valid number."),
|
||||
DELETE_VAULT_ERROR("delete-vault-error", "&cError deleting vault :("),
|
||||
NO_PERMS("no-permissions", "&cYou don''t have permission for that!"),
|
||||
INSUFFICIENT_FUNDS("insufficient-funds", "&cYou don''t have enough money for that!"),
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user