diff --git a/core/common/src/main/kotlin/com/willfp/libreforge/filters/Filters.kt b/core/common/src/main/kotlin/com/willfp/libreforge/filters/Filters.kt index 43762f57..e8aa002a 100644 --- a/core/common/src/main/kotlin/com/willfp/libreforge/filters/Filters.kt +++ b/core/common/src/main/kotlin/com/willfp/libreforge/filters/Filters.kt @@ -34,6 +34,7 @@ import com.willfp.libreforge.filters.impl.FilterPlayerPlaced import com.willfp.libreforge.filters.impl.FilterPotionEffect import com.willfp.libreforge.filters.impl.FilterProjectiles import com.willfp.libreforge.filters.impl.FilterSpawnerEntity +import com.willfp.libreforge.filters.impl.FilterSwept import com.willfp.libreforge.filters.impl.FilterText import com.willfp.libreforge.filters.impl.FilterTextContains import com.willfp.libreforge.filters.impl.FilterThisItem @@ -122,5 +123,6 @@ object Filters : Registry>() { register(FilterThisItem) register(FilterEnchant) register(FilterSpawnerEntity) + register(FilterSwept) } } diff --git a/core/common/src/main/kotlin/com/willfp/libreforge/filters/impl/FilterSwept.kt b/core/common/src/main/kotlin/com/willfp/libreforge/filters/impl/FilterSwept.kt new file mode 100644 index 00000000..265f527c --- /dev/null +++ b/core/common/src/main/kotlin/com/willfp/libreforge/filters/impl/FilterSwept.kt @@ -0,0 +1,18 @@ +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.triggers.TriggerData +import org.bukkit.event.entity.EntityDamageEvent + +object FilterSwept : Filter("swept") { + override fun getValue(config: Config, data: TriggerData?, key: String): Boolean { + return config.getBool(key) + } + + override fun isMet(data: TriggerData, value: Boolean, compileData: NoCompileData): Boolean { + val cause = (data.event as? EntityDamageEvent)?.cause ?: return true + return cause == EntityDamageEvent.DamageCause.ENTITY_SWEEP_ATTACK == value + } +}