mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 16:16:17 +02:00
use eco enchant enchant limit
This commit is contained in:
parent
dea86ab9ce
commit
00adf05d2b
3 changed files with 17 additions and 3 deletions
|
|
@ -4,6 +4,7 @@ import io.delilaheve.CustomAnvil
|
|||
import org.bukkit.entity.HumanEntity
|
||||
import org.bukkit.inventory.ItemStack
|
||||
import xyz.alexcrea.cuanvil.config.ConfigHolder
|
||||
import xyz.alexcrea.cuanvil.dependency.DependencyManager
|
||||
import xyz.alexcrea.cuanvil.enchant.CAEnchantment
|
||||
import xyz.alexcrea.cuanvil.group.ConflictType
|
||||
import kotlin.math.max
|
||||
|
|
@ -33,6 +34,10 @@ object EnchantmentUtil {
|
|||
val bypassFuse = player.hasPermission(CustomAnvil.bypassFusePermission)
|
||||
val bypassLevel = player.hasPermission(CustomAnvil.bypassLevelPermission)
|
||||
|
||||
// TODO add custom anvil maximum enchant count per item and globally too
|
||||
var maxEnchantCount = DependencyManager.ecoEnchantCompatibility?.getEcoLevelLimit()
|
||||
if(maxEnchantCount == null || maxEnchantCount < 0) maxEnchantCount = Int.MAX_VALUE;
|
||||
|
||||
other.forEach { (enchantment, level) ->
|
||||
if(!enchantment.isAllowed(player)) return@forEach
|
||||
|
||||
|
|
@ -45,6 +50,9 @@ object EnchantmentUtil {
|
|||
|
||||
// Enchantment not yet in result list
|
||||
if (!containsKey(enchantment)) {
|
||||
// Do not allow new enchantment if above maximum
|
||||
if(this.size <= maxEnchantCount) return@forEach
|
||||
|
||||
// Add the enchantment if it doesn't have conflicts, or if player is allowed to bypass enchantment restrictions
|
||||
this[enchantment] = cappedLevel
|
||||
if(bypassFuse){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue