mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2024-11-21 14:55:17 +01:00
Added 1.20.2 support
This commit is contained in:
parent
3451c1d498
commit
3ac72bf3cf
6
eco-core/core-nms/v1_20_R2/build.gradle.kts
Normal file
6
eco-core/core-nms/v1_20_R2/build.gradle.kts
Normal file
@ -0,0 +1,6 @@
|
||||
group = "com.willfp"
|
||||
version = rootProject.version
|
||||
|
||||
dependencies {
|
||||
compileOnly("org.spigotmc:spigot:1.20.2-R0.1-SNAPSHOT")
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package com.willfp.ecoenchants.proxy.v1_20_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_20_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)
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.willfp.ecoenchants.proxy.v1_20_R2
|
||||
|
||||
import com.willfp.ecoenchants.proxy.proxies.EcoCraftEnchantmentManagerProxy
|
||||
import com.willfp.ecoenchants.vanilla.VanillaEnchantmentData
|
||||
import net.minecraft.core.registries.BuiltInRegistries
|
||||
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_20_R2.util.CraftNamespacedKey.fromMinecraft(
|
||||
BuiltInRegistries.g.b(enchant)
|
||||
)
|
||||
if (key.key != enchantment.key.key) {
|
||||
continue
|
||||
}
|
||||
EcoCraftEnchantment(enchant, data).register()
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package com.willfp.ecoenchants.proxy.v1_20_R2
|
||||
|
||||
import com.willfp.ecoenchants.proxy.proxies.OpenInventoryProxy
|
||||
import org.bukkit.craftbukkit.v1_20_R2.entity.CraftPlayer
|
||||
import org.bukkit.entity.Player
|
||||
|
||||
class OpenInventory : OpenInventoryProxy {
|
||||
override fun getOpenInventory(player: Player): Any {
|
||||
return (player as CraftPlayer).handle.bS
|
||||
}
|
||||
}
|
@ -20,3 +20,4 @@ include(":eco-core:core-nms:v1_19_R1")
|
||||
include(":eco-core:core-nms:v1_19_R2")
|
||||
include(":eco-core:core-nms:v1_19_R3")
|
||||
include(":eco-core:core-nms:v1_20_R1")
|
||||
include(":eco-core:core-nms:v1_20_R2")
|
||||
|
Loading…
Reference in New Issue
Block a user