From d6925300351ad4d48bbcbbfc8f1e88069053e1e5 Mon Sep 17 00:00:00 2001 From: DNx5 Date: Tue, 1 Dec 2015 01:35:30 +0700 Subject: [PATCH] Moved is player can connect check into prelogin event. --- .../authme/listener/AuthMePlayerListener.java | 6 ++++++ .../authme/process/join/AsynchronousJoin.java | 15 --------------- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java b/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java index 8400d572f..ae0e83ca0 100644 --- a/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java +++ b/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java @@ -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)) { diff --git a/src/main/java/fr/xephi/authme/process/join/AsynchronousJoin.java b/src/main/java/fr/xephi/authme/process/join/AsynchronousJoin.java index 01724b3a1..407554637 100644 --- a/src/main/java/fr/xephi/authme/process/join/AsynchronousJoin.java +++ b/src/main/java/fr/xephi/authme/process/join/AsynchronousJoin.java @@ -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);