Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add kotlin extension (#2) #15

Merged
merged 1 commit into from
Nov 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
)
Loading