From 2323b258349bf566fcadb68e838e55fc73611098 Mon Sep 17 00:00:00 2001 From: Seggan Date: Wed, 10 Apr 2024 12:53:36 -0400 Subject: [PATCH] Update sf4k --- build.gradle.kts | 2 +- plugin/build.gradle.kts | 12 ++++++------ .../addoncommunity/galactifun/Galactifun2.kt | 3 +-- .../galactifun/api/rockets/RocketInfo.kt | 2 +- .../addoncommunity/galactifun/impl/Gf2Command.kt | 2 +- .../galactifun/impl/items/FuelTank.kt | 12 ++++-------- .../galactifun/util/worldgen/ChunkPosition.kt | 16 ---------------- .../kotlin/io/github/seggan/uom/UomProcessor.kt | 1 + 8 files changed, 15 insertions(+), 35 deletions(-) delete mode 100644 plugin/src/main/kotlin/io/github/addoncommunity/galactifun/util/worldgen/ChunkPosition.kt diff --git a/build.gradle.kts b/build.gradle.kts index b9b8cd4..d38921c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,5 @@ plugins { - kotlin("jvm") version "1.9.22" apply false + kotlin("jvm") version "1.9.23" apply false } allprojects { diff --git a/plugin/build.gradle.kts b/plugin/build.gradle.kts index f08c605..512ad98 100644 --- a/plugin/build.gradle.kts +++ b/plugin/build.gradle.kts @@ -1,10 +1,11 @@ plugins { kotlin("jvm") + kotlin("plugin.serialization") version "1.9.23" + id("com.google.devtools.ksp") version "1.9.23-1.0.20" + id("com.github.johnrengelman.shadow") version "8.1.1" - id("net.minecrell.plugin-yml.bukkit") version "0.5.3" + id("net.minecrell.plugin-yml.bukkit") version "0.6.0" id("xyz.jpenilla.run-paper") version "2.2.0" - - id("com.google.devtools.ksp") version "1.9.22-1.0.17" } repositories { @@ -42,14 +43,14 @@ dependencies { implementation("co.aikar:acf-paper:0.5.1-SNAPSHOT") implementation("com.jeff_media:MorePersistentDataTypes:2.4.0") - implementation("io.github.seggan:sf4k:0.1.1") + implementation("io.github.seggan:sf4k:0.3.2") implementation(project(":uom")) ksp(project(":uom-processor")) testImplementation(kotlin("test")) testImplementation("io.kotest:kotest-assertions-core:5.8.0") - testImplementation("com.github.seeseemelk:MockBukkit-v1.20:3.78.0") + testImplementation("com.github.seeseemelk:MockBukkit-v1.20:3.80.0") testImplementation("com.github.shynixn.mccoroutine:mccoroutine-bukkit-test:2.14.0") } @@ -85,7 +86,6 @@ tasks.shadowJar { doRelocate("co.aikar.commands") doRelocate("co.aikar.locales") doRelocate("com.jeff_media.morepersistentdatatypes") - doRelocate("org.jetbrains.kotlinx") dependencies { exclude(dependency("org.jetbrains.kotlin:kotlin-stdlib")) diff --git a/plugin/src/main/kotlin/io/github/addoncommunity/galactifun/Galactifun2.kt b/plugin/src/main/kotlin/io/github/addoncommunity/galactifun/Galactifun2.kt index 1fe4431..11780e0 100644 --- a/plugin/src/main/kotlin/io/github/addoncommunity/galactifun/Galactifun2.kt +++ b/plugin/src/main/kotlin/io/github/addoncommunity/galactifun/Galactifun2.kt @@ -46,8 +46,7 @@ import kotlin.time.Duration.Companion.hours open class Galactifun2 : AbstractAddon() { - lateinit var manager: PaperCommandManager - private set + private lateinit var manager: PaperCommandManager var isTest = classLoader.javaClass.packageName.startsWith("be.seeseemelk.mockbukkit") diff --git a/plugin/src/main/kotlin/io/github/addoncommunity/galactifun/api/rockets/RocketInfo.kt b/plugin/src/main/kotlin/io/github/addoncommunity/galactifun/api/rockets/RocketInfo.kt index 706369e..9f00e73 100644 --- a/plugin/src/main/kotlin/io/github/addoncommunity/galactifun/api/rockets/RocketInfo.kt +++ b/plugin/src/main/kotlin/io/github/addoncommunity/galactifun/api/rockets/RocketInfo.kt @@ -95,7 +95,7 @@ class RocketInfo( private fun deltaV(engines: List, wetMass: Mass, dryMass: Mass): Velocity { val ispNeum = engines.sumBy { it.thrust }.newtons val ispDenom = engines.sumOf { it.thrust.newtons / it.specificImpulse.doubleSeconds } - val isp = (ispNeum / ispDenom).seconds + val isp = if (ispDenom == 0.0) 0.seconds else (ispNeum / ispDenom).seconds return EARTH_GRAVITY * isp * ln(wetMass / dryMass) } diff --git a/plugin/src/main/kotlin/io/github/addoncommunity/galactifun/impl/Gf2Command.kt b/plugin/src/main/kotlin/io/github/addoncommunity/galactifun/impl/Gf2Command.kt index 688c9b4..b1c61e7 100644 --- a/plugin/src/main/kotlin/io/github/addoncommunity/galactifun/impl/Gf2Command.kt +++ b/plugin/src/main/kotlin/io/github/addoncommunity/galactifun/impl/Gf2Command.kt @@ -44,7 +44,7 @@ object Gf2Command : BaseCommand() { fun distance(player: Player, planet: PlanetaryObject) { val start = PlanetManager.getByWorld(player.world) ?: return val distance = start.getDeltaVForTransferTo(planet, Clock.System.now()) - player.sendMessage("The delta-v required to transfer to %s is %.2f m/s".format(planet.name, distance)) + player.sendMessage("The delta-v required to transfer to %s is %.2f m/s".format(planet.name, distance.metersPerSecond)) } @Subcommand("selector") diff --git a/plugin/src/main/kotlin/io/github/addoncommunity/galactifun/impl/items/FuelTank.kt b/plugin/src/main/kotlin/io/github/addoncommunity/galactifun/impl/items/FuelTank.kt index 9c1c641..e506c4a 100644 --- a/plugin/src/main/kotlin/io/github/addoncommunity/galactifun/impl/items/FuelTank.kt +++ b/plugin/src/main/kotlin/io/github/addoncommunity/galactifun/impl/items/FuelTank.kt @@ -15,7 +15,8 @@ import io.github.addoncommunity.galactifun.util.general.mergeMaps import io.github.addoncommunity.galactifun.util.general.with import io.github.addoncommunity.galactifun.util.items.TickingBlock import io.github.addoncommunity.galactifun.util.items.buildMenu -import io.github.seggan.sf4k.serial.* +import io.github.seggan.sf4k.serial.blockstorage.getBlockStorage +import io.github.seggan.sf4k.serial.blockstorage.setBlockStorage import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType @@ -43,11 +44,6 @@ class FuelTank( input(INPUT with 0).addBorder() item(0 with 0, CustomItemStack(Material.WATER_BUCKET, "&fContents")) } - - private val fuelDataType = MapBlockStorageDataType( - EnumBlockStorageDataType(Gas::class), - BlockStorageDataType.DOUBLE - ) } override fun tick(b: Block) { @@ -115,11 +111,11 @@ class FuelTank( } fun getFuelLevel(block: Block): Map { - return block.getBlockStorage("fuel", fuelDataType)?.mapValues { it.value.liters } ?: emptyMap() + return block.getBlockStorage>("fuel") ?: emptyMap() } fun setFuelLevel(block: Block, fuel: Map) { - block.setBlockStorage("fuel", fuel.mapValues { it.value.liters }, fuelDataType) + block.setBlockStorage("fuel", fuel) } override fun getMass(block: Block): Mass = 729.kilograms // based on a 1 m^3 tank with 0.5 m thick walls of aluminum diff --git a/plugin/src/main/kotlin/io/github/addoncommunity/galactifun/util/worldgen/ChunkPosition.kt b/plugin/src/main/kotlin/io/github/addoncommunity/galactifun/util/worldgen/ChunkPosition.kt deleted file mode 100644 index 92580f0..0000000 --- a/plugin/src/main/kotlin/io/github/addoncommunity/galactifun/util/worldgen/ChunkPosition.kt +++ /dev/null @@ -1,16 +0,0 @@ -package io.github.addoncommunity.galactifun.util.worldgen - -import org.bukkit.Chunk -import org.bukkit.Location -import org.bukkit.World - -data class ChunkPosition(val x: Int, val y: Int) { - - val worldX = x * 16 - val worldY = y * 16 - - fun toLocation(world: World) = Location(world, worldX.toDouble(), 0.0, worldY.toDouble()) -} - -val Chunk.position: ChunkPosition - get() = ChunkPosition(x, z) diff --git a/uom-processor/src/main/kotlin/io/github/seggan/uom/UomProcessor.kt b/uom-processor/src/main/kotlin/io/github/seggan/uom/UomProcessor.kt index eaf21bb..65d8bca 100644 --- a/uom-processor/src/main/kotlin/io/github/seggan/uom/UomProcessor.kt +++ b/uom-processor/src/main/kotlin/io/github/seggan/uom/UomProcessor.kt @@ -47,6 +47,7 @@ class UomProcessor( .addOriginatingKSFile(classDeclaration.containingFile!!) .addModifiers(KModifier.VALUE) .jvmInline() + .addAnnotation(ClassName("kotlinx.serialization", "Serializable")) .addSuperinterface(COMPARABLE.parameterizedBy(clazzName)) .addSuperinterface(Formattable::class)