diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/EcoEnchantsPlugin.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/EcoEnchantsPlugin.kt index fd660d4a..c149a34a 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/EcoEnchantsPlugin.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/EcoEnchantsPlugin.kt @@ -28,7 +28,9 @@ import com.willfp.ecoenchants.mechanics.GrindstoneSupport import com.willfp.ecoenchants.mechanics.LootSupport import com.willfp.ecoenchants.mechanics.VillagerSupport import com.willfp.ecoenchants.target.EnchantLookup.clearEnchantCache +import com.willfp.ecoenchants.target.EnchantLookup.getActiveEnchantLevel import com.willfp.ecoenchants.target.EnchantLookup.heldEnchantLevels +import com.willfp.libreforge.EmptyProvidedHolder.holder import com.willfp.libreforge.NamedValue import com.willfp.libreforge.loader.LibreforgePlugin import com.willfp.libreforge.loader.configs.ConfigCategory @@ -58,9 +60,12 @@ class EcoEnchantsPlugin : LibreforgePlugin() { override fun handleEnable() { registerHolderProvider { it.heldEnchantLevels } registerPlayerRefreshFunction { it.clearEnchantCache() } - registerHolderPlaceholderProvider { (holder, _) -> - when (holder) { - is EcoEnchantLevel -> listOf(NamedValue("level", holder.level)) + registerHolderPlaceholderProvider { ph, player -> + when (val holder = ph.holder) { + is EcoEnchantLevel -> listOf( + NamedValue("level", holder.level), + NamedValue("active_level", player.getActiveEnchantLevel(holder.enchant)) + ) else -> emptyList() } } diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/EcoEnchantLevel.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/EcoEnchantLevel.kt index 0db4f413..f7812ed4 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/EcoEnchantLevel.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/EcoEnchantLevel.kt @@ -7,13 +7,13 @@ import com.willfp.libreforge.effects.EffectList import java.util.Objects class EcoEnchantLevel( - parent: EcoEnchant, + val enchant: EcoEnchant, val level: Int, override val effects: EffectList, override val conditions: ConditionList, plugin: EcoPlugin ) : Holder { - override val id = plugin.createNamespacedKey("${parent.id}_$level") + override val id = plugin.createNamespacedKey("${enchant.id}_$level") override fun equals(other: Any?): Boolean { if (other !is EcoEnchantLevel) { diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/impl/EnchantmentRapid.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/impl/EnchantmentRapid.kt index f8c48d5f..82f2f5e5 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/impl/EnchantmentRapid.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/impl/EnchantmentRapid.kt @@ -2,6 +2,7 @@ package com.willfp.ecoenchants.enchants.impl import com.willfp.ecoenchants.EcoEnchantsPlugin import com.willfp.ecoenchants.enchants.EcoEnchant +import com.willfp.ecoenchants.target.EnchantLookup.getActiveEnchantLevel import com.willfp.ecoenchants.target.EnchantLookup.getEnchantLevel import org.bukkit.entity.Player import org.bukkit.event.EventHandler @@ -31,7 +32,7 @@ class EnchantmentRapid( fun handle(event: EntityShootBowEvent) { val player = event.entity as? Player ?: return - val level = player.getEnchantLevel(enchant) + val level = player.getActiveEnchantLevel(enchant) val multiplier = 1 - enchant.config.getDouble("percent-faster-per-level") * level / 100 diff --git a/gradle.properties b/gradle.properties index 6532bd1f..9b652ac8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ #libreforge-updater #Wed May 24 14:58:23 BST 2023 kotlin.code.style=official -libreforge-version=4.16.1 +libreforge-version=4.17.0 version=10.16.1