Deny chatting if the required permission is not given (#470)

* Deny chatting if the required permission is not given

* Add missing import

---------

Co-authored-by: Josua Parks <[email protected]>
This commit is contained in:
Benjamin SeligandJosua Parks authored and GitHub committed 2024-05-14 16:19:54 -07:00
1 parent a816dcd738
commit 74418adfd0
1 file changed
+7
@@ -22,6 +22,7 @@ package net.draycia.carbon.common.listeners;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import net.draycia.carbon.api.channels.ChannelPermissionResult;
import net.draycia.carbon.api.channels.ChatChannel;
import net.draycia.carbon.api.event.CarbonEventHandler;
import net.draycia.carbon.api.users.CarbonPlayer;
@@ -69,6 +70,12 @@ public abstract class ChatListenerInternal {
}
protected @Nullable CarbonChatEventImpl prepareAndEmitChatEvent(final CarbonPlayer sender, final String messageContent, final @Nullable SignedMessage signedMessage, final ChatChannel channel) {
final ChannelPermissionResult permitted = channel.speechPermitted(sender);
if (!permitted.permitted()) {
sender.sendMessage(permitted.reason());
return null;
}
String content = this.configManager.primaryConfig().applyChatPlaceholders(messageContent);
content = this.configManager.primaryConfig().applyChatFilters(content);