class SetPasswordCommand extends PlayerCommand {

    @Override
    protected void runCommand(Player player, List<String> arguments) {
        if (recoveryService.canChangePassword(player)) {
            String name = player.getName();
            String password = arguments.get(0);

            ValidationResult result = validationService.validatePassword(password, name);
            if (!result.hasError()) {
                HashedPassword hashedPassword = passwordSecurity.computeHash(password, name);
                dataSource.updatePassword(name, hashedPassword);
                ConsoleLogger.info("Player '" + name + "' has changed their password from recovery");
                commonService.send(player, MessageKey.PASSWORD_CHANGED_SUCCESS);
            } else {
                commonService.send(player, result.getMessageKey(), result.getArgs());
            }
        }
    }

}