Makes only authenticated players chat recipients that will be filtered

This commit is contained in:
DNx5 2015-11-27 00:38:56 +07:00
parent 30cdf6b1e0
commit fc87ea4eef

View File

@ -57,16 +57,20 @@ public class AuthMePlayerListener implements Listener {
* @param event AsyncPlayerChatEvent
*/
private void handleChat(AsyncPlayerChatEvent event) {
if (Settings.isChatAllowed || Utils.checkAuth(event.getPlayer())) {
if (Settings.isChatAllowed) {
return;
}
final Player player = event.getPlayer();
if(Utils.checkAuth(player)) {
for (Player p : Utils.getOnlinePlayers()) {
if (!PlayerCache.getInstance().isAuthenticated(p.getName())) {
event.getRecipients().remove(p); // TODO: it should be configurable
}
}
return;
}
event.setCancelled(true);
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() {