Local Chat : Arrays

Discussion in 'Plugin Development' started by BajanAmerican, Mar 9, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    BajanAmerican

    Hello, I am having some trouble with trying to make it so that only teammates are able to chat to each other. I have two array lists:
    Code:
        public static List<String> blue = new ArrayList();
        public static List<String> red = new ArrayList();
    And here is my ChatEvent:

    Code:
        @EventHandler
        public void onPlayerChat(PlayerChatEvent event){
            Player player = event.getPlayer();
            String msg = event.getMessage();
            String Pname = event.getPlayer().getName();
            if(CloudWars.hasStarted){
            if(Game.blue.contains(player)){
                event.setFormat("§1§l<" + ChatColor.RESET + player.getName() + "§1§l>" + ChatColor.RESET + " " + msg);
            }
            if(Game.red.contains(player)){
                event.setFormat("§4§l<" + ChatColor.RESET + player.getName() + "§4§l>" + ChatColor.RESET + " " + msg);
            }
            }
            if(!CloudWars.hasStarted){
                event.setFormat("§8§l<" + ChatColor.RESET + player.getName() + "§8§l>" + ChatColor.RESET + " " + msg);
            }
        }
    How do I make it so that only the players in the two arrays are able to chat with each other? Any advice helps! Thanks!
     
  2. Offline

    RealDope

    Cancel the event and use getRecipients to manually send the message.

    Or if .setRecipients is a method (I can't remember), just use that, setting it to the list of blue or red players.
     
Thread Status:
Not open for further replies.

Share This Page