From da108ffeed564641d0335e267b8e218c45d21ade Mon Sep 17 00:00:00 2001 From: Auxilor Date: Sun, 30 Apr 2023 19:28:41 +0100 Subject: [PATCH] Fixed %level% placeholder --- .../com/willfp/ecoenchants/enchants/EcoEnchant.kt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/EcoEnchant.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/EcoEnchant.kt index 0a8aba33..7df0891e 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/EcoEnchant.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/EcoEnchant.kt @@ -8,6 +8,8 @@ import com.willfp.eco.core.config.interfaces.Config import com.willfp.eco.core.config.readConfig import com.willfp.eco.core.fast.fast import com.willfp.eco.core.placeholder.PlayerStaticPlaceholder +import com.willfp.eco.core.placeholder.context.PlaceholderContext +import com.willfp.eco.core.placeholder.templates.SimpleInjectablePlaceholder import com.willfp.eco.util.StringUtils import com.willfp.eco.util.containsIgnoreCase import com.willfp.ecoenchants.EcoEnchantsPlugin @@ -121,6 +123,14 @@ abstract class EcoEnchant( init { checkDependencies() + config.injectPlaceholders( + object : SimpleInjectablePlaceholder("level") { + override fun getValue(args: String, context: PlaceholderContext): String? { + return context.itemStack?.fast()?.getEnchantmentLevel(this@EcoEnchant)?.toString() + } + } + ) + conditions = Conditions.compile( config.getSubsections("conditions"), if (plugin.isLoaded) ViolationContext(plugin, "Enchantment $id")