Solved Chat filter not working?

Discussion in 'Plugin Development' started by HungerCraftNL, Feb 13, 2014.

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

    HungerCraftNL

    Can someone please read my code over, it doesn't work, but I don't know why...
    PHP:
    private String prefix ChatColor.GRAY "[" ChatColor.GOLD "NiAntiFlame" ChatColor.GRAY "] ";
       
        @
    EventHandler
        
    public void onChat(AsyncPlayerChatEvent e){
            
    String message e.getMessage();
            List<
    Stringwords Arrays.asList("kut""kanker""shit""fuck""noob");
           
            if(
    message.contains(words.toString())){
                
    e.setCancelled(true);
                
    Player p e.getPlayer();
                
    p.sendMessage(prefix ChatColor.RED "Flaming is not allowed!");
            }
        }
    The event is registered right.
     
  2. Offline

    amhokies

    HungerCraftNL
    words.toString() is using the toString method on the list itself. You have to iterate through each of the elements in the list and check each string against the message.
     
  3. Offline

    HungerCraftNL

    Thank you.
     
  4. Offline

    jkjames6

    amhokies Hey I'm trying to do this how do I iterate each element?
     
  5. Offline

    amhokies

    I hate to be 'that guy', but if you don't know how to iterate through the elements of a Collection, you should probably get a better understanding of Java before trying to do Bukkit plugins.
     
Thread Status:
Not open for further replies.

Share This Page