mirror of
https://github.com/GayPizzaSpecifications/foundation.git
synced 2025-08-03 13:31:32 +00:00
Minor refactoring and cleanup.
This commit is contained in:
@ -0,0 +1,23 @@
|
||||
package gay.pizza.foundation.shared
|
||||
|
||||
import net.kyori.adventure.text.Component
|
||||
import net.kyori.adventure.text.format.TextColor
|
||||
|
||||
object MessageUtil {
|
||||
private val leftBracket: Component = Component.text('[')
|
||||
private val rightBracket: Component = Component.text(']')
|
||||
private val whitespace: Component = Component.text(' ')
|
||||
private val foundationName: Component = Component.text("Foundation")
|
||||
|
||||
fun formatSystemMessage(message: String): Component {
|
||||
return formatSystemMessage(TextColors.AmaranthPink, message)
|
||||
}
|
||||
|
||||
fun formatSystemMessage(prefixColor: TextColor, message: String): Component {
|
||||
return leftBracket
|
||||
.append(foundationName.color(prefixColor))
|
||||
.append(rightBracket)
|
||||
.append(whitespace)
|
||||
.append(Component.text(message))
|
||||
}
|
||||
}
|
@ -9,7 +9,7 @@ import org.bukkit.entity.EntityType
|
||||
val Server.allPlayers: List<OfflinePlayer>
|
||||
get() = listOf(onlinePlayers, offlinePlayers.filter { !isPlayerOnline(it) }.toList()).flatten()
|
||||
|
||||
fun Server.isPlayerOnline(player: OfflinePlayer) =
|
||||
fun Server.isPlayerOnline(player: OfflinePlayer): Boolean =
|
||||
onlinePlayers.any { onlinePlayer -> onlinePlayer.name == player.name }
|
||||
|
||||
fun Server.allPlayerStatisticsOf(
|
||||
@ -17,7 +17,7 @@ fun Server.allPlayerStatisticsOf(
|
||||
material: Material? = null,
|
||||
entityType: EntityType? = null,
|
||||
order: SortOrder = SortOrder.Ascending
|
||||
) = allPlayers.map { player ->
|
||||
): List<Pair<OfflinePlayer, Int>> = allPlayers.map { player ->
|
||||
player to if (material != null) {
|
||||
player.getStatistic(statistic, material)
|
||||
} else if (entityType != null) {
|
||||
|
@ -0,0 +1,7 @@
|
||||
package gay.pizza.foundation.shared
|
||||
|
||||
import net.kyori.adventure.text.format.TextColor
|
||||
|
||||
object TextColors {
|
||||
val AmaranthPink = TextColor.fromHexString("#F7A8B8")!!
|
||||
}
|
Reference in New Issue
Block a user