Skip to content

Commit

Permalink
Add check for async entityProvider access
Browse files Browse the repository at this point in the history
  • Loading branch information
0ffz committed Dec 3, 2023
1 parent e5994ae commit 77b03d7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 77b03d7

Please sign in to comment.