Skip to content

Commit

Permalink
Update error messages for wrong command arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
lscgh committed Jan 25, 2024
1 parent 7a85783 commit d39d5a3
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,12 @@ public boolean onCommand(CommandSender sender, Command command, String label, St

try {
config = this.createGameConfigFromCommand((Player)sender, args);
} catch(InvalidArgCountException | OpponentPlayerNotFoundException | NumberFormatException e) {
sender.sendMessage(e.getMessage());
} catch(InvalidArgCountException | OpponentPlayerNotFoundException e) {
sender.sendMessage(ChatColor.RED + e.getMessage() + ChatColor.RESET);
return true;
} catch(NumberFormatException e) {
String nonNumberString = e.getMessage().substring(19, e.getMessage().length() - 2);
sender.sendMessage(ChatColor.RED + "Error: expected number at '" + nonNumberString + "'" + ChatColor.RESET);
return true;
}

Expand Down

0 comments on commit d39d5a3

Please sign in to comment.