Fixed empty banned words list muting all chat.
This commit is contained in:
parent
bdbc35dc59
commit
26cef61d7f
|
|
@ -2,6 +2,7 @@ package me.ryanhamshire.GriefPrevention;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
@ -57,4 +58,11 @@ public class Tests
|
||||||
WordFinder finder = new WordFinder(Arrays.asList("alpha"));
|
WordFinder finder = new WordFinder(Arrays.asList("alpha"));
|
||||||
assertFalse(finder.hasMatch("Unit testing is smart."));
|
assertFalse(finder.hasMatch("Unit testing is smart."));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void WordFinder_EmptyList()
|
||||||
|
{
|
||||||
|
WordFinder finder = new WordFinder(new ArrayList<String>());
|
||||||
|
assertFalse(finder.hasMatch("alpha"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -10,6 +10,8 @@ class WordFinder
|
||||||
|
|
||||||
WordFinder(List<String> wordsToFind)
|
WordFinder(List<String> wordsToFind)
|
||||||
{
|
{
|
||||||
|
if(wordsToFind.size() == 0) return;
|
||||||
|
|
||||||
StringBuilder patternBuilder = new StringBuilder();
|
StringBuilder patternBuilder = new StringBuilder();
|
||||||
for(String word : wordsToFind)
|
for(String word : wordsToFind)
|
||||||
{
|
{
|
||||||
|
|
@ -28,6 +30,8 @@ class WordFinder
|
||||||
|
|
||||||
boolean hasMatch(String input)
|
boolean hasMatch(String input)
|
||||||
{
|
{
|
||||||
|
if(this.pattern == null) return false;
|
||||||
|
|
||||||
Matcher matcher = this.pattern.matcher(input);
|
Matcher matcher = this.pattern.matcher(input);
|
||||||
return matcher.find();
|
return matcher.find();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user