Add Third Party PreLogin Event

This commit is contained in:
Xephi59 2015-08-20 23:29:02 +02:00
parent 86e1b8df7c
commit e1eb22239a
2 changed files with 46 additions and 0 deletions

View File

@ -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 AuthMe try to teleport a player
*
* @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;
}
}

View File

@ -13,6 +13,7 @@ import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache; import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.cache.limbo.LimboCache; import fr.xephi.authme.cache.limbo.LimboCache;
import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.events.AuthMeAsyncPreLoginEvent;
import fr.xephi.authme.listener.AuthMePlayerListener; import fr.xephi.authme.listener.AuthMePlayerListener;
import fr.xephi.authme.security.PasswordSecurity; import fr.xephi.authme.security.PasswordSecurity;
import fr.xephi.authme.security.RandomString; import fr.xephi.authme.security.RandomString;
@ -113,6 +114,10 @@ public class AsyncronousLogin {
m.send(player, "vb_nonActiv"); m.send(player, "vb_nonActiv");
return null; return null;
} }
AuthMeAsyncPreLoginEvent event = new AuthMeAsyncPreLoginEvent(player);
Bukkit.getServer().getPluginManager().callEvent(event);
if (!event.canLogin())
return null;
return pAuth; return pAuth;
} }