Skip to content

Commit

Permalink
Added is_passive
Browse files Browse the repository at this point in the history
  • Loading branch information
WillFP committed Oct 14, 2023
1 parent 1b41c0a commit de1dab5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions core/src/main/kotlin/com/willfp/libreforge/filters/Filters.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import com.willfp.libreforge.filters.impl.FilterFullyCharged
import com.willfp.libreforge.filters.impl.FilterFullyGrown
import com.willfp.libreforge.filters.impl.FilterIsBehindVictim
import com.willfp.libreforge.filters.impl.FilterIsNPC
import com.willfp.libreforge.filters.impl.FilterIsPassive
import com.willfp.libreforge.filters.impl.FilterItemDurabilityAbove
import com.willfp.libreforge.filters.impl.FilterItemDurabilityBelow
import com.willfp.libreforge.filters.impl.FilterItems
Expand Down Expand Up @@ -100,5 +101,6 @@ object Filters : Registry<Filter<*, *>>() {
register(FilterVictimName)
register(FilterItemDurabilityAbove)
register(FilterItemDurabilityBelow)
register(FilterIsPassive)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.willfp.libreforge.filters.impl

import com.willfp.eco.core.config.interfaces.Config
import com.willfp.eco.util.NamespacedKeyUtils
import com.willfp.libreforge.NoCompileData
import com.willfp.libreforge.filters.Filter
import com.willfp.libreforge.triggers.TriggerData
import org.bukkit.entity.Boss
import org.bukkit.entity.Creature
import org.bukkit.entity.ElderGuardian
import org.bukkit.entity.Monster
import org.bukkit.persistence.PersistentDataType

object FilterIsPassive : Filter<NoCompileData, Boolean>("is_passive") {
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 entity = data.victim ?: return true

return (entity is Creature && entity !is Monster) == value
}
}

0 comments on commit de1dab5

Please sign in to comment.