Merge pull request #32 from Xephi/master

uP
This commit is contained in:
Gabriele C. 2015-08-21 23:25:51 +02:00
commit 876b3858ec
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 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;
}
}

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.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;
}