Event stores details for players attempting to log in
@EventHandler
public void onPlayerLogin(PlayerLoginEvent e) {
Player tryingToLogin = e.getPlayer();
//Disallowing a player login
e.disallow(PlayerLoginEvent.Result.KICK_FULL , "The server is reserved and is full for you!");
//Allowing a player login
if (e.getResult() != PlayerLoginEvent.Result.ALLOW) {
if (isVip(tryingToLogin) ){
e.allow();
}
}
//Getting player IP
String ip = e.getAddress();
//Get the hostname player used to login to the server
String ipJoined = e.getHostname();
//Get current result from the login attempt
PlayerLoginEvent.Result result = e.getResult();
//Set kick message if Result wasn't ALLOW
e.setKickMessage("You were kicked!");
//Retrieve the kick message
String s = e.getKickMessage();
}
PlayerLoginEvent.Result ENUM:
- ALLOWED - The player is allowed to log in
- KICK_BANNED - The player is not allowed to log in, due to them being banned
- KICK_FULL - The player is not allowed to log in, due to the server being full
- KICK_OTHER - The player is not allowed to log in, for reasons undefined
- KICK_WHITELIST - The player is not allowed to log in, due to them not being on the white list