Minor refactoring and cleanup.

This commit is contained in:
2023-02-09 00:41:10 -05:00
parent e0823f7b15
commit eaa3888821
8 changed files with 22 additions and 20 deletions

View File

@ -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))
}
}

View File

@ -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) {

View File

@ -0,0 +1,7 @@
package gay.pizza.foundation.shared
import net.kyori.adventure.text.format.TextColor
object TextColors {
val AmaranthPink = TextColor.fromHexString("#F7A8B8")!!
}