super("login PLAYER PASSWORD", "Login using CustAuth.");
}
public void execute(Player player, String message) {
Authenticator auth = player.getServer().authenticator;
if (!allowUse(player, auth)) {
return;
}
String[] arguments = extractArguments(message);
if (arguments.length != 2) {
player.addTMessage(Color.RED, "Wrong number of arguments!");
return;
}
String userName = arguments[0];
String password = arguments[1];
if (player.getServer().playerList.findPlayerExact(userName) != null) {
player.addTMessage(Color.RED, "Login failed! Player already in server.");
return;
}
if (!auth.isRegistered(userName)) {
player.addTMessage(Color.RED, "You are not registered!");
player.addTMessage(Color.RED, "Use the %s command to register.", (commandPrefix() + "register"));
return;
}
if (!auth.loginBanTimeOver(player)) {
player.addTMessage(Color.RED, "You've to wait %s seconds before another try to login.", auth.leftBanTime(player));
return;
}
if (auth.login(player, userName, password)) {
player.addTMessage(Color.GRAY, "Login successfull!");
player.addTMessage(Color.GRAY, "Please reconnect to the server within %s seconds to complete the CustAuth process.", Authenticator.REQUEST_EXPIRATION);
player.setUsedAuthenticator(true);
auth.unbanLogin(player);
} else {
player.addTMessage(Color.RED, "Login failed! Password missmatch.");
auth.banLogin(player);
}
}