diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/display/EnchantDisplay.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/display/EnchantDisplay.kt index 50a38e74..a1394f51 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/display/EnchantDisplay.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/display/EnchantDisplay.kt @@ -12,6 +12,7 @@ import com.willfp.ecoenchants.display.EnchantSorter.sortForDisplay import com.willfp.ecoenchants.enchants.EcoEnchant import com.willfp.ecoenchants.enchants.wrap import com.willfp.ecoenchants.target.EnchantmentTargets.isEnchantable +import com.willfp.libreforge.ItemProvidedHolder import org.bukkit.Material import org.bukkit.entity.Player import org.bukkit.inventory.ItemFlag @@ -76,8 +77,9 @@ class EnchantDisplay(private val plugin: EcoEnchantsPlugin) : DisplayModule(plug var showNotMet = false if (player != null && enchant is EcoEnchant) { val enchantLevel = enchant.getLevel(level) + val holder = ItemProvidedHolder(enchantLevel, itemStack) - val enchantNotMetLines = enchantLevel.conditions.getNotMetLines(player).map { Display.PREFIX + it } + val enchantNotMetLines = enchantLevel.conditions.getNotMetLines(player, holder).map { Display.PREFIX + it } notMetLines.addAll(enchantNotMetLines) if (enchantNotMetLines.isNotEmpty()) { diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/target/EnchantLookup.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/target/EnchantLookup.kt index 0e04a91b..c5b34225 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/target/EnchantLookup.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/target/EnchantLookup.kt @@ -4,6 +4,7 @@ import com.github.benmanes.caffeine.cache.Caffeine import com.willfp.eco.core.fast.fast import com.willfp.ecoenchants.enchants.EcoEnchant import com.willfp.ecoenchants.enchants.EcoEnchantLevel +import com.willfp.ecoenchants.target.EnchantLookup.getEnchantLevel import com.willfp.libreforge.ItemProvidedHolder import com.willfp.libreforge.ProvidedHolder import org.bukkit.entity.Player @@ -173,7 +174,9 @@ object EnchantLookup { for ((slot, enchants) in this.heldEnchantsInSlots) { val inSlot = mutableMapOf() for ((enchant, level) in enchants) { - if (enchant.getLevel(level).conditions.all { it.isMet(this) }) { + val enchantLevel = enchant.getLevel(level) + val providedHolder = ItemProvidedHolder(enchantLevel, slot.item) + if (enchantLevel.conditions.areMet(this, providedHolder)) { inSlot[enchant] = level } } @@ -239,7 +242,11 @@ object EnchantLookup { return 0 } - if (enchant.getLevel(level).conditions.any { !it.isMet(this) }) { + val enchantLevel = enchant.getLevel(level) + val item = this.inventory.getItem(slot) ?: return 0 + val providedHolder = ItemProvidedHolder(enchantLevel, item) + + if (!enchantLevel.conditions.areMet(this, providedHolder)) { return 0 } diff --git a/gradle.properties b/gradle.properties index 0a21ec49..5589efab 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ #libreforge-updater -#Wed Mar 29 15:47:50 BST 2023 +#Wed Mar 29 19:21:20 BST 2023 kotlin.code.style=official -libreforge-version=4.0.0 -version=10.0.0 +libreforge-version=4.1.0 +version=10.1.0