diff --git a/eco-core/core-nms/v1_21_3/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_21_3/ModernEnchantmentRegisterer.kt b/eco-core/core-nms/v1_21_3/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_21_3/ModernEnchantmentRegisterer.kt index 08cb5d1f..73d3ea5a 100644 --- a/eco-core/core-nms/v1_21_3/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_21_3/ModernEnchantmentRegisterer.kt +++ b/eco-core/core-nms/v1_21_3/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_21_3/ModernEnchantmentRegisterer.kt @@ -18,6 +18,7 @@ import org.bukkit.craftbukkit.CraftRegistry import org.bukkit.craftbukkit.CraftServer import org.bukkit.craftbukkit.util.CraftNamespacedKey import org.bukkit.enchantments.Enchantment +import java.lang.reflect.Modifier import java.util.IdentityHashMap import java.util.function.BiFunction @@ -34,6 +35,11 @@ class ModernEnchantmentRegisterer : ModernEnchantmentRegistererProxy { .filter { it.type.isPrimitive }[0] .apply { isAccessible = true } + private val allTags = MappedRegistry::class.java + .declaredFields + .filter { it.type.name.contains("TagSet") }[0] + .apply { isAccessible = true } + private val unregisteredIntrusiveHoldersField = MappedRegistry::class.java .declaredFields .last { it.type == Map::class.java } @@ -81,6 +87,21 @@ class ModernEnchantmentRegisterer : ModernEnchantmentRegistererProxy { IdentityHashMap>() ) + + /* + Creating an unbound tag set requires using reflection because the inner class is + package-private, so we just find the method manually. + */ + + val unboundTagSet = MappedRegistry::class.java + .declaredClasses[0] + .declaredMethods + .filter { Modifier.isStatic(it.modifiers) } + .filter { it.parameterCount == 0 }[0] + .apply { isAccessible = true } + .invoke(null) + + allTags.set(enchantmentRegistry, unboundTagSet) } override fun register(enchant: EcoEnchantBase): Enchantment {