Improved canEnchantItem

This commit is contained in:
Auxilor 2022-09-05 17:28:43 +01:00
parent b903657a38
commit 27b351858f
2 changed files with 10 additions and 0 deletions

View File

@ -15,6 +15,7 @@ import com.willfp.eco.util.StringUtils
import com.willfp.eco.util.containsIgnoreCase
import com.willfp.ecoenchants.EcoEnchantsPlugin
import com.willfp.ecoenchants.display.getFormattedName
import com.willfp.ecoenchants.mechanics.infiniteIfNegative
import com.willfp.ecoenchants.rarity.EnchantmentRarities
import com.willfp.ecoenchants.target.EnchantLookup.getEnchantLevel
import com.willfp.ecoenchants.target.EnchantmentTargets
@ -236,6 +237,10 @@ abstract class EcoEnchant(
return false
}
if (item.fast().getEnchants(true).size >= plugin.configYml.getInt("anvil.enchant-limit").infiniteIfNegative()) {
return false
}
if (item.type == Material.BOOK || item.type == Material.ENCHANTED_BOOK) {
return true
}

View File

@ -8,6 +8,7 @@ import com.willfp.eco.core.placeholder.PlaceholderInjectable
import com.willfp.eco.core.placeholder.StaticPlaceholder
import com.willfp.eco.util.NumberUtils
import com.willfp.ecoenchants.EcoEnchantsPlugin
import com.willfp.ecoenchants.mechanics.infiniteIfNegative
import com.willfp.ecoenchants.proxy.proxies.EcoCraftEnchantmentManagerProxy
import com.willfp.ecoenchants.rarity.EnchantmentRarities
import com.willfp.ecoenchants.rarity.EnchantmentRarity
@ -122,6 +123,10 @@ class VanillaEcoEnchantLike(
return false
}
if (item.fast().getEnchants(true).size >= plugin.configYml.getInt("anvil.enchant-limit").infiniteIfNegative()) {
return false
}
if (item.type == Material.BOOK || item.type == Material.ENCHANTED_BOOK) {
return true
}