All Downloads are FREE. Search and download functionalities are using the official Maven repository.

walkmc.extensions.Notifications.kt Maven / Gradle / Ivy

There is a newer version: 2.4.0
Show newest version
package walkmc.extensions

import org.bukkit.entity.*
import walkmc.*
import walkmc.extensions.collections.*
import walkmc.extensions.strings.*
import walkmc.placeholder.*

/**
 * Sends a notification to the specified player with the specifieds placeholders.
 */
fun Chat.log(player: Player, vararg placeholders: Pair) {
	if (!notificate) return
	player.log(message.process(PlayerPlaceholder, player).process(*placeholders))
}

/**
 * Sends a notification to the specified player with the specifieds placeholders.
 */
fun ActionBar.log(player: Player, vararg placeholders: Pair) {
	if (!notificate) return
	player.action(message.process(PlayerPlaceholder, player).process(*placeholders))
}

/**
 * Sends a notification to the specified player with the specifieds placeholders.
 */
fun Title.log(player: Player, vararg placeholders: Pair) {
	if (!notificate) return
	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, vararg placeholders: Pair) {
	when (this) {
		is Chat -> log(player, *placeholders)
		is ActionBar -> log(player, *placeholders)
		is Title -> log(player, *placeholders)
	}
}

/**
 * Sends a notification to the specified player with the specifieds placeholders.
 */
fun Chat.log(player: Player, placeholders: Map) {
	if (!notificate) return
	player.log(message.process(PlayerPlaceholder, player).process(placeholders))
}

/**
 * Sends a notification to the specified player with the specifieds placeholders.
 */
fun ActionBar.log(player: Player, placeholders: Map) {
	if (!notificate) return
	player.action(message.process(PlayerPlaceholder, player).process(placeholders))
}

/**
 * Sends a notification to the specified player with the specifieds placeholders.
 */
fun Title.log(player: Player, placeholders: Map) {
	if (!notificate) return
	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) {
	when (this) {
		is Chat -> log(player, placeholders)
		is ActionBar -> log(player, placeholders)
		is Title -> log(player, placeholders)
	}
}

/**
 * Sends a notification to the specified player with the specifieds placeholders.
 */
fun  Chat.log(player: Player, placeholder: Placeholder, value: T) {
	if (!notificate) return
	player.log(message.process(PlayerPlaceholder, player).process(placeholder, value))
}

/**
 * Sends a notification to the specified player with the specifieds placeholders.
 */
fun  ActionBar.log(player: Player, placeholder: Placeholder, value: T) {
	if (!notificate) return
	player.action(message.process(PlayerPlaceholder, player).process(placeholder, value))
}

/**
 * Sends a notification to the specified player with the specifieds placeholders.
 */
fun  Title.log(player: Player, placeholder: Placeholder, value: T) {
	if (!notificate) return
	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 specifieds placeholders.
 */
fun  Notification.log(player: Player, placeholder: Placeholder, value: T) {
	when (this) {
		is Chat -> log(player, placeholder, value)
		is ActionBar -> log(player, placeholder, value)
		is Title -> log(player, placeholder, value)
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy