Moved is player can connect check into prelogin event.

This commit is contained in:
DNx5 2015-12-01 01:35:30 +07:00
parent 029214c080
commit d692530035
2 changed files with 6 additions and 15 deletions

View File

@ -198,6 +198,12 @@ public class AuthMePlayerListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST)
public void onPreLogin(AsyncPlayerPreLoginEvent event) {
if (!plugin.canConnect()) {
event.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_OTHER);
event.setKickMessage("Server is loading, please wait before joining!");
return;
}
final String name = event.getName().toLowerCase();
final Player player = Utils.getPlayer(name);
if (player == null || Utils.isNPC(player)) {

View File

@ -60,21 +60,6 @@ public class AsynchronousJoin {
plugin.ess.getUser(player).setSocialSpyEnabled(false);
}
if (!plugin.canConnect()) {
final GameMode gM = AuthMePlayerListener.gameMode.get(name);
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
AuthMePlayerListener.causeByAuthMe.putIfAbsent(name, true);
player.setGameMode(gM);
player.kickPlayer("Server is loading, please wait before joining!");
}
});
return;
}
final String ip = plugin.getIP(player);
if (Settings.isAllowRestrictedIp && !Settings.getRestrictedIp(name, ip)) {
final GameMode gM = AuthMePlayerListener.gameMode.get(name);