Skip to content

Commit

Permalink
added spawner things
Browse files Browse the repository at this point in the history
  • Loading branch information
Exanthiax committed Jul 22, 2024
1 parent be3db11 commit ad78d84
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import com.willfp.libreforge.filters.impl.FilterPlayerName
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.FilterText
import com.willfp.libreforge.filters.impl.FilterTextContains
import com.willfp.libreforge.filters.impl.FilterThisItem
Expand Down Expand Up @@ -120,5 +121,6 @@ object Filters : Registry<Filter<*, *>>() {
register(FilterAdvancements)
register(FilterThisItem)
register(FilterEnchant)
register(FilterSpawnerEntity)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.willfp.libreforge.filters.impl

import com.willfp.eco.core.config.interfaces.Config
import com.willfp.eco.util.containsIgnoreCase
import com.willfp.libreforge.NoCompileData
import com.willfp.libreforge.filters.Filter
import com.willfp.libreforge.triggers.TriggerData
import org.bukkit.block.CreatureSpawner

object FilterSpawnerEntity : Filter<NoCompileData, Collection<String>>("spawner_entity") {

override fun getValue(config: Config, data: TriggerData?, key: String): Collection<String> {
return config.getStrings(key)
}

override fun isMet(data: TriggerData, value: Collection<String>, compileData: NoCompileData): Boolean {
val block = data.block ?: return false

if (block.state is CreatureSpawner) {
val spawner = block.state as CreatureSpawner
val spawnerEntityType = spawner.spawnedType?.name ?: "null"

return value.containsIgnoreCase(spawnerEntityType)
}

return false
}
}

0 comments on commit ad78d84

Please sign in to comment.