From 4de4a4ce896dfbdf5bfd06794c63cb96ea0f7b7e Mon Sep 17 00:00:00 2001 From: Auxilor Date: Sat, 22 Jun 2024 22:32:31 +0100 Subject: [PATCH] Fixed sweeping_edge --- .../enchant/VanillaEnchantments.kt | 20 +++++++++++++++---- .../enchant/impl/VanillaEcoEnchantLike.kt | 14 +++++++++---- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/VanillaEnchantments.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/VanillaEnchantments.kt index 77d65ef3..46bca27f 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/VanillaEnchantments.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/VanillaEnchantments.kt @@ -7,7 +7,13 @@ import org.bukkit.enchantments.Enchantment val Enchantment.vanillaEnchantmentData: VanillaEnchantmentData? get() { - val vanilla = plugin.vanillaEnchantsYml.getSubsectionOrNull(key.key) ?: return null + val configKey = if (key.key == "sweeping_edge") { + "sweeping" + } else { + key.key + } + + val vanilla = plugin.vanillaEnchantsYml.getSubsectionOrNull(configKey) ?: return null return VanillaEnchantmentData( vanilla.getIntOrNull("max-level"), @@ -31,12 +37,18 @@ private val enchantmentOptions = arrayOf( fun legacyRegisterVanillaEnchantmentData(plugin: EcoEnchantsPlugin) { for (vanilla in plugin.vanillaEnchantsYml.getKeys(false)) { - if (enchantmentOptions.any { plugin.vanillaEnchantsYml.has("$vanilla.$it") }) { + val key = if (vanilla == "sweeping_edge") { + "sweeping" + } else { + vanilla + } + + if (enchantmentOptions.any { plugin.vanillaEnchantsYml.has("$key.$it") }) { plugin.getProxy(EcoCraftEnchantmentManagerProxy::class.java).registerNewCraftEnchantment( Enchantment.getByKey(NamespacedKey.minecraft(vanilla))!!, VanillaEnchantmentData( - plugin.vanillaEnchantsYml.getIntOrNull("$vanilla.max-level"), - plugin.vanillaEnchantsYml.getStringsOrNull("$vanilla.conflicts") + plugin.vanillaEnchantsYml.getIntOrNull("$key.max-level"), + plugin.vanillaEnchantsYml.getStringsOrNull("$key.conflicts") ?.map { NamespacedKey.minecraft(it) } ) ) diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/impl/VanillaEcoEnchantLike.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/impl/VanillaEcoEnchantLike.kt index 1e38f18b..47cb75d1 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/impl/VanillaEcoEnchantLike.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/impl/VanillaEcoEnchantLike.kt @@ -13,20 +13,26 @@ class VanillaEcoEnchantLike( override val enchantment: Enchantment, override val plugin: EcoEnchantsPlugin ) : EcoEnchantLike { - override val config = plugin.vanillaEnchantsYml.getSubsection(enchantment.key.key) + private val section = if (enchantment.key.key == "sweeping_edge") { + "sweeping" + } else { + enchantment.key.key + } + + override val config = plugin.vanillaEnchantsYml.getSubsection(section) override val maximumLevel get() = enchantment.maxLevel override val type: EnchantmentType = - EnchantmentTypes[plugin.vanillaEnchantsYml.getString("${enchantment.key.key}.type")] + EnchantmentTypes[plugin.vanillaEnchantsYml.getString("${section}.type")] ?: EnchantmentTypes.values().first() override val enchantmentRarity: EnchantmentRarity = - EnchantmentRarities[plugin.vanillaEnchantsYml.getString("${enchantment.key.key}.rarity")] + EnchantmentRarities[plugin.vanillaEnchantsYml.getString("${section}.rarity")] ?: EnchantmentRarities.values().first() - override val rawDisplayName = plugin.vanillaEnchantsYml.getString("${enchantment.key.key}.name") + override val rawDisplayName = plugin.vanillaEnchantsYml.getString("${section}.name") override fun equals(other: Any?): Boolean { if (other !is VanillaEcoEnchantLike) {