Skip to content

Commit

Permalink
Merge pull request #290 from Dans-Plugins/bug-fix/validate-age-input
Browse files Browse the repository at this point in the history
Bug Fix - Validate Age Input
  • Loading branch information
dmccoystephenson authored Dec 5, 2022
2 parents 21fd6f0 + 08f7d04 commit 4e4b0c9
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,14 @@ public void changeAge(CommandSender sender, String[] args) {
if (card.getPlayerUUID().equals(player.getUniqueId())) {

if (args.length > 1) {
card.setAge(Integer.parseInt(medievalRoleplayEngine.argumentParser.createStringFromFirstArgOnwards(args, 1)));
int newAge;
try {
newAge = Integer.parseInt(medievalRoleplayEngine.argumentParser.createStringFromFirstArgOnwards(args, 1));
} catch(NumberFormatException e) {
player.sendMessage(medievalRoleplayEngine.colorChecker.getNegativeAlertColor() + "Must be a number.");
return;
}
card.setAge(newAge);
player.sendMessage(medievalRoleplayEngine.colorChecker.getPositiveAlertColor() + "Age set! Type /card to see changes.");
}
else {
Expand Down

0 comments on commit 4e4b0c9

Please sign in to comment.