Skip to content

Commit

Permalink
Added optional filters to mine_vein
Browse files Browse the repository at this point in the history
  • Loading branch information
WillFP committed Oct 30, 2023
1 parent 292bb81 commit ed271f7
Showing 1 changed file with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ import com.willfp.eco.core.config.interfaces.Config
import com.willfp.eco.core.integrations.antigrief.AntigriefManager
import com.willfp.eco.util.BlockUtils
import com.willfp.libreforge.NoCompileData
import com.willfp.libreforge.ViolationContext
import com.willfp.libreforge.arguments
import com.willfp.libreforge.effects.templates.MineBlockEffect
import com.willfp.libreforge.filters.FilterList
import com.willfp.libreforge.filters.Filters
import com.willfp.libreforge.getIntFromExpression
import com.willfp.libreforge.triggers.TriggerData
import com.willfp.libreforge.triggers.TriggerParameter
import org.bukkit.Material

object EffectMineVein : MineBlockEffect<NoCompileData>("mine_vein") {
object EffectMineVein : MineBlockEffect<FilterList>("mine_vein") {
override val parameters = setOf(
TriggerParameter.PLAYER
)
Expand All @@ -20,7 +23,7 @@ object EffectMineVein : MineBlockEffect<NoCompileData>("mine_vein") {
require("limit", "You must specify the most blocks to break!")
}

override fun onTrigger(config: Config, data: TriggerData, compileData: NoCompileData): Boolean {
override fun onTrigger(config: Config, data: TriggerData, compileData: FilterList): Boolean {
val block = data.block ?: data.location?.block ?: return false
val player = data.player ?: return false

Expand All @@ -38,10 +41,19 @@ object EffectMineVein : MineBlockEffect<NoCompileData>("mine_vein") {
block,
whitelist,
limit
).filter { AntigriefManager.canBreakBlock(player, it) }
)
.filter { AntigriefManager.canBreakBlock(player, it) }
.filter { compileData.isMet(data.copy(block = it)) }

player.breakBlocksSafely(blocks)

return true
}

override fun makeCompileData(config: Config, context: ViolationContext): FilterList {
return Filters.compile(
config.getSubsection("filters"),
context.with("filters")
)
}
}

0 comments on commit ed271f7

Please sign in to comment.