cleaned up wordfilter

This commit is contained in:
Mikkel Friis 2020-09-22 04:31:38 +02:00
parent a0072a407f
commit 947d7a4ce7

View File

@ -138,29 +138,14 @@ public class WordFilter {
filteredMessage = this.normalise(filteredMessage);
}
TObjectHashIterator iterator = this.words.iterator();
boolean foundShit = false;
while (iterator.hasNext()) {
WordFilterWord word = (WordFilterWord) iterator.next();
if (StringUtils.containsIgnoreCase(filteredMessage, word.key)) {
for (WordFilterWord word : this.words) {
if (!StringUtils.containsIgnoreCase(filteredMessage, word.key)) continue;
if (habbo != null) {
if (Emulator.getPluginManager().fireEvent(new UserTriggerWordFilterEvent(habbo, word)).isCancelled())
continue;
}
filteredMessage = filteredMessage.replace("(?i)" + word.key, word.replacement);
foundShit = true;
if (habbo != null && word.muteTime > 0) {
habbo.mute(word.muteTime, false);
}
}
}
if (!foundShit) {
return message;
filteredMessage = filteredMessage.replaceAll("(?i)" + Pattern.quote(word.key), word.replacement);
}
return filteredMessage;