From 7ee82882fc4fc53ade5a5c8cac0bc0474f08f78c Mon Sep 17 00:00:00 2001 From: Deichor Date: Tue, 10 Dec 2024 03:22:39 +0300 Subject: [PATCH] Added kick method for joinverifier --- .../fr/xephi/authme/listener/OnJoinVerifier.java | 12 ++++++++++++ .../fr/xephi/authme/listener/PlayerListener.java | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/java/fr/xephi/authme/listener/OnJoinVerifier.java b/src/main/java/fr/xephi/authme/listener/OnJoinVerifier.java index a617c2fa..3a7f9a50 100644 --- a/src/main/java/fr/xephi/authme/listener/OnJoinVerifier.java +++ b/src/main/java/fr/xephi/authme/listener/OnJoinVerifier.java @@ -94,6 +94,18 @@ public class OnJoinVerifier implements Reloadable { } } + /** + * Checks whether email verification is required, and if so, whether the email is verified. + * + * @param isAuthAvailable whether or not the player's email is verified + * @throws FailedVerificationException if the email verification is not completed + */ + public void checkKickNotVerified(boolean isAuthAvailable) throws FailedVerificationException { + if (!isAuthAvailable && settings.getProperty(RestrictionSettings.KICK_NOT_VERIFIED)) { + throw new FailedVerificationException(MessageKey.MUST_VERIFIED_MESSAGE); + } + } + /** * Checks that the name adheres to the configured username restrictions. * diff --git a/src/main/java/fr/xephi/authme/listener/PlayerListener.java b/src/main/java/fr/xephi/authme/listener/PlayerListener.java index 60aa7401..93b8f4f8 100644 --- a/src/main/java/fr/xephi/authme/listener/PlayerListener.java +++ b/src/main/java/fr/xephi/authme/listener/PlayerListener.java @@ -150,8 +150,9 @@ public class PlayerListener implements Listener { // Slow, blocking checks try { final PlayerAuth auth = dataSource.getAuth(name); - final boolean isAuthAvailable = auth != null; + final boolean isAuthAvailable = auth != null && auth.isEmailVerified(); onJoinVerifier.checkKickNonRegistered(isAuthAvailable); + onJoinVerifier.checkKickNotVerified(isAuthAvailable); onJoinVerifier.checkAntibot(name, isAuthAvailable); onJoinVerifier.checkNameCasing(name, auth); final String ip = event.getAddress().getHostAddress();