if (database.isAuthAvailable(name)) {
sender.sendMessage(m._("user_regged"));
return true;
}
PlayerAuth auth = new PlayerAuth(name, hash, "198.18.0.1", 0);
if (!database.saveAuth(auth)) {
sender.sendMessage(m._("error"));
return true;
}
sender.sendMessage(m._("registered"));
ConsoleLogger.info(args[1] + " registered");
} catch (NoSuchAlgorithmException ex) {
ConsoleLogger.showError(ex.getMessage());
sender.sendMessage(m._("error"));
}
} else if (args[0].equalsIgnoreCase("changepassword")) {
if (args.length != 3) {
sender.sendMessage("Usage: /authme changepassword playername newpassword");
return true;
}
try {
String name = args[1].toLowerCase();
String hash = PasswordSecurity.getHash(settings.getPasswordHash(), args[2]);
PlayerAuth auth = null;
if (PlayerCache.getInstance().isAuthenticated(name)) {
auth = PlayerCache.getInstance().getAuth(name);
} else if (database.isAuthAvailable(name)) {
auth = database.getAuth(name);
} else {
sender.sendMessage(m._("unknown_user"));
return true;
}
auth.setHash(hash);
if (!database.updatePassword(auth)) {
sender.sendMessage(m._("error"));
return true;
}