Skip to content

Commit

Permalink
Simplify blockedwords, fixes #141
Browse files Browse the repository at this point in the history
  • Loading branch information
TheJeterLP committed Jan 16, 2024
1 parent 6d0f708 commit 27c7348
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 83 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<name>ChatEx</name>
<inceptionYear>2024</inceptionYear>

<version>3.2.0</version>
<version>3.2.1</version>
<description>ChatManagement plugin for Bukkit</description>
<url>https://www.spigotmc.org/resources/chatex-continued.71041/</url>

Expand Down
24 changes: 12 additions & 12 deletions src/main/java/de/jeter/chatex/ChatListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import de.jeter.chatex.utils.adManager.AdManager;
import de.jeter.chatex.utils.adManager.SimpleAdManager;
import de.jeter.chatex.utils.adManager.SmartAdManager;
import de.jeter.chatex.utils.blockedWords.BlockedWords;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
Expand All @@ -39,8 +38,6 @@
public class ChatListener implements Listener {

private final AdManager adManager = Config.ADS_SMART_MANAGER.getBoolean() ? new SmartAdManager() : new SimpleAdManager();
private final BlockedWords blockedWords = new BlockedWords();


@EventHandler(priority = EventPriority.LOWEST)
public void onLowest(final AsyncPlayerChatEvent event) {
Expand Down Expand Up @@ -132,15 +129,18 @@ private void executeChatEvent(AsyncPlayerChatEvent event) {

LogHelper.debug("Player did not activate the AdBlocker. Continuing...");

if (blockedWords.isBlocked(chatMessage)) {
String message = Locales.MESSAGES_BLOCKED.getString(null);
MessageContainsBlockedWordEvent messageContainsBlockedWordEvent = new MessageContainsBlockedWordEvent(player, chatMessage, message);
Bukkit.getPluginManager().callEvent(messageContainsBlockedWordEvent);
event.setCancelled(!messageContainsBlockedWordEvent.isCancelled());
chatMessage = messageContainsBlockedWordEvent.getMessage();
if (!messageContainsBlockedWordEvent.isCancelled()) {
event.getPlayer().sendMessage(messageContainsBlockedWordEvent.getPluginMessage());
return;
for(String block : Config.BLOCKED_WORDS.getStringList()) {
if(chatMessage.contains(block)) {
LogHelper.debug("Player activated wordblocker! ChatMessage: " + chatMessage + " contains blockedWord: " + block);
String message = Locales.MESSAGES_BLOCKED.getString(null);
MessageContainsBlockedWordEvent messageContainsBlockedWordEvent = new MessageContainsBlockedWordEvent(player, chatMessage, message);
Bukkit.getPluginManager().callEvent(messageContainsBlockedWordEvent);
event.setCancelled(!messageContainsBlockedWordEvent.isCancelled());
chatMessage = messageContainsBlockedWordEvent.getMessage();
if (!messageContainsBlockedWordEvent.isCancelled()) {
event.getPlayer().sendMessage(messageContainsBlockedWordEvent.getPluginMessage());
return;
}
}
}

Expand Down
33 changes: 0 additions & 33 deletions src/main/java/de/jeter/chatex/utils/blockedWords/BlockedWords.java

This file was deleted.

6 changes: 0 additions & 6 deletions src/main/java/de/jeter/chatex/utils/blockedWords/Blocker.java

This file was deleted.

16 changes: 0 additions & 16 deletions src/main/java/de/jeter/chatex/utils/blockedWords/RegexBlocker.java

This file was deleted.

This file was deleted.

0 comments on commit 27c7348

Please sign in to comment.