First create a String List. PHP: List<String> bannedFromChat = new ArrayList<String>(); Then you want to register the chat event PHP: //Class Declarationpublic class Main extends JavaPlugin implements Listener { //On enablegetServer().getPluginManager().registerEvents(this, this); And finally your chat listener PHP: public void onPlayerChat(PlayerChatEvent event) { Player p = event.getPlayer(); for (String s : bannedFromChat) { if (s.equals(p.getName())) { event.setCancelled(true); p.sendMessage(ChatColor.RED + "[BanVote] You have been muted. You can not chat."); } } } to ban someone just add the following code after the onCommand(...) Method. PHP: bannedFromChat.add(args[0]); to unban someone just add the following code after the onCommand(...) Method. PHP: bannedFromChat.remove(args[0]);
Code: [...] if (s.equalsIgnoreCase(p.getDisplayName())) { [...] You're gonna have some problems with that.
I was actually talking about the .getDisplayName(), since it can change AND contain colors so there's a way to bypass this mute.
I know, that's my point. Hence, it would be nice if you could edit your post so other people, who might use this, won't run into the issue.
I would do something like: if(bannedFromChat.contains(p.getName()) instead of looping through the whole List.
Yeah, you will cause pretty bad chat lag if a large server ever tries to use something based on this.