From 627b31b1851d77c98824ccd40a7c7a1d4a82f984 Mon Sep 17 00:00:00 2001 From: Will FP Date: Sat, 6 Jan 2024 15:11:00 +0000 Subject: [PATCH] Added this_item filter --- .../com/willfp/libreforge/filters/Filters.kt | 2 ++ .../libreforge/filters/impl/FilterThisItem.kt | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 core/src/main/kotlin/com/willfp/libreforge/filters/impl/FilterThisItem.kt diff --git a/core/src/main/kotlin/com/willfp/libreforge/filters/Filters.kt b/core/src/main/kotlin/com/willfp/libreforge/filters/Filters.kt index ea0a67800..8fc2c0a02 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/filters/Filters.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/filters/Filters.kt @@ -34,6 +34,7 @@ import com.willfp.libreforge.filters.impl.FilterPotionEffect import com.willfp.libreforge.filters.impl.FilterProjectiles import com.willfp.libreforge.filters.impl.FilterText import com.willfp.libreforge.filters.impl.FilterTextContains +import com.willfp.libreforge.filters.impl.FilterThisItem import com.willfp.libreforge.filters.impl.FilterValueAbove import com.willfp.libreforge.filters.impl.FilterValueBelow import com.willfp.libreforge.filters.impl.FilterValueEquals @@ -116,5 +117,6 @@ object Filters : Registry>() { register(FilterValueBelow) register(FilterIsExpressionTrue) register(FilterAdvancements) + register(FilterThisItem) } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/filters/impl/FilterThisItem.kt b/core/src/main/kotlin/com/willfp/libreforge/filters/impl/FilterThisItem.kt new file mode 100644 index 000000000..0e38a5943 --- /dev/null +++ b/core/src/main/kotlin/com/willfp/libreforge/filters/impl/FilterThisItem.kt @@ -0,0 +1,17 @@ +package com.willfp.libreforge.filters.impl + +import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.NoCompileData +import com.willfp.libreforge.filters.Filter +import com.willfp.libreforge.getProvider +import com.willfp.libreforge.triggers.TriggerData + +object FilterThisItem : Filter("this_item") { + override fun getValue(config: Config, data: TriggerData?, key: String): Boolean { + return config.getBool(key) + } + + override fun isMet(data: TriggerData, value: Boolean, compileData: NoCompileData): Boolean { + return data.item == data.holder.getProvider() + } +}