From d80c1915f6127f273c03e69dfe3e0701c75ad8d1 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 1 Sep 2022 19:31:56 +0700 Subject: [PATCH] Remove item handler cacher since it is useless --- .../mc/otm/container/MatteryContainer.kt | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt index 83dbf75de..7396cabc4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt @@ -142,33 +142,31 @@ open class MatteryContainer(val watcher: Runnable, private val size: Int) : Cont return false } - protected var handler: MatteryContainerHandler? = null - fun handler( insert_validator: (slot: Int, stack: ItemStack) -> Boolean, extract_validator: (slot: Int, amount: Int, stack: ItemStack) -> Boolean ): MatteryContainerHandler { - return handler ?: MatteryContainerHandler(this, object : MatteryContainerFilter { + return MatteryContainerHandler(this, object : MatteryContainerFilter { override fun canInsert(slot: Int, stack: ItemStack) = insert_validator(slot, stack) override fun canExtract(slot: Int, amount: Int, stack: ItemStack) = extract_validator(slot, amount, stack) - }).also { handler = it } + }) } fun handler( filter: MatteryContainerFilter ): MatteryContainerHandler { - return handler ?: MatteryContainerHandler(this, filter).also { handler = it } + return MatteryContainerHandler(this, filter) } fun handler(insert_validator: (Int, ItemStack) -> Boolean): MatteryContainerHandler { - return handler ?: MatteryContainerHandler(this, object : MatteryContainerFilter { + return MatteryContainerHandler(this, object : MatteryContainerFilter { override fun canInsert(slot: Int, stack: ItemStack) = insert_validator(slot, stack) override fun canExtract(slot: Int, amount: Int, stack: ItemStack) = false - }).also { handler = it } + }) } fun handler(): MatteryContainerHandler { - return handler ?: MatteryContainerHandler(this).also { handler = it } + return MatteryContainerHandler(this) } open fun getMaxStackSize(slot: Int) = maxStackSize