diff --git a/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java b/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java index e2852359e..502d2f4f3 100644 --- a/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java +++ b/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java @@ -57,11 +57,17 @@ public class AuthMePlayerListener implements Listener { * @param event AsyncPlayerChatEvent */ private void handleChat(AsyncPlayerChatEvent event) { + Player player = event.getPlayer(); + for (Player p : Utils.getOnlinePlayers()) { + if (p != player && !PlayerCache.getInstance().isAuthenticated(p.getName())) { + event.getRecipients().remove(p); + } + } + if (Settings.isChatAllowed) { return; } - Player player = event.getPlayer(); if (Utils.checkAuth(player)) { return; } @@ -214,7 +220,7 @@ public class AuthMePlayerListener implements Listener { */ @EventHandler(priority = EventPriority.HIGHEST) public void onPlayerJoin(PlayerJoinEvent event) { - if (event.getPlayer() == null) { + if (event.getPlayer() == null || Utils.isNPC(event.getPlayer())) { return; } @@ -250,7 +256,7 @@ public class AuthMePlayerListener implements Listener { public void onPreLogin(AsyncPlayerPreLoginEvent event) { final String name = event.getName().toLowerCase(); final Player player = Utils.getPlayer(name); - if (player == null) { + if (player == null || Utils.isNPC(player)) { return; } diff --git a/src/main/java/fr/xephi/authme/util/Utils.java b/src/main/java/fr/xephi/authme/util/Utils.java index 18a7e2065..327fc43dc 100644 --- a/src/main/java/fr/xephi/authme/util/Utils.java +++ b/src/main/java/fr/xephi/authme/util/Utils.java @@ -130,7 +130,7 @@ public final class Utils { // TODO: Move to a Manager public static boolean checkAuth(Player player) { - if (player == null || Utils.isUnrestricted(player)) { + if (player == null || Utils.isUnrestricted(player) || Utils.isNPC(player)) { return true; }