Advertisement
Guest User

Untitled

a guest
Jul 14th, 2011
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.27 KB | None | 0 0
  1. package net.minedev.cronikkk.iWarning.Methods;
  2.  
  3.  
  4.  
  5. import java.io.BufferedReader;
  6. import java.io.File;
  7. import java.io.FileNotFoundException;
  8. import java.io.FileReader;
  9. import java.io.IOException;
  10.  
  11. import net.minedev.cronikkk.iWarning.iWarning;
  12.  
  13. public class WordFilter {
  14.     public iWarning plugin;
  15.     public WordFilter(iWarning i) {
  16.         plugin = i;
  17.     }
  18.    
  19.     String words[] = new String[200];
  20.     File badWordFile = new File("plugins/iWarning/badwords.txt");
  21.    
  22.     public void fillArray() {
  23.         try {
  24.             BufferedReader in = new BufferedReader(new FileReader(badWordFile));
  25.             String word;
  26.             int counter = 0;
  27.            
  28.             plugin.log.info(in.readLine());
  29.            
  30.             while((word = in.readLine()) != null) {
  31.                 words[counter] = word;
  32.                 counter ++;
  33.             }
  34.         } catch (FileNotFoundException e) {
  35.             // TODO Auto-generated catch block
  36.             e.printStackTrace();
  37.         } catch (IOException e) {
  38.             // TODO Auto-generated catch block
  39.             e.printStackTrace();
  40.         }
  41.     }
  42.    
  43.     public boolean checkMessage(String message) {
  44.         this.fillArray();
  45.         int counter = 0;
  46.         boolean badWord = false;
  47.         while(!badWord || counter != words.length) {
  48.             if(message.contains(words[counter])) {
  49.                 badWord = true;
  50.             }
  51.             counter ++;
  52.         }
  53.        
  54.         if(badWord) {
  55.             return true;
  56.         } else {
  57.             return false;
  58.         }
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement