Skip to content

Commit

Permalink
Merge pull request #168 from Exanthiax/honeycomb
Browse files Browse the repository at this point in the history
added `honey_level_full` filter
  • Loading branch information
WillFP authored Sep 22, 2024
2 parents f613460 + 14a25cb commit b889b95
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 128 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,7 @@ import com.willfp.eco.core.registry.Registry
import com.willfp.libreforge.ConfigWarning
import com.willfp.libreforge.ViolationContext
import com.willfp.libreforge.deprecationMessage
import com.willfp.libreforge.filters.impl.FilterAboveHealthPercent
import com.willfp.libreforge.filters.impl.FilterAdvancements
import com.willfp.libreforge.filters.impl.FilterBlocks
import com.willfp.libreforge.filters.impl.FilterDamageCause
import com.willfp.libreforge.filters.impl.FilterEnchant
import com.willfp.libreforge.filters.impl.FilterEntities
import com.willfp.libreforge.filters.impl.FilterFromSpawner
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.FilterIsBoss
import com.willfp.libreforge.filters.impl.FilterIsExpressionTrue
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.FilterItemDurabilityAbovePercent
import com.willfp.libreforge.filters.impl.FilterItemDurabilityBelow
import com.willfp.libreforge.filters.impl.FilterItemDurabilityBelowPercent
import com.willfp.libreforge.filters.impl.FilterItems
import com.willfp.libreforge.filters.impl.FilterOnMaxHealth
import com.willfp.libreforge.filters.impl.FilterOnlyBosses
import com.willfp.libreforge.filters.impl.FilterOnlyNonBosses
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.FilterSwept
import com.willfp.libreforge.filters.impl.FilterText
import com.willfp.libreforge.filters.impl.FilterTextContains
import com.willfp.libreforge.filters.impl.FilterThisItem
import com.willfp.libreforge.filters.impl.FilterValueAbove
import com.willfp.libreforge.filters.impl.FilterValueBelow
import com.willfp.libreforge.filters.impl.FilterValueEquals
import com.willfp.libreforge.filters.impl.FilterVictimConditions
import com.willfp.libreforge.filters.impl.FilterVictimName
import com.willfp.libreforge.filters.impl.*

object Filters : Registry<Filter<*, *>>() {
/**
Expand Down Expand Up @@ -130,5 +95,7 @@ object Filters : Registry<Filter<*, *>>() {
register(FilterEnchant)
register(FilterSpawnerEntity)
register(FilterSwept)
register(FilterHoneyLevelFull)
register(FilterSheepColor)
}
}
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
}
}
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) }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,96 +2,7 @@ package com.willfp.libreforge.triggers

import com.willfp.eco.core.registry.Registry
import com.willfp.libreforge.mutators.MutatorList
import com.willfp.libreforge.triggers.impl.TriggerAltClick
import com.willfp.libreforge.triggers.impl.TriggerBite
import com.willfp.libreforge.triggers.impl.TriggerBlockItemDrop
import com.willfp.libreforge.triggers.impl.TriggerBowAttack
import com.willfp.libreforge.triggers.impl.TriggerBreed
import com.willfp.libreforge.triggers.impl.TriggerBrew
import com.willfp.libreforge.triggers.impl.TriggerBrewIngredient
import com.willfp.libreforge.triggers.impl.TriggerCastRod
import com.willfp.libreforge.triggers.impl.TriggerCatchEntity
import com.willfp.libreforge.triggers.impl.TriggerCatchFish
import com.willfp.libreforge.triggers.impl.TriggerCatchFishFail
import com.willfp.libreforge.triggers.impl.TriggerChangeArmor
import com.willfp.libreforge.triggers.impl.TriggerChangeChunk
import com.willfp.libreforge.triggers.impl.TriggerChangeWorld
import com.willfp.libreforge.triggers.impl.TriggerClickBlock
import com.willfp.libreforge.triggers.impl.TriggerClickEntity
import com.willfp.libreforge.triggers.impl.TriggerCompleteAdvancement
import com.willfp.libreforge.triggers.impl.TriggerConsume
import com.willfp.libreforge.triggers.impl.TriggerCraft
import com.willfp.libreforge.triggers.impl.TriggerDamageItem
import com.willfp.libreforge.triggers.impl.TriggerDeath
import com.willfp.libreforge.triggers.impl.TriggerDeployElytra
import com.willfp.libreforge.triggers.impl.TriggerDisable
import com.willfp.libreforge.triggers.impl.TriggerDrink
import com.willfp.libreforge.triggers.impl.TriggerDropItem
import com.willfp.libreforge.triggers.impl.TriggerEmptyBucket
import com.willfp.libreforge.triggers.impl.TriggerEnable
import com.willfp.libreforge.triggers.impl.TriggerEnchantItem
import com.willfp.libreforge.triggers.impl.TriggerEnterBed
import com.willfp.libreforge.triggers.impl.TriggerEntityBreakDoor
import com.willfp.libreforge.triggers.impl.TriggerEntityCatchFireFromBlock
import com.willfp.libreforge.triggers.impl.TriggerEntityCatchFireFromEntity
import com.willfp.libreforge.triggers.impl.TriggerEntityDamage
import com.willfp.libreforge.triggers.impl.TriggerEntityDamageByEntity
import com.willfp.libreforge.triggers.impl.TriggerEntityDeath
import com.willfp.libreforge.triggers.impl.TriggerEntityItemDrop
import com.willfp.libreforge.triggers.impl.TriggerEntitySpawn
import com.willfp.libreforge.triggers.impl.TriggerEntityTarget
import com.willfp.libreforge.triggers.impl.TriggerEntityTeleport
import com.willfp.libreforge.triggers.impl.TriggerFallDamage
import com.willfp.libreforge.triggers.impl.TriggerFillBucket
import com.willfp.libreforge.triggers.impl.TriggerGainHunger
import com.willfp.libreforge.triggers.impl.TriggerGainXp
import com.willfp.libreforge.triggers.impl.TriggerGroupCustom
import com.willfp.libreforge.triggers.impl.TriggerGroupGlobalStatic
import com.willfp.libreforge.triggers.impl.TriggerGroupStatic
import com.willfp.libreforge.triggers.impl.TriggerHeadshot
import com.willfp.libreforge.triggers.impl.TriggerHeal
import com.willfp.libreforge.triggers.impl.TriggerHoldItem
import com.willfp.libreforge.triggers.impl.TriggerHookInGround
import com.willfp.libreforge.triggers.impl.TriggerItemBreak
import com.willfp.libreforge.triggers.impl.TriggerJoin
import com.willfp.libreforge.triggers.impl.TriggerJump
import com.willfp.libreforge.triggers.impl.TriggerKill
import com.willfp.libreforge.triggers.impl.TriggerLeashEntity
import com.willfp.libreforge.triggers.impl.TriggerLeave
import com.willfp.libreforge.triggers.impl.TriggerLeaveBed
import com.willfp.libreforge.triggers.impl.TriggerLevelUpItem
import com.willfp.libreforge.triggers.impl.TriggerLevelUpXp
import com.willfp.libreforge.triggers.impl.TriggerLoseHunger
import com.willfp.libreforge.triggers.impl.TriggerLosePotionEffect
import com.willfp.libreforge.triggers.impl.TriggerMeleeAttack
import com.willfp.libreforge.triggers.impl.TriggerMineBlock
import com.willfp.libreforge.triggers.impl.TriggerMineBlockProgress
import com.willfp.libreforge.triggers.impl.TriggerMove
import com.willfp.libreforge.triggers.impl.TriggerPickUpItem
import com.willfp.libreforge.triggers.impl.TriggerPlaceBlock
import com.willfp.libreforge.triggers.impl.TriggerPotionEffect
import com.willfp.libreforge.triggers.impl.TriggerProjectileHit
import com.willfp.libreforge.triggers.impl.TriggerProjectileLaunch
import com.willfp.libreforge.triggers.impl.TriggerReelIn
import com.willfp.libreforge.triggers.impl.TriggerRespawn
import com.willfp.libreforge.triggers.impl.TriggerRunCommand
import com.willfp.libreforge.triggers.impl.TriggerSellItem
import com.willfp.libreforge.triggers.impl.TriggerSendMessage
import com.willfp.libreforge.triggers.impl.TriggerShearEntity
import com.willfp.libreforge.triggers.impl.TriggerShieldBlock
import com.willfp.libreforge.triggers.impl.TriggerShootBow
import com.willfp.libreforge.triggers.impl.TriggerSmelt
import com.willfp.libreforge.triggers.impl.TriggerSmithItem
import com.willfp.libreforge.triggers.impl.TriggerSwapHands
import com.willfp.libreforge.triggers.impl.TriggerTakeDamage
import com.willfp.libreforge.triggers.impl.TriggerTakeEntityDamage
import com.willfp.libreforge.triggers.impl.TriggerTameAnimal
import com.willfp.libreforge.triggers.impl.TriggerTeleport
import com.willfp.libreforge.triggers.impl.TriggerToggleFlight
import com.willfp.libreforge.triggers.impl.TriggerToggleSneak
import com.willfp.libreforge.triggers.impl.TriggerToggleSprint
import com.willfp.libreforge.integrations.paper.impl.TriggerTridentAttack
import com.willfp.libreforge.triggers.impl.TriggerWinRaid
import com.willfp.libreforge.triggers.impl.*

object Triggers : Registry<Trigger>() {
private val groupRegistry = Registry<TriggerGroup>()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.willfp.libreforge.triggers.impl

import com.willfp.eco.core.Prerequisite
import com.willfp.libreforge.proxy.renamedValues
import com.willfp.libreforge.toDispatcher
import com.willfp.libreforge.triggers.Trigger
Expand All @@ -23,7 +22,7 @@ object TriggerShearEntity : Trigger("shear_entity") {
fun handle(event: PlayerShearEntityEvent) {
val entity = event.entity as? LivingEntity ?: return

if (entity.type !in listOf(EntityType.SHEEP, renamedValues().entities.mooshroom)) {
if (entity.type !in listOf(EntityType.SHEEP, EntityType.SNOWMAN, renamedValues().entities.mooshroom)) {
return
}

Expand Down

0 comments on commit b889b95

Please sign in to comment.