Repair extension loading by placing them in common-plugin rather than foundation-shared.

This commit is contained in:
2023-04-20 20:23:57 -07:00
committed by Alex Zenla
parent 6a05d5f29f
commit 772cc32099
13 changed files with 19 additions and 14 deletions

View File

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

View File

@ -1,8 +0,0 @@
package gay.pizza.foundation.shared
fun <T, R : Comparable<R>> Collection<T>.sortedBy(order: SortOrder, selector: (T) -> R?): List<T> =
if (order == SortOrder.Ascending) {
sortedBy(selector)
} else {
sortedByDescending(selector)
}

View File

@ -1,28 +0,0 @@
package gay.pizza.foundation.shared
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): Boolean =
onlinePlayers.any { onlinePlayer -> onlinePlayer.name == player.name }
fun Server.allPlayerStatisticsOf(
statistic: Statistic,
material: Material? = null,
entityType: EntityType? = null,
order: SortOrder = SortOrder.Ascending
): List<Pair<OfflinePlayer, Int>> = 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 }

View File

@ -1,6 +0,0 @@
package gay.pizza.foundation.shared
enum class SortOrder {
Ascending,
Descending
}

View File

@ -1,12 +0,0 @@
package gay.pizza.foundation.shared
import org.bukkit.Location
import org.bukkit.World
import org.bukkit.entity.Entity
import org.bukkit.entity.Player
import kotlin.reflect.KClass
fun <T: Entity> World.spawn(location: Location, clazz: KClass<T>): T = spawn(location, clazz.java)
fun <T: Entity> Player.spawn(clazz: KClass<T>): T = spawn(clazz.java)
fun <T: Entity> Player.spawn(clazz: Class<T>): T = world.spawn(location, clazz)