diff --git a/chatty-paper/src/main/kotlin/com/mineinabyss/chatty/events/ChattyPlayerChatEvent.kt b/chatty-paper/src/main/kotlin/com/mineinabyss/chatty/events/ChattyPlayerChatEvent.kt new file mode 100644 index 0000000..6fbe9ae --- /dev/null +++ b/chatty-paper/src/main/kotlin/com/mineinabyss/chatty/events/ChattyPlayerChatEvent.kt @@ -0,0 +1,19 @@ +package com.mineinabyss.chatty.events + +import com.mineinabyss.chatty.ChattyChannel +import io.papermc.paper.event.player.AbstractChatEvent +import net.kyori.adventure.audience.Audience +import net.kyori.adventure.text.Component +import org.bukkit.entity.Player +import org.bukkit.event.Event +import org.bukkit.event.HandlerList +import org.bukkit.event.player.PlayerEvent + +class ChattyPlayerChatEvent(player: Player, val channel: ChattyChannel, val message: Component, val viewers: MutableSet) : PlayerEvent(player, true) { + companion object { + @JvmStatic + val handlerList = HandlerList() + } + + override fun getHandlers(): HandlerList = handlerList +} \ No newline at end of file diff --git a/chatty-paper/src/main/kotlin/com/mineinabyss/chatty/listeners/ChatListener.kt b/chatty-paper/src/main/kotlin/com/mineinabyss/chatty/listeners/ChatListener.kt index f0af552..b068c0b 100644 --- a/chatty-paper/src/main/kotlin/com/mineinabyss/chatty/listeners/ChatListener.kt +++ b/chatty-paper/src/main/kotlin/com/mineinabyss/chatty/listeners/ChatListener.kt @@ -4,7 +4,7 @@ import com.mineinabyss.chatty.chatty import com.mineinabyss.chatty.chattyProxyChannel import com.mineinabyss.chatty.components.ChannelData import com.mineinabyss.chatty.components.CommandSpy -import com.mineinabyss.chatty.components.chattyNickname +import com.mineinabyss.chatty.events.ChattyPlayerChatEvent import com.mineinabyss.chatty.helpers.* import com.mineinabyss.geary.datatypes.family.family import com.mineinabyss.geary.papermc.tracking.entities.toGearyOrNull @@ -16,7 +16,6 @@ import io.papermc.paper.event.player.AsyncChatCommandDecorateEvent import io.papermc.paper.event.player.AsyncChatDecorateEvent import io.papermc.paper.event.player.AsyncChatEvent import net.kyori.adventure.text.Component -import net.kyori.adventure.text.format.NamedTextColor import net.kyori.adventure.text.format.Style import net.kyori.adventure.text.format.TextDecoration import net.kyori.adventure.text.minimessage.MiniMessage @@ -65,6 +64,10 @@ class ChatListener : Listener { if (viewers().isNotEmpty()) viewers().clear() viewers() += channel.getAudience(player) + val chattyEvent = ChattyPlayerChatEvent(player, channel, message(), viewers()) + if (chattyEvent.callEvent()) message(chattyEvent.message) + else viewers().clear() + if (channel.proxy) { //Append channel to give proxy info on what channel the message is from val proxyMessage = (("${player.name}$ZERO_WIDTH$channelId$ZERO_WIDTH" +