mirror of
https://github.com/GayPizzaSpecifications/foundation.git
synced 2025-08-03 13:31:32 +00:00
Move some code to common-plugin.
This commit is contained in:
@ -1,28 +0,0 @@
|
||||
package gay.pizza.foundation.core
|
||||
|
||||
import org.bukkit.Material
|
||||
import org.bukkit.OfflinePlayer
|
||||
import org.bukkit.Server
|
||||
import org.bukkit.Statistic
|
||||
import org.bukkit.entity.EntityType
|
||||
|
||||
val Server.allPlayers: List<OfflinePlayer>
|
||||
get() = listOf(onlinePlayers, offlinePlayers.filter { !isPlayerOnline(it) }.toList()).flatten()
|
||||
|
||||
fun Server.isPlayerOnline(player: OfflinePlayer) =
|
||||
onlinePlayers.any { onlinePlayer -> onlinePlayer.name == player.name }
|
||||
|
||||
fun Server.allPlayerStatisticsOf(
|
||||
statistic: Statistic,
|
||||
material: Material? = null,
|
||||
entityType: EntityType? = null,
|
||||
order: SortOrder = SortOrder.Ascending
|
||||
) = allPlayers.map { player ->
|
||||
player to if (material != null) {
|
||||
player.getStatistic(statistic, material)
|
||||
} else if (entityType != null) {
|
||||
player.getStatistic(statistic, entityType)
|
||||
} else {
|
||||
player.getStatistic(statistic)
|
||||
}
|
||||
}.sortedBy(order) { it.second }
|
@ -1,8 +0,0 @@
|
||||
package gay.pizza.foundation.core
|
||||
|
||||
fun <T, R : Comparable<R>> Collection<T>.sortedBy(order: SortOrder, selector: (T) -> R?): List<T> =
|
||||
if (order == SortOrder.Ascending) {
|
||||
sortedBy(selector)
|
||||
} else {
|
||||
sortedByDescending(selector)
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
package gay.pizza.foundation.core
|
||||
|
||||
enum class SortOrder {
|
||||
Ascending,
|
||||
Descending
|
||||
}
|
@ -3,5 +3,5 @@ package gay.pizza.foundation.core
|
||||
import net.kyori.adventure.text.format.TextColor
|
||||
|
||||
object TextColors {
|
||||
val AMARANTH_PINK = TextColor.fromHexString("#F7A8B8")!!
|
||||
val AmaranthPink = TextColor.fromHexString("#F7A8B8")!!
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ object Util {
|
||||
private val foundationName: Component = Component.text("Foundation")
|
||||
|
||||
fun formatSystemMessage(message: String): Component {
|
||||
return formatSystemMessage(TextColors.AMARANTH_PINK, message)
|
||||
return formatSystemMessage(TextColors.AmaranthPink, message)
|
||||
}
|
||||
|
||||
fun formatSystemMessage(prefixColor: TextColor, message: String): Component {
|
||||
@ -57,9 +57,4 @@ object Util {
|
||||
|
||||
return outPath
|
||||
}
|
||||
|
||||
fun isPlatformWindows(): Boolean {
|
||||
val os = System.getProperty("os.name")
|
||||
return os != null && os.lowercase().startsWith("windows")
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package gay.pizza.foundation.core.features.backup
|
||||
|
||||
import gay.pizza.foundation.common.Platform
|
||||
import gay.pizza.foundation.core.FoundationCorePlugin
|
||||
import gay.pizza.foundation.core.Util
|
||||
import net.kyori.adventure.text.Component
|
||||
@ -58,7 +59,7 @@ class BackupCommand(
|
||||
}
|
||||
|
||||
val backupTime = Instant.now()
|
||||
val backupIdentifier = if (Util.isPlatformWindows()) {
|
||||
val backupIdentifier = if (Platform.isWindows()) {
|
||||
backupTime.toEpochMilli().toString()
|
||||
} else {
|
||||
backupTime.toString()
|
||||
|
@ -1,5 +1,6 @@
|
||||
package gay.pizza.foundation.core.features.player
|
||||
|
||||
import gay.pizza.foundation.common.chat
|
||||
import org.bukkit.command.Command
|
||||
import org.bukkit.command.CommandExecutor
|
||||
import org.bukkit.command.CommandSender
|
||||
@ -15,8 +16,10 @@ class GooseCommand : CommandExecutor {
|
||||
sender.sendMessage("Player is required for this command.")
|
||||
return true
|
||||
}
|
||||
sender.chat("Goose is the most beautiful kbity to ever exist <3")
|
||||
sender.chat("I don't know who Nat is but there is no way she can compare to Goose.")
|
||||
sender.chat(
|
||||
"Goose is the most beautiful kbity to ever exist <3",
|
||||
"I don't know who Nat is but there is no way she can compare to Goose."
|
||||
)
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package gay.pizza.foundation.core.features.stats
|
||||
|
||||
import gay.pizza.foundation.core.SortOrder
|
||||
import gay.pizza.foundation.core.allPlayerStatisticsOf
|
||||
import gay.pizza.foundation.common.SortOrder
|
||||
import gay.pizza.foundation.common.allPlayerStatisticsOf
|
||||
import org.bukkit.Statistic
|
||||
import org.bukkit.command.Command
|
||||
import org.bukkit.command.CommandExecutor
|
||||
|
Reference in New Issue
Block a user