From 77b03d796a3a2e217c28d1db4d256ddd8de56fb5 Mon Sep 17 00:00:00 2001 From: Danielle Voznyy Date: Sun, 3 Dec 2023 18:40:36 -0500 Subject: [PATCH] Add check for async entityProvider access --- .../mineinabyss/geary/papermc/plugin/PaperEngineModule.kt | 8 +++++++- .../geary/papermc/tracking/entities/BukkitEntity2Geary.kt | 1 - 2 files changed, 7 insertions(+), 2 deletions(-) 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 dfcafce..16e43e8 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 @@ -3,6 +3,7 @@ package com.mineinabyss.geary.papermc.plugin import co.touchlab.kermit.Logger import co.touchlab.kermit.StaticConfig import com.mineinabyss.geary.engine.archetypes.ArchetypeEngine +import com.mineinabyss.geary.engine.archetypes.EntityByArchetypeProvider import com.mineinabyss.geary.engine.archetypes.operations.ArchetypeMutateOperations import com.mineinabyss.geary.engine.archetypes.operations.ArchetypeReadOperations import com.mineinabyss.geary.modules.ArchetypeEngineModule @@ -20,7 +21,12 @@ class PaperEngineModule( override val engine: ArchetypeEngine = PaperMCEngine() override val logger = Logger(StaticConfig(logWriterList = listOf(PaperWriter(plugin)), minSeverity = gearyPaper.config.logLevel)) - + override val entityProvider: EntityByArchetypeProvider + get() { + if (gearyPaper.config.catchAsyncWrite) + AsyncCatcher.catchOp("Async entityProvider access!") + return super.entityProvider + } override val read: ArchetypeReadOperations get() { if (gearyPaper.config.catchAsyncRead) diff --git a/geary-papermc-tracking/src/main/kotlin/com/mineinabyss/geary/papermc/tracking/entities/BukkitEntity2Geary.kt b/geary-papermc-tracking/src/main/kotlin/com/mineinabyss/geary/papermc/tracking/entities/BukkitEntity2Geary.kt index dac7e3a..010add4 100644 --- a/geary-papermc-tracking/src/main/kotlin/com/mineinabyss/geary/papermc/tracking/entities/BukkitEntity2Geary.kt +++ b/geary-papermc-tracking/src/main/kotlin/com/mineinabyss/geary/papermc/tracking/entities/BukkitEntity2Geary.kt @@ -12,7 +12,6 @@ class BukkitEntity2Geary(val forceMainThread: Boolean = true) { private val entityMap = Int2LongOpenHashMap().apply { defaultReturnValue(-1) } operator fun get(bukkit: BukkitEntity): GearyEntity? { - if (forceMainThread) AsyncCatcher.catchOp("Async geary entity access for $bukkit") val id = entityMap.get(bukkit.entityId) if (id == -1L) return null return id.toGeary()