diff --git a/eco-core/core-nms/v1_19_R2/build.gradle b/eco-core/core-nms/v1_19_R2/build.gradle new file mode 100644 index 00000000..ad3fc61f --- /dev/null +++ b/eco-core/core-nms/v1_19_R2/build.gradle @@ -0,0 +1,6 @@ +group 'com.willfp' +version rootProject.version + +dependencies { + compileOnly 'org.spigotmc:spigot:1.19.3-R0.1-SNAPSHOT' +} diff --git a/eco-core/core-nms/v1_19_R2/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_19_R2/EcoCraftEnchantment.kt b/eco-core/core-nms/v1_19_R2/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_19_R2/EcoCraftEnchantment.kt new file mode 100644 index 00000000..ddd333b1 --- /dev/null +++ b/eco-core/core-nms/v1_19_R2/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_19_R2/EcoCraftEnchantment.kt @@ -0,0 +1,26 @@ +package com.willfp.ecoenchants.proxy.v1_19_R2 + +import com.willfp.ecoenchants.enchants.EcoEnchant +import com.willfp.ecoenchants.enchants.EcoEnchants +import com.willfp.ecoenchants.vanilla.VanillaEnchantmentData +import net.minecraft.world.item.enchantment.Enchantment +import org.bukkit.craftbukkit.v1_19_R2.enchantments.CraftEnchantment + +class EcoCraftEnchantment( + target: Enchantment, + private val data: VanillaEnchantmentData +) : CraftEnchantment(target) { + override fun getMaxLevel(): Int = data.maxLevel ?: super.getMaxLevel() + + override fun conflictsWith(other: org.bukkit.enchantments.Enchantment): Boolean { + if (other is EcoEnchant) { + return other.conflictsWith(this) + } + + return data.conflicts?.contains(other.key) ?: super.conflictsWith(other) + } + + fun register() { + EcoEnchants.register(this) + } +} diff --git a/eco-core/core-nms/v1_19_R2/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_19_R2/EcoCraftEnchantmentManager.kt b/eco-core/core-nms/v1_19_R2/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_19_R2/EcoCraftEnchantmentManager.kt new file mode 100644 index 00000000..4cf97e62 --- /dev/null +++ b/eco-core/core-nms/v1_19_R2/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_19_R2/EcoCraftEnchantmentManager.kt @@ -0,0 +1,26 @@ +package com.willfp.ecoenchants.proxy.v1_19_R2 + +import com.willfp.ecoenchants.proxy.proxies.EcoCraftEnchantmentManagerProxy +import com.willfp.ecoenchants.vanilla.VanillaEnchantmentData +import net.minecraft.core.Registry +import net.minecraft.core.registries.BuiltInRegistries +import net.minecraft.core.registries.Registries +import org.bukkit.NamespacedKey +import org.bukkit.enchantments.Enchantment + +class EcoCraftEnchantmentManager : EcoCraftEnchantmentManagerProxy { + override fun registerNewCraftEnchantment( + enchantment: Enchantment, + data: VanillaEnchantmentData + ) { + for (enchant in BuiltInRegistries.g) { + val key = org.bukkit.craftbukkit.v1_19_R2.util.CraftNamespacedKey.fromMinecraft( + BuiltInRegistries.g.b(enchant) + ) + if (key.key != enchantment.key.key) { + continue + } + EcoCraftEnchantment(enchant, data).register() + } + } +} diff --git a/eco-core/core-nms/v1_19_R2/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_19_R2/OpenInventory.kt b/eco-core/core-nms/v1_19_R2/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_19_R2/OpenInventory.kt new file mode 100644 index 00000000..d330e293 --- /dev/null +++ b/eco-core/core-nms/v1_19_R2/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_19_R2/OpenInventory.kt @@ -0,0 +1,11 @@ +package com.willfp.ecoenchants.proxy.v1_19_R2 + +import com.willfp.ecoenchants.proxy.proxies.OpenInventoryProxy +import org.bukkit.craftbukkit.v1_19_R2.entity.CraftPlayer +import org.bukkit.entity.Player + +class OpenInventory : OpenInventoryProxy { + override fun getOpenInventory(player: Player): Any { + return (player as CraftPlayer).handle.bU + } +} diff --git a/settings.gradle b/settings.gradle index 48fa2e51..b1b7088f 100644 --- a/settings.gradle +++ b/settings.gradle @@ -8,4 +8,5 @@ include ':eco-core:core-nms' include ':eco-core:core-nms:v1_17_R1' include ':eco-core:core-nms:v1_18_R1' include ':eco-core:core-nms:v1_18_R2' -include ':eco-core:core-nms:v1_19_R1' \ No newline at end of file +include ':eco-core:core-nms:v1_19_R1' +include ':eco-core:core-nms:v1_19_R2' \ No newline at end of file