Fixed legacy registration

This commit is contained in:
Auxilor 2023-12-20 12:14:17 +00:00
parent bf012dff02
commit 5d5a80286b

View File

@ -8,19 +8,17 @@ import org.bukkit.enchantments.Enchantment
@Suppress("UNCHECKED_CAST") @Suppress("UNCHECKED_CAST")
object LegacyEnchantmentRegisterer : EnchantmentRegisterer { object LegacyEnchantmentRegisterer : EnchantmentRegisterer {
init { /**
* Register an enchantment to bukkit (for replacing vanilla CraftEnchantments)
*/
fun registerToBukkit(enchantment: Enchantment) {
// Allow registering new enchantments // Allow registering new enchantments
Enchantment::class.java.getDeclaredField("acceptingNew") Enchantment::class.java.getDeclaredField("acceptingNew")
.apply { .apply {
isAccessible = true isAccessible = true
set(null, true) set(null, true)
} }
}
/**
* Register an enchantment to bukkit (for replacing vanilla CraftEnchantments)
*/
fun registerToBukkit(enchantment: Enchantment) {
Enchantment::class.java.getDeclaredField("byKey") Enchantment::class.java.getDeclaredField("byKey")
.apply { .apply {
isAccessible = true isAccessible = true