Solved Caps

Discussion in 'Plugin Development' started by TheFl4me, Mar 26, 2015.

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

    TheFl4me

    So im coding a auto-kick plugin wich will kick anybody who writes a word wich is located in a config called "Blacklist".

    This is how my plugin currently checks if the msg contains that certain word:

    Code:
    List <String> blacklist = cfg.getStringList("blacklist");
                for (String insults : blacklist) {
                    if(e.getMessage().contains(insults)) {
    It works fine but it does not work if for example in the config i entered the word "fuck" and someone writes the word "FUCK".

    any help?
     
  2. Offline

    mythbusterma

    @TheFl4me

    Instead of doing Collection#contains(...), iterate through the Collection looking for the word, using String#equalsIgnoreCase(...).
     
  3. Offline

    TheFl4me

    I get how this would work if a player would write a single word in chat. But would this also work if the player writes more then just the specified word?
     
  4. Offline

    mythbusterma

    @TheFl4me

    Iterate over every word in the chat.
     
  5. Offline

    TheFl4me

    Thank you it works ^^
     
  6. Offline

    Regablith

    Just saying, what you have there will only count it if it 's spelled exactly like it is in the list. So if you put "hi" into the list, it won't detect "HI".

    To fix that, do StringUtils#containsIgnoreCase
     
  7. Offline

    TheFl4me

    I appreciate you trying to help but that was exactly what the entire conversation was about >_>
     
  8. Offline

    Regablith

    Didn't really read it, but looking at the other guy's post, this will be easier :p
     
  9. e.getMessage().toLowerCase().contains(insults.toLowerCase())
     
  10. Offline

    Funergy

    @FisheyLP You never read the whole thread, right? He just said it works. Thats why the thread is marked solved.
     
  11. @Funergy it wasn't solved before and no, I didn't read it ._.
     
Thread Status:
Not open for further replies.

Share This Page