Skip to content

Commit

Permalink
impl kt extension rchomczyk#2
Browse files Browse the repository at this point in the history
  • Loading branch information
noyzys authored Nov 16, 2024
1 parent ce08973 commit 1b21b4a
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions honey-kt-extension/src/dev/shiza/honey/audience.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import dev.shiza.honey.dispatcher.AdventureMessageDispatcher
import dev.shiza.honey.message.Message
import net.kyori.adventure.audience.Audience
import net.kyori.adventure.text.Component

typealias MessageFormatter = MessageFormatter<Component>
typealias MessageDispatcher = MessageDispatcher<Audience, Component>

fun AdventureMessageDispatcher.createChat(messageFormatter: MessageFormatter): MessageDispatcher =
MessageBaseDispatcher(
messageFormatter,
Message.blank(),
Audience.empty(),
Audience::sendMessage
)

fun AdventureMessageDispatcher.createActionBar(messageFormatter: MessageFormatter): MessageDispatcher =
MessageBaseDispatcher(
messageFormatter,
Message.blank(),
Audience.empty(),
Audience::sendActionBar
)

fun Audience.createChat(messageFormatter: MessageFormatter): MessageDispatcher =
MessageBaseDispatcher(
messageFormatter,
Message.blank(),
this,
Audience::sendMessage
)

fun Audience.createActionBar(messageFormatter: MessageFormatter): MessageDispatcher =
MessageBaseDispatcher(
messageFormatter,
Message.blank(),
this,
Audience::sendActionBar
)

0 comments on commit 1b21b4a

Please sign in to comment.