Added login tries tracking.
This commit is contained in:
parent
2c16cb8318
commit
1f274c3034
|
@ -18,8 +18,9 @@ public class LoginCommand {
|
|||
private static Text enterPassword = new LiteralText(SimpleAuth.config.lang.enterPassword);
|
||||
private static Text wrongPassword = new LiteralText(SimpleAuth.config.lang.wrongPassword);
|
||||
private static Text alreadyAuthenticated = new LiteralText(SimpleAuth.config.lang.alreadyAuthenticated);
|
||||
//private static Text loginTriesExceeded = new LiteralText("§4Too many login tries.");
|
||||
private static Text loginTriesExceeded = new LiteralText(SimpleAuth.config.lang.loginTriesExceeded);
|
||||
private static Text successfullyAuthenticated = new LiteralText(SimpleAuth.config.lang.successfullyAuthenticated);
|
||||
private static int maxLoginTries = 3;
|
||||
|
||||
public static void registerCommand(CommandDispatcher<ServerCommandSource> dispatcher) {
|
||||
// Registering the "/login" command
|
||||
|
@ -41,6 +42,9 @@ public class LoginCommand {
|
|||
player.sendMessage(alreadyAuthenticated);
|
||||
return 0;
|
||||
}
|
||||
else if(SimpleAuth.deauthenticatedUsers.get(player) >= maxLoginTries && maxLoginTries != -1)
|
||||
player.networkHandler.disconnect(loginTriesExceeded);
|
||||
|
||||
else if(SimpleAuth.config.main.enableGlobalPassword) {
|
||||
if (AuthHelper.checkPass("globalPass", pass.toCharArray())) {
|
||||
SimpleAuth.authenticatePlayer(player, successfullyAuthenticated);
|
||||
|
@ -51,8 +55,12 @@ public class LoginCommand {
|
|||
SimpleAuth.authenticatePlayer(player, successfullyAuthenticated);
|
||||
return 1;
|
||||
}
|
||||
else if(maxLoginTries == 1)
|
||||
player.networkHandler.disconnect(wrongPassword);
|
||||
//player.sendMessage(wrongPassword);
|
||||
|
||||
player.sendMessage(wrongPassword);
|
||||
SimpleAuth.deauthenticatedUsers.replace(player, SimpleAuth.deauthenticatedUsers.get(player) + 1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ public class AuthEventHandler {
|
|||
|
||||
// Player joining the server
|
||||
public static void onPlayerJoin(ServerPlayerEntity player) {
|
||||
// Marking player as not authenticated, (re)setting login tries to zero
|
||||
SimpleAuth.deauthenticatedUsers.put(player, 0);
|
||||
/*CompoundTag loginTries = new CompoundTag();
|
||||
loginTries.putInt("loginTries", 0);
|
||||
|
|
|
@ -50,6 +50,9 @@ public class AuthConfig {
|
|||
public boolean playerInvulnerable = true;
|
||||
// If player should be invisible to mobs before authentication
|
||||
public boolean playerInvisible = true;
|
||||
// Maximum login tries before kicking the player
|
||||
// Set to -1 to allow unlimited, not recommended however
|
||||
public int maxLoginTries = 1;
|
||||
// Time after which player will be kicked if not authenticated - in seconds
|
||||
public int delay = 60;
|
||||
// Disables registering and forces logging in with global password
|
||||
|
@ -67,6 +70,7 @@ public class AuthConfig {
|
|||
public String matchPassword = "§6Passwords must match!";
|
||||
public String passwordUpdated = "§4Your password was updated successfully!";
|
||||
public String loginRequired = "§cYou are not authenticated!\n§6Use /login to authenticate!";
|
||||
public String loginTriesExceeded = "§4Too many login tries.";
|
||||
public String globalPasswordSet = "§aGlobal password was successfully set!";
|
||||
public String cannotChangePassword = "§aYou cannot change password!";
|
||||
public String cannotUnregister = "§aYou cannot unregister this account!";
|
||||
|
|
Loading…
Reference in New Issue