Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.minedev.cronikkk.iWarning.Methods;
- import java.io.BufferedReader;
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.io.FileReader;
- import java.io.IOException;
- import net.minedev.cronikkk.iWarning.iWarning;
- public class WordFilter {
- public iWarning plugin;
- public WordFilter(iWarning i) {
- plugin = i;
- }
- String words[] = new String[200];
- File badWordFile = new File("plugins/iWarning/badwords.txt");
- public void fillArray() {
- try {
- BufferedReader in = new BufferedReader(new FileReader(badWordFile));
- String word;
- int counter = 0;
- plugin.log.info(in.readLine());
- while((word = in.readLine()) != null) {
- words[counter] = word;
- counter ++;
- }
- } catch (FileNotFoundException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- public boolean checkMessage(String message) {
- this.fillArray();
- int counter = 0;
- boolean badWord = false;
- while(!badWord || counter != words.length) {
- if(message.contains(words[counter])) {
- badWord = true;
- }
- counter ++;
- }
- if(badWord) {
- return true;
- } else {
- return false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement