
net.chestmc.common.extensions.Notifications.kt Maven / Gradle / Ivy
package net.chestmc.common.extensions
import net.chestmc.common.common.Notification
import net.chestmc.common.extensions.collections.process
import net.chestmc.common.extensions.strings.process
import net.chestmc.common.placeholder.Placeholder
import net.chestmc.common.placeholder.PlayerPlaceholder
import org.bukkit.entity.Player
/**
* Sends a notification to the specified player with the specifieds placeholders.
*/
fun Notification.log(player: Player, vararg placeholders: Pair) {
if (!notificate) return
when (this) {
is Notification.Chat -> player.log(message.process(PlayerPlaceholder, player).process(*placeholders))
is Notification.ActionBar -> player.action(message.process(PlayerPlaceholder, player).process(*placeholders))
is Notification.Title -> player.title(
title.process(PlayerPlaceholder, player).process(*placeholders),
subtitle.process(PlayerPlaceholder, player).process(*placeholders),
fadeIn, stay, fadeOut
)
}
}
/**
* Sends a notification to the specified player with the specifieds placeholders.
*/
fun Notification.log(player: Player, placeholders: Map) {
if (!notificate) return
when (this) {
is Notification.Chat -> player.log(message.process(PlayerPlaceholder, player).process(placeholders))
is Notification.ActionBar -> player.action(message.process(PlayerPlaceholder, player).process(placeholders))
is Notification.Title -> player.title(
title.process(PlayerPlaceholder, player).process(placeholders),
subtitle.process(PlayerPlaceholder, player).process(placeholders),
fadeIn, stay, fadeOut
)
}
}
/**
* Sends a notification to the specified player with the specified placeholder with a value.
*/
fun Notification.log(player: Player, placeholder: Placeholder, value: T) {
if (!notificate) return
when (this) {
is Notification.Chat -> player.log(message.process(PlayerPlaceholder, player).process(placeholder, value))
is Notification.ActionBar -> player.action(message.process(PlayerPlaceholder, player).process(placeholder, value))
is Notification.Title -> player.title(
title.process(PlayerPlaceholder, player).process(placeholder, value),
subtitle.process(PlayerPlaceholder, player).process(placeholder, value),
fadeIn, stay, fadeOut
)
}
}
/**
* Sends a notification to the specified player with the specified placeholder with a value.
*/
fun Notification.log(player: Player, placeholder: Placeholder) {
if (!notificate) return
when (this) {
is Notification.Chat -> player.log(message.process(PlayerPlaceholder, player).process(placeholder, player))
is Notification.ActionBar -> player.action(message.process(PlayerPlaceholder, player).process(placeholder, player))
is Notification.Title -> player.title(
title.process(PlayerPlaceholder, player).process(placeholder, player),
subtitle.process(PlayerPlaceholder, player).process(placeholder, player),
fadeIn, stay, fadeOut
)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy