Post any ideas / suggestions for the game servers here.
  • User avatar
User avatar
By Sharingan616
#2416
In addition to the Uppercase detection mod, a group of us players were also talking about a profanity filter....
Code: Select all
public class SwearFilter{
  public static void main(String[] args){
    
    String playertext = "You sir, are a complete idiot and a loser duckster.";
    String part1;
    String swear;
    String part2;
    String replacement = "";
    int word;
    int length;
    String bannedwords[] = {"idiot", "loser", "duckster", "meanie", "noob"};
    
    for(int i = 0; i < bannedwords.length; i++){
      word = playertext.indexOf(bannedwords[i]);
      length = bannedwords[i].length();
      if(word != -1){
        part1 = playertext.substring(0,word);
        swear = playertext.substring(word, word+length);
        part2 = playertext.substring(word+length, playertext.length());
        
        for (int x=0; x<  swear.length(); x++)
          replacement = replacement + "*";
        
        playertext = part1+replacement+part2;
        replacement = "";
      }
    }
    System.out.println(playertext);
  }
}
The above code returns
"You sir, are a complete ***** and a ***** ********."

:D
By jailbird556
#2686
Sharingan616 wrote:In addition to the Uppercase detection mod, a group of us players were also talking about a profanity filter....
Code: Select all
public class SwearFilter{
  public static void main(String[] args){
    
    String playertext = "You sir, are a complete idiot and a loser duckster.";
    String part1;
    String swear;
    String part2;
    String replacement = "";
    int word;
    int length;
    String bannedwords[] = {"idiot", "loser", "duckster", "meanie", "noob"};
    
    for(int i = 0; i < bannedwords.length; i++){
      word = playertext.indexOf(bannedwords[i]);
      length = bannedwords[i].length();
      if(word != -1){
        part1 = playertext.substring(0,word);
        swear = playertext.substring(word, word+length);
        part2 = playertext.substring(word+length, playertext.length());
        
        for (int x=0; x<  swear.length(); x++)
          replacement = replacement + "*";
        
        playertext = part1+replacement+part2;
        replacement = "";
      }
    }
    System.out.println(playertext);
  }
}
The above code returns
"You sir, are a complete ***** and a ***** ********."

:D
this would only be for swearing and replacment of swears like shiznit and frig or somethin not idiot or Duckster????
User avatar
By Sharingan616
#2702
jailbird556 wrote:
Sharingan616 wrote: this would only be for swearing and replacment of swears like shiznit and frig or somethin not idiot or Duckster????
The banned words specified in this example can be replaced with any amount of different words. The words that would be blocked would be the F word, the S word, the N word, stuff like that. All you have to do is replace the words "idiot", "loser", "duckster", "meanie", and "noob" with the swear words.
By jailbird556
#2708
Sharingan616 wrote:
jailbird556 wrote:
Sharingan616 wrote: this would only be for swearing and replacment of swears like shiznit and frig or somethin not idiot or Duckster????
The banned words specified in this example can be replaced with any amount of different words. The words that would be blocked would be the F word, the S word, the N word, stuff like that. All you have to do is replace the words "idiot", "loser", "duckster", "meanie", and "noob" with the swear words.
lol thats what i ment
long long title how many chars? lets see 123 ok more? yes 60

We have created lots of YouTube videos just so you can achieve [...]

Another post test yes yes yes or no, maybe ni? :-/

The best flat phpBB theme around. Period. Fine craftmanship and [...]

Do you need a super MOD? Well here it is. chew on this

All you need is right here. Content tag, SEO, listing, Pizza and spaghetti [...]

Lasagna on me this time ok? I got plenty of cash

this should be fantastic. but what about links,images, bbcodes etc etc? [...]