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

de.miraculixx.mcommons.extensions.AudienceExtensions.kt Maven / Gradle / Ivy

There is a newer version: 1.0.1
Show newest version
@file:Suppress("unused")

package de.miraculixx.mcommons.extensions

import net.kyori.adventure.audience.Audience
import net.kyori.adventure.text.Component
import net.kyori.adventure.title.Title
import kotlin.time.Duration
import kotlin.time.Duration.Companion.seconds
import kotlin.time.toJavaDuration

/**
 * Displays a title with [Duration]
 */
fun Audience.title(main: Component, sub: Component, fadeIn: Duration = Duration.ZERO, stay: Duration = 5.seconds, fadeOut: Duration = Duration.ZERO) {
    showTitle(Title.title(main, sub, Title.Times.times(fadeIn.toJavaDuration(), stay.toJavaDuration(), fadeOut.toJavaDuration())))
}

/**
 * Add two audiences together
 */
fun Audience.plus(audience: Audience) = Audience.audience(this, audience)

/**
 * Add multiple audiences together
 */
fun Audience.plus(audiences: Collection) = Audience.audience(audiences.plus(this))




© 2015 - 2025 Weber Informatics LLC | Privacy Policy