How can I disable all chat for a player without a permission? EDIT: So they can't type anything or see what others are typing.
@Faith Well, to cancel the chat I would do AsyncPlayerChatEvent, and check if the player has permission.. But to cancel them seeing the messages I would probably take the same event, cancel it, then message all the players that can see it with for(Player onlinePlayer : Bukkit.getOnlinePlayers()) { if(onlinePlayer.hasPermission(...) { onlinePlayer.sendMessage(event.getMessage()); ect.. I did this without an IDE, so let me know if this works..
You could put this in a Chat Listener: Code: e.getRecipients().clear(); List<Player> recipients = new LinkedList<Player>(); for( Player p : plugin.getServer().getOnlinePlayers()){ if(!pluign.getIsMuted(p)){ recipients.add(p); } } if(!plugin.getIsMuted(player)){ e.getRecipients().addAll(regipients); }else{ e.getRecipients().clear(); } Where player is the player's instance e is the event, plugin is your main classes instance and getIsMuted checks to see if the player is muted. I do not believe there is a way to take away the user's chat ability but this makes it to where they do not recive any messages from other players and there messages do not get to other players.
@Faith To stop a player from chatting, cancel the event. To keep a player from seeing a message, remove him from the recipient Set.