Renamed WrappedEnchantment to CAEnchantment (CustomAnvilEnchantment).

created an interface out of CAEnchantment and moved the implementation to CAEnchantmentBase.
This commit is contained in:
alexcrea 2024-06-20 13:08:48 +02:00
parent fa4752ea67
commit dafe595c5b
No known key found for this signature in database
GPG key ID: 43FD265DB0DBF91F
20 changed files with 575 additions and 463 deletions

View file

@ -4,7 +4,7 @@ import io.delilaheve.CustomAnvil
import org.bukkit.Material
import org.bukkit.entity.HumanEntity
import xyz.alexcrea.cuanvil.config.ConfigHolder
import xyz.alexcrea.cuanvil.enchant.WrappedEnchantment
import xyz.alexcrea.cuanvil.enchant.CAEnchantment
import xyz.alexcrea.cuanvil.group.ConflictType
import kotlin.math.max
import kotlin.math.min
@ -17,17 +17,17 @@ object EnchantmentUtil {
/**
* Enchantment name without namespace
*/
val WrappedEnchantment.enchantmentName: String
val CAEnchantment.enchantmentName: String
get() = key.key
/**
* Combine 2 sets of enchantments according to our configuration
*/
fun Map<WrappedEnchantment, Int>.combineWith(
other: Map<WrappedEnchantment, Int>,
fun Map<CAEnchantment, Int>.combineWith(
other: Map<CAEnchantment, Int>,
mat: Material,
player: HumanEntity
) = mutableMapOf<WrappedEnchantment, Int>().apply {
) = mutableMapOf<CAEnchantment, Int>().apply {
putAll(this@combineWith)
other.forEach { (enchantment, level) ->
if(!enchantment.isAllowed(player)) return@forEach