From 221fb11a50dd19db49b4478a8d27e5ce77073aed Mon Sep 17 00:00:00 2001 From: Danielle Voznyy Date: Sun, 29 Oct 2023 22:18:09 -0400 Subject: [PATCH 1/3] Move geary definition to onLoad, start in onEnable --- .../geary/papermc/bridge/PaperBridge.kt | 15 +++++++++------ .../geary/papermc/plugin/GearyPluginImpl.kt | 7 ++++++- .../geary/papermc/plugin/PaperEngineModule.kt | 8 ++------ .../papermc/tracking/entities/EntityTracking.kt | 5 ++++- .../geary/papermc/tracking/items/ItemTracking.kt | 14 +++++++++----- gradle.properties | 2 +- 6 files changed, 31 insertions(+), 20 deletions(-) diff --git a/geary-papermc-bridge/src/main/kotlin/com/mineinabyss/geary/papermc/bridge/PaperBridge.kt b/geary-papermc-bridge/src/main/kotlin/com/mineinabyss/geary/papermc/bridge/PaperBridge.kt index 60554f3..3afa705 100644 --- a/geary-papermc-bridge/src/main/kotlin/com/mineinabyss/geary/papermc/bridge/PaperBridge.kt +++ b/geary-papermc-bridge/src/main/kotlin/com/mineinabyss/geary/papermc/bridge/PaperBridge.kt @@ -1,5 +1,6 @@ package com.mineinabyss.geary.papermc.bridge +import com.mineinabyss.geary.addons.GearyPhase import com.mineinabyss.geary.addons.dsl.GearyAddonWithDefault import com.mineinabyss.geary.modules.geary import com.mineinabyss.geary.papermc.bridge.actions.ExplosionSystem @@ -18,12 +19,6 @@ import com.mineinabyss.idofront.plugin.listeners class PaperBridge { companion object : GearyAddonWithDefault { override fun PaperBridge.install() { - gearyPaper.plugin.listeners( - DeathBridge(), - ItemActionsBridge(), - MobActionsBridge(), - ) - geary.pipeline.addSystems( CooldownDisplaySystem(), ApplyAttribute(), @@ -39,6 +34,14 @@ class PaperBridge { TimeConditionChecker(), ExplosionSystem(), ) + + geary.pipeline.runOnOrAfter(GearyPhase.ENABLE) { + gearyPaper.plugin.listeners( + DeathBridge(), + ItemActionsBridge(), + MobActionsBridge(), + ) + } } override fun default() = PaperBridge() diff --git a/geary-papermc-plugin/src/main/kotlin/com/mineinabyss/geary/papermc/plugin/GearyPluginImpl.kt b/geary-papermc-plugin/src/main/kotlin/com/mineinabyss/geary/papermc/plugin/GearyPluginImpl.kt index c382faa..ea82b49 100644 --- a/geary-papermc-plugin/src/main/kotlin/com/mineinabyss/geary/papermc/plugin/GearyPluginImpl.kt +++ b/geary-papermc-plugin/src/main/kotlin/com/mineinabyss/geary/papermc/plugin/GearyPluginImpl.kt @@ -2,6 +2,7 @@ package com.mineinabyss.geary.papermc.plugin import com.mineinabyss.geary.addons.GearyPhase.ENABLE import com.mineinabyss.geary.autoscan.autoscan +import com.mineinabyss.geary.modules.ArchetypeEngineModule import com.mineinabyss.geary.modules.geary import com.mineinabyss.geary.papermc.GearyPaperConfigModule import com.mineinabyss.geary.papermc.GearyPlugin @@ -34,7 +35,7 @@ import kotlin.io.path.name class GearyPluginImpl : GearyPlugin() { - override fun onEnable() { + override fun onLoad() { // Register DI val configModule = GearyProductionPaperConfigModule(this) @@ -98,6 +99,10 @@ class GearyPluginImpl : GearyPlugin() { GearyCommands() } + override fun onEnable() { + ArchetypeEngineModule.start(DI.get()) + } + override fun onDisable() { server.worlds.forEach { world -> world.entities.forEach entities@{ entity -> diff --git a/geary-papermc-plugin/src/main/kotlin/com/mineinabyss/geary/papermc/plugin/PaperEngineModule.kt b/geary-papermc-plugin/src/main/kotlin/com/mineinabyss/geary/papermc/plugin/PaperEngineModule.kt index 8d6f0e7..c5bfe40 100644 --- a/geary-papermc-plugin/src/main/kotlin/com/mineinabyss/geary/papermc/plugin/PaperEngineModule.kt +++ b/geary-papermc-plugin/src/main/kotlin/com/mineinabyss/geary/papermc/plugin/PaperEngineModule.kt @@ -2,14 +2,13 @@ package com.mineinabyss.geary.papermc.plugin import co.touchlab.kermit.Logger import co.touchlab.kermit.StaticConfig -import com.github.shynixn.mccoroutine.bukkit.launch import com.mineinabyss.geary.engine.archetypes.ArchetypeEngine import com.mineinabyss.geary.modules.ArchetypeEngineModule import com.mineinabyss.geary.modules.GearyModuleProvider import com.mineinabyss.geary.papermc.GearyPlugin import com.mineinabyss.geary.papermc.gearyPaper +import com.mineinabyss.idofront.di.DI import com.mineinabyss.idofront.time.ticks -import kotlinx.coroutines.delay class PaperEngineModule(val plugin: GearyPlugin) : ArchetypeEngineModule(tickDuration = 1.ticks) { @@ -18,10 +17,7 @@ class PaperEngineModule(val plugin: GearyPlugin) : companion object: GearyModuleProvider { override fun start(module: PaperEngineModule) { - module.plugin.launch { - delay(1.ticks) // Waits until first tick has complete (all plugins loaded) - ArchetypeEngineModule.start(module) - } + DI.add(module) } override fun init(module: PaperEngineModule) { diff --git a/geary-papermc-tracking/src/main/kotlin/com/mineinabyss/geary/papermc/tracking/entities/EntityTracking.kt b/geary-papermc-tracking/src/main/kotlin/com/mineinabyss/geary/papermc/tracking/entities/EntityTracking.kt index bbd54ad..46b1e62 100644 --- a/geary-papermc-tracking/src/main/kotlin/com/mineinabyss/geary/papermc/tracking/entities/EntityTracking.kt +++ b/geary-papermc-tracking/src/main/kotlin/com/mineinabyss/geary/papermc/tracking/entities/EntityTracking.kt @@ -1,5 +1,6 @@ package com.mineinabyss.geary.papermc.tracking.entities +import com.mineinabyss.geary.addons.GearyPhase import com.mineinabyss.geary.addons.dsl.GearyAddonWithDefault import com.mineinabyss.geary.datatypes.ComponentId import com.mineinabyss.geary.helpers.componentId @@ -26,13 +27,15 @@ interface EntityTracking { } override fun EntityTracking.install() { - gearyPaper.plugin.listeners(EntityWorldEventTracker()) geary.pipeline.addSystems( TrackOnSetBukkitComponent(), UntrackOnRemoveBukkitComponent(), AttemptSpawnListener(), AttemptSpawnMythicMob() ) + geary.pipeline.runOnOrAfter(GearyPhase.ENABLE) { + gearyPaper.plugin.listeners(EntityWorldEventTracker()) + } } } } diff --git a/geary-papermc-tracking/src/main/kotlin/com/mineinabyss/geary/papermc/tracking/items/ItemTracking.kt b/geary-papermc-tracking/src/main/kotlin/com/mineinabyss/geary/papermc/tracking/items/ItemTracking.kt index 842d390..1b12225 100644 --- a/geary-papermc-tracking/src/main/kotlin/com/mineinabyss/geary/papermc/tracking/items/ItemTracking.kt +++ b/geary-papermc-tracking/src/main/kotlin/com/mineinabyss/geary/papermc/tracking/items/ItemTracking.kt @@ -1,5 +1,6 @@ package com.mineinabyss.geary.papermc.tracking.items +import com.mineinabyss.geary.addons.GearyPhase import com.mineinabyss.geary.addons.dsl.GearyAddonWithDefault import com.mineinabyss.geary.datatypes.GearyEntity import com.mineinabyss.geary.modules.geary @@ -36,16 +37,19 @@ interface ItemTracking { override fun default(): ItemTracking = NMSBackedItemTracking() override fun ItemTracking.install() { - gearyPaper.plugin.listeners( - loginListener, - SetItemIgnoredPropertyListener(), - MythicMobDropSystem() - ) geary.pipeline.addSystems( InventoryTrackerSystem(), CustomModelDataToPrefabTracker(), SetItemMigrationSystem() ) + + geary.pipeline.runOnOrAfter(GearyPhase.ENABLE) { + gearyPaper.plugin.listeners( + loginListener, + SetItemIgnoredPropertyListener(), + MythicMobDropSystem() + ) + } } } } diff --git a/gradle.properties b/gradle.properties index c0c689c..bd3e406 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ kotlin.code.style=official group=com.mineinabyss -version=0.26 +version=0.27 idofrontVersion=0.20.1 gearyVersion=0.23-SNAPSHOT From 2f8726b6ab05ed96e430fdb8d501f2c19d9d56a8 Mon Sep 17 00:00:00 2001 From: Danielle Voznyy Date: Wed, 1 Nov 2023 20:51:04 -0400 Subject: [PATCH 2/3] Move SerializablePrefabItemService declaration from looty --- .../geary/papermc/plugin/GearyPluginImpl.kt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/geary-papermc-plugin/src/main/kotlin/com/mineinabyss/geary/papermc/plugin/GearyPluginImpl.kt b/geary-papermc-plugin/src/main/kotlin/com/mineinabyss/geary/papermc/plugin/GearyPluginImpl.kt index ea82b49..955f61c 100644 --- a/geary-papermc-plugin/src/main/kotlin/com/mineinabyss/geary/papermc/plugin/GearyPluginImpl.kt +++ b/geary-papermc-plugin/src/main/kotlin/com/mineinabyss/geary/papermc/plugin/GearyPluginImpl.kt @@ -17,6 +17,7 @@ import com.mineinabyss.geary.papermc.tracking.entities.gearyMobs import com.mineinabyss.geary.papermc.tracking.entities.toGearyOrNull import com.mineinabyss.geary.papermc.tracking.items.ItemTracking import com.mineinabyss.geary.papermc.tracking.items.gearyItems +import com.mineinabyss.geary.prefabs.PrefabKey import com.mineinabyss.geary.prefabs.prefabs import com.mineinabyss.geary.serialization.dsl.FileSystemAddon import com.mineinabyss.geary.serialization.dsl.serialization @@ -24,11 +25,13 @@ import com.mineinabyss.geary.uuid.UUIDTracking import com.mineinabyss.idofront.di.DI import com.mineinabyss.idofront.messaging.logSuccess import com.mineinabyss.idofront.plugin.listeners +import com.mineinabyss.idofront.serialization.SerializablePrefabItemService import com.mineinabyss.serialization.formats.YamlFormat import okio.FileSystem import okio.Path.Companion.toOkioPath import org.bukkit.entity.Player import org.bukkit.event.Listener +import org.bukkit.inventory.ItemStack import kotlin.io.path.isDirectory import kotlin.io.path.listDirectoryEntries import kotlin.io.path.name @@ -95,6 +98,15 @@ class GearyPluginImpl : GearyPlugin() { } } + + DI.add( + object : SerializablePrefabItemService { + override fun encodeFromPrefab(item: ItemStack, prefabName: String) { + val result = gearyItems.createItem(PrefabKey.of(prefabName), item) + require(result != null) { "Failed to create serializable ItemStack from $prefabName, does the prefab exist and have a geary:set.item component?" } + } + }) + // Register commands GearyCommands() } From a09df38ffc1002d2d7463d9a52350d228fe6b409 Mon Sep 17 00:00:00 2001 From: Danielle Voznyy Date: Wed, 1 Nov 2023 20:51:29 -0400 Subject: [PATCH 3/3] Bump idofront --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index bd3e406..583b114 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ kotlin.code.style=official group=com.mineinabyss version=0.27 -idofrontVersion=0.20.1 +idofrontVersion=0.20.6 gearyVersion=0.23-SNAPSHOT