Move some code to common-plugin.

This commit is contained in:
Alex Zenla 2023-02-05 19:04:38 -08:00
parent ef6daa8467
commit 6803a456b3
Signed by: alex
GPG Key ID: C0780728420EBFE5
10 changed files with 28 additions and 15 deletions

View File

@ -0,0 +1,7 @@
package gay.pizza.foundation.common
import org.bukkit.entity.Player
fun Player.chat(vararg messages: String): Unit = messages.forEach { message ->
chat(message)
}

View File

@ -1,4 +1,4 @@
package gay.pizza.foundation.core
package gay.pizza.foundation.common
fun <T, R : Comparable<R>> Collection<T>.sortedBy(order: SortOrder, selector: (T) -> R?): List<T> =
if (order == SortOrder.Ascending) {

View File

@ -0,0 +1,7 @@
package gay.pizza.foundation.common
object Platform {
private val os: String? = System.getProperty("os.name")
fun isWindows(): Boolean = os != null && os.lowercase().startsWith("windows")
}

View File

@ -1,4 +1,4 @@
package gay.pizza.foundation.core
package gay.pizza.foundation.common
import org.bukkit.Material
import org.bukkit.OfflinePlayer

View File

@ -1,4 +1,4 @@
package gay.pizza.foundation.core
package gay.pizza.foundation.common
enum class SortOrder {
Ascending,

View File

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

View File

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

View File

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

View File

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

View File

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