-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #168 from Exanthiax/honeycomb
added `honey_level_full` filter
- Loading branch information
Showing
5 changed files
with
50 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
core/common/src/main/kotlin/com/willfp/libreforge/filters/impl/FilterHoneyLevelFull.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
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.Material | ||
import org.bukkit.block.data.type.Beehive | ||
|
||
object FilterHoneyLevelFull : Filter<NoCompileData, Boolean>("honey_level_full") { | ||
override fun getValue(config: Config, data: TriggerData?, key: String): Boolean { | ||
return true | ||
} | ||
|
||
override fun isMet(data: TriggerData, value: Boolean, compileData: NoCompileData): Boolean { | ||
val block = data.block ?: return false | ||
|
||
if (block.type == Material.BEEHIVE || block.type == Material.BEE_NEST) { | ||
val beehiveData = block.blockData as? Beehive ?: return false | ||
return beehiveData.honeyLevel == 5 | ||
} | ||
|
||
return false | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
core/common/src/main/kotlin/com/willfp/libreforge/filters/impl/FilterSheepColor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
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.entity.Sheep | ||
|
||
object FilterSheepColor : Filter<NoCompileData, Collection<String>>("sheep_color") { | ||
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 entity = data.victim as? Sheep ?: return false | ||
val sheepColor = entity.color?.name | ||
|
||
return value.any { it.equals(sheepColor, ignoreCase = true) } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters