Anti Swear strings

Discussion in 'Plugin Development' started by aninsanellama, Sep 9, 2013.

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

    aninsanellama

    Hello.

    I'm pretty new to Bukkit development, and I have a question about an anti-swear system. I'm not sure if there is a way, or not, so I'll look like an idiot if there is, and this is a pretty simple question.

    Very simply, I'm creating a String variable and making it equal to a word I don't want to be displayed. The problem is, if a string is like this: "string", then it wouldn't work for "String", it'd save me a lot of time and effort if there was a way to get Java to check it as capitals as well as lower-case.

    Thanks!
     
  2. Offline

    metalhedd

    "string".equalsIgnoreCase("StRiNg") == true
     
  3. Offline

    aninsanellama

    How would that be applied into the code?

    For example, I want to check: "if(message.contains(swear1)", and the string is like: 'String swear1 = "string";', what would I change?
     
  4. Offline

    stonar96

    Your post will be true :D
     
  5. Offline

    sharp237


    if(message.toLowerCase().contains(swear1.toLowerCase()))
     
  6. or you could loop through a list, i would suggest that. or a config file if you want to store them there
     
  7. Offline

    PogoStick29

  8. Offline

    aninsanellama

    Thanks, I've solved it now.
     
  9. Offline

    PogoStick29

    Glad to hear that. Please mark this thread as [Solved].
     
Thread Status:
Not open for further replies.

Share This Page