diff --git a/src/main/java/fr/xephi/authme/events/AuthMeAsyncPreLoginEvent.java b/src/main/java/fr/xephi/authme/events/AuthMeAsyncPreLoginEvent.java new file mode 100644 index 000000000..1995fbd0b --- /dev/null +++ b/src/main/java/fr/xephi/authme/events/AuthMeAsyncPreLoginEvent.java @@ -0,0 +1,41 @@ +package fr.xephi.authme.events; + +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +/** + * + * This event is call when a player try to /login + * + * @author Xephi59 + */ +public class AuthMeAsyncPreLoginEvent extends Event { + + private Player player; + private boolean canLogin = true; + private static final HandlerList handlers = new HandlerList(); + + public AuthMeAsyncPreLoginEvent(Player player) { + super(true); + this.player = player; + } + + public Player getPlayer() { + return player; + } + + public boolean canLogin() { + return canLogin; + } + + public void setCanLogin(boolean canLogin) { + this.canLogin = canLogin; + } + + @Override + public HandlerList getHandlers() { + return handlers; + } + +} diff --git a/src/main/java/fr/xephi/authme/process/login/AsyncronousLogin.java b/src/main/java/fr/xephi/authme/process/login/AsyncronousLogin.java index e7c49af87..302203b7d 100644 --- a/src/main/java/fr/xephi/authme/process/login/AsyncronousLogin.java +++ b/src/main/java/fr/xephi/authme/process/login/AsyncronousLogin.java @@ -13,6 +13,7 @@ import fr.xephi.authme.cache.auth.PlayerAuth; import fr.xephi.authme.cache.auth.PlayerCache; import fr.xephi.authme.cache.limbo.LimboCache; import fr.xephi.authme.datasource.DataSource; +import fr.xephi.authme.events.AuthMeAsyncPreLoginEvent; import fr.xephi.authme.listener.AuthMePlayerListener; import fr.xephi.authme.security.PasswordSecurity; import fr.xephi.authme.security.RandomString; @@ -113,6 +114,10 @@ public class AsyncronousLogin { m.send(player, "vb_nonActiv"); return null; } + AuthMeAsyncPreLoginEvent event = new AuthMeAsyncPreLoginEvent(player); + Bukkit.getServer().getPluginManager().callEvent(event); + if (!event.canLogin()) + return null; return pAuth; }