Anti-Swearing Plugin

Discussion in 'Plugin Development' started by Conor015, Oct 11, 2017.

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

    Conor015

    Hey, I am developing an Anti-Swearing plugin that will stop players from swearing on a server. The problem i am having is that you can bypass the unallowed curse words by using caps or by doing something like this: shiiiiiit. I need help if someone could help me on how to stop them from saying a word completely. Thanks

    Some of the code:
    Code:
    @EventHandler
      public void onPlayerChat(AsyncPlayerChatEvent e)
      {
        String antiswear2 = ChatColor.GRAY + " (!)";
        for (String word : e.getMessage().split(" ")) {
          if (getConfig().getStringList("UnallowedWords").contains(word))
          {
            e.setCancelled(true);
            e.getPlayer().sendMessage(antiswear2 + ChatColor.RED + " You are not allowed to say that word!");
          }
        }
      }
    }
    Config works fine*
     
  2. Offline

    MightyOne

    well the the shiiiiiat thing is a bit more complicated but you can get around capital letters by just: String#toLowerCase() or toUpperCase() whatever suits you.

    To just compare if a word contains some random characters like "shiatsu" or "critical" seems sensless to me. maybe you just write down in the config every part of words that will be 99% surely used in swearing context... just an idea I am no expert
     
    Last edited: Oct 11, 2017
  3. Offline

    Conor015

    Ok thanks. Im not really good at coding so what do you mean by, String#toLowerCase(). Like, where do i put it or what to change in my current code, Thanks
     
  4. Offline

    MightyOne

    maybe put it like for(String word : e.getMessage.toLowerCase().split())
    oh man this is spoonfeeding but yeah its ok

    @Conor015 got it to work in a nice way?
     
    Last edited: Oct 11, 2017
  5. Offline

    A5H73Y

  6. Offline

    Conor015

    I tried that. Doesnt work. It doesnt block the unallowed words from the config anymore. (no errors in config)
     
  7. Offline

    MightyOne

    mhh. well post your code again if you need more help
     
  8. Offline

    Horsey

    May I introduce you to The Scunthorpe Problem. A plugin can't really parse natural speech, and decide whether the text is profane (well it could, but you'd need to implement some machine learning and AI).

    Anyway, if you really need to block profanity, I'd suggest you download an online list with possible variations OR use a RESTful API. and just use that list rather than code in checks for different variations as that will 100% cause false positives. Some options: http://www.purgomalum.com/, http://filter.faleddo.com/,http://www.bannedwordlist.com/, https://github.com/whomwah/language-timothy/blob/master/profanity-list.txt


    For example: A bit cheap becomes: A b****eap.
     
    Zombie_Striker likes this.
Thread Status:
Not open for further replies.

Share This Page