diff --git a/eco-core/core-nms/build.gradle.kts b/eco-core/core-nms/build.gradle.kts index 468525a9..6765eca3 100644 --- a/eco-core/core-nms/build.gradle.kts +++ b/eco-core/core-nms/build.gradle.kts @@ -8,7 +8,6 @@ version = rootProject.version subprojects { dependencies { - compileOnly(project(":eco-core:core-proxy")) compileOnly(project(":eco-core:core-plugin")) } } diff --git a/eco-core/core-nms/v1_17_R1/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_17_R1/EcoCraftEnchantment.kt b/eco-core/core-nms/v1_17_R1/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_17_R1/EcoCraftEnchantment.kt index 09f6f253..b222837d 100644 --- a/eco-core/core-nms/v1_17_R1/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_17_R1/EcoCraftEnchantment.kt +++ b/eco-core/core-nms/v1_17_R1/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_17_R1/EcoCraftEnchantment.kt @@ -1,12 +1,12 @@ package com.willfp.ecoenchants.proxy.v1_17_R1 -import com.willfp.ecoenchants.enchants.EcoEnchant -import com.willfp.ecoenchants.enchants.EcoEnchants -import com.willfp.ecoenchants.vanilla.VanillaEnchantmentData +import com.willfp.ecoenchants.enchant.EcoEnchant +import com.willfp.ecoenchants.enchant.VanillaEnchantmentData import net.minecraft.world.item.enchantment.Enchantment import org.bukkit.NamespacedKey import org.bukkit.craftbukkit.v1_17_R1.enchantments.CraftEnchantment + class EcoCraftEnchantment( target: Enchantment, private val data: VanillaEnchantmentData @@ -21,7 +21,26 @@ class EcoCraftEnchantment( return data.conflicts?.contains(other.key) ?: super.conflictsWith(other) } + @Suppress("UNCHECKED_CAST") fun register() { - EcoEnchants.register(this) + org.bukkit.enchantments.Enchantment::class.java.getDeclaredField("byKey") + .apply { + isAccessible = true + (get(null) as MutableMap).apply { remove(key) } + } + + org.bukkit.enchantments.Enchantment::class.java.getDeclaredField("byName") + .apply { + isAccessible = true + (get(null) as MutableMap).apply { remove(name) } + } + + org.bukkit.enchantments.Enchantment::class.java.getDeclaredField("acceptingNew") + .apply { + isAccessible = true + set(null, true) + } + + org.bukkit.enchantments.Enchantment.registerEnchantment(this) } } diff --git a/eco-core/core-nms/v1_17_R1/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_17_R1/EcoCraftEnchantmentManager.kt b/eco-core/core-nms/v1_17_R1/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_17_R1/EcoCraftEnchantmentManager.kt index 6096c385..4a40c2d5 100644 --- a/eco-core/core-nms/v1_17_R1/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_17_R1/EcoCraftEnchantmentManager.kt +++ b/eco-core/core-nms/v1_17_R1/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_17_R1/EcoCraftEnchantmentManager.kt @@ -1,8 +1,7 @@ package com.willfp.ecoenchants.proxy.v1_17_R1 -import com.willfp.ecoenchants.proxy.proxies.EcoCraftEnchantmentManagerProxy -import com.willfp.ecoenchants.vanilla.VanillaEnchantmentData -import org.bukkit.NamespacedKey +import com.willfp.ecoenchants.enchant.EcoCraftEnchantmentManagerProxy +import com.willfp.ecoenchants.enchant.VanillaEnchantmentData import org.bukkit.enchantments.Enchantment class EcoCraftEnchantmentManager : EcoCraftEnchantmentManagerProxy { diff --git a/eco-core/core-nms/v1_18_R1/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_18_R1/EcoCraftEnchantment.kt b/eco-core/core-nms/v1_18_R1/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_18_R1/EcoCraftEnchantment.kt index e9d70669..1a3ef24a 100644 --- a/eco-core/core-nms/v1_18_R1/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_18_R1/EcoCraftEnchantment.kt +++ b/eco-core/core-nms/v1_18_R1/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_18_R1/EcoCraftEnchantment.kt @@ -1,12 +1,12 @@ package com.willfp.ecoenchants.proxy.v1_18_R1 -import com.willfp.ecoenchants.enchants.EcoEnchant -import com.willfp.ecoenchants.enchants.EcoEnchants -import com.willfp.ecoenchants.vanilla.VanillaEnchantmentData +import com.willfp.ecoenchants.enchant.EcoEnchant +import com.willfp.ecoenchants.enchant.VanillaEnchantmentData import net.minecraft.world.item.enchantment.Enchantment import org.bukkit.NamespacedKey import org.bukkit.craftbukkit.v1_18_R1.enchantments.CraftEnchantment + class EcoCraftEnchantment( target: Enchantment, private val data: VanillaEnchantmentData @@ -21,7 +21,26 @@ class EcoCraftEnchantment( return data.conflicts?.contains(other.key) ?: super.conflictsWith(other) } + @Suppress("UNCHECKED_CAST") fun register() { - EcoEnchants.register(this) + org.bukkit.enchantments.Enchantment::class.java.getDeclaredField("byKey") + .apply { + isAccessible = true + (get(null) as MutableMap).apply { remove(key) } + } + + org.bukkit.enchantments.Enchantment::class.java.getDeclaredField("byName") + .apply { + isAccessible = true + (get(null) as MutableMap).apply { remove(name) } + } + + org.bukkit.enchantments.Enchantment::class.java.getDeclaredField("acceptingNew") + .apply { + isAccessible = true + set(null, true) + } + + org.bukkit.enchantments.Enchantment.registerEnchantment(this) } } diff --git a/eco-core/core-nms/v1_18_R1/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_18_R1/EcoCraftEnchantmentManager.kt b/eco-core/core-nms/v1_18_R1/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_18_R1/EcoCraftEnchantmentManager.kt index 3569dc2e..747e8d81 100644 --- a/eco-core/core-nms/v1_18_R1/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_18_R1/EcoCraftEnchantmentManager.kt +++ b/eco-core/core-nms/v1_18_R1/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_18_R1/EcoCraftEnchantmentManager.kt @@ -1,8 +1,7 @@ package com.willfp.ecoenchants.proxy.v1_18_R1 -import com.willfp.ecoenchants.proxy.proxies.EcoCraftEnchantmentManagerProxy -import com.willfp.ecoenchants.vanilla.VanillaEnchantmentData -import org.bukkit.NamespacedKey +import com.willfp.ecoenchants.enchant.EcoCraftEnchantmentManagerProxy +import com.willfp.ecoenchants.enchant.VanillaEnchantmentData import org.bukkit.enchantments.Enchantment class EcoCraftEnchantmentManager : EcoCraftEnchantmentManagerProxy { diff --git a/eco-core/core-nms/v1_18_R2/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_18_R2/EcoCraftEnchantment.kt b/eco-core/core-nms/v1_18_R2/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_18_R2/EcoCraftEnchantment.kt index 7edf2b2a..e73161b7 100644 --- a/eco-core/core-nms/v1_18_R2/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_18_R2/EcoCraftEnchantment.kt +++ b/eco-core/core-nms/v1_18_R2/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_18_R2/EcoCraftEnchantment.kt @@ -1,12 +1,12 @@ package com.willfp.ecoenchants.proxy.v1_18_R2 -import com.willfp.ecoenchants.enchants.EcoEnchant -import com.willfp.ecoenchants.enchants.EcoEnchants -import com.willfp.ecoenchants.vanilla.VanillaEnchantmentData +import com.willfp.ecoenchants.enchant.EcoEnchant +import com.willfp.ecoenchants.enchant.VanillaEnchantmentData import net.minecraft.world.item.enchantment.Enchantment import org.bukkit.NamespacedKey import org.bukkit.craftbukkit.v1_18_R2.enchantments.CraftEnchantment + class EcoCraftEnchantment( target: Enchantment, private val data: VanillaEnchantmentData @@ -21,7 +21,26 @@ class EcoCraftEnchantment( return data.conflicts?.contains(other.key) ?: super.conflictsWith(other) } + @Suppress("UNCHECKED_CAST") fun register() { - EcoEnchants.register(this) + org.bukkit.enchantments.Enchantment::class.java.getDeclaredField("byKey") + .apply { + isAccessible = true + (get(null) as MutableMap).apply { remove(key) } + } + + org.bukkit.enchantments.Enchantment::class.java.getDeclaredField("byName") + .apply { + isAccessible = true + (get(null) as MutableMap).apply { remove(name) } + } + + org.bukkit.enchantments.Enchantment::class.java.getDeclaredField("acceptingNew") + .apply { + isAccessible = true + set(null, true) + } + + org.bukkit.enchantments.Enchantment.registerEnchantment(this) } } diff --git a/eco-core/core-nms/v1_18_R2/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_18_R2/EcoCraftEnchantmentManager.kt b/eco-core/core-nms/v1_18_R2/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_18_R2/EcoCraftEnchantmentManager.kt index 2ee2eb3e..b3b25144 100644 --- a/eco-core/core-nms/v1_18_R2/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_18_R2/EcoCraftEnchantmentManager.kt +++ b/eco-core/core-nms/v1_18_R2/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_18_R2/EcoCraftEnchantmentManager.kt @@ -1,8 +1,7 @@ package com.willfp.ecoenchants.proxy.v1_18_R2 -import com.willfp.ecoenchants.proxy.proxies.EcoCraftEnchantmentManagerProxy -import com.willfp.ecoenchants.vanilla.VanillaEnchantmentData -import org.bukkit.NamespacedKey +import com.willfp.ecoenchants.enchant.EcoCraftEnchantmentManagerProxy +import com.willfp.ecoenchants.enchant.VanillaEnchantmentData import org.bukkit.enchantments.Enchantment class EcoCraftEnchantmentManager : EcoCraftEnchantmentManagerProxy { diff --git a/eco-core/core-nms/v1_19_R1/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_19_R1/EcoCraftEnchantment.kt b/eco-core/core-nms/v1_19_R1/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_19_R1/EcoCraftEnchantment.kt index 7b2ad00f..4793ed6c 100644 --- a/eco-core/core-nms/v1_19_R1/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_19_R1/EcoCraftEnchantment.kt +++ b/eco-core/core-nms/v1_19_R1/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_19_R1/EcoCraftEnchantment.kt @@ -1,11 +1,12 @@ package com.willfp.ecoenchants.proxy.v1_19_R1 -import com.willfp.ecoenchants.enchants.EcoEnchant -import com.willfp.ecoenchants.enchants.EcoEnchants -import com.willfp.ecoenchants.vanilla.VanillaEnchantmentData +import com.willfp.ecoenchants.enchant.EcoEnchant +import com.willfp.ecoenchants.enchant.VanillaEnchantmentData import net.minecraft.world.item.enchantment.Enchantment +import org.bukkit.NamespacedKey import org.bukkit.craftbukkit.v1_19_R1.enchantments.CraftEnchantment + class EcoCraftEnchantment( target: Enchantment, private val data: VanillaEnchantmentData @@ -20,7 +21,26 @@ class EcoCraftEnchantment( return data.conflicts?.contains(other.key) ?: super.conflictsWith(other) } + @Suppress("UNCHECKED_CAST") fun register() { - EcoEnchants.register(this) + org.bukkit.enchantments.Enchantment::class.java.getDeclaredField("byKey") + .apply { + isAccessible = true + (get(null) as MutableMap).apply { remove(key) } + } + + org.bukkit.enchantments.Enchantment::class.java.getDeclaredField("byName") + .apply { + isAccessible = true + (get(null) as MutableMap).apply { remove(name) } + } + + org.bukkit.enchantments.Enchantment::class.java.getDeclaredField("acceptingNew") + .apply { + isAccessible = true + set(null, true) + } + + org.bukkit.enchantments.Enchantment.registerEnchantment(this) } } diff --git a/eco-core/core-nms/v1_19_R1/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_19_R1/EcoCraftEnchantmentManager.kt b/eco-core/core-nms/v1_19_R1/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_19_R1/EcoCraftEnchantmentManager.kt index a727293c..e8b7995f 100644 --- a/eco-core/core-nms/v1_19_R1/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_19_R1/EcoCraftEnchantmentManager.kt +++ b/eco-core/core-nms/v1_19_R1/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_19_R1/EcoCraftEnchantmentManager.kt @@ -1,8 +1,7 @@ package com.willfp.ecoenchants.proxy.v1_19_R1 -import com.willfp.ecoenchants.proxy.proxies.EcoCraftEnchantmentManagerProxy -import com.willfp.ecoenchants.vanilla.VanillaEnchantmentData -import org.bukkit.NamespacedKey +import com.willfp.ecoenchants.enchant.EcoCraftEnchantmentManagerProxy +import com.willfp.ecoenchants.enchant.VanillaEnchantmentData import org.bukkit.enchantments.Enchantment class EcoCraftEnchantmentManager : EcoCraftEnchantmentManagerProxy { 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 index ddd333b1..9470ff5f 100644 --- 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 @@ -1,11 +1,12 @@ 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 com.willfp.ecoenchants.enchant.EcoEnchant +import com.willfp.ecoenchants.enchant.VanillaEnchantmentData import net.minecraft.world.item.enchantment.Enchantment +import org.bukkit.NamespacedKey import org.bukkit.craftbukkit.v1_19_R2.enchantments.CraftEnchantment + class EcoCraftEnchantment( target: Enchantment, private val data: VanillaEnchantmentData @@ -20,7 +21,26 @@ class EcoCraftEnchantment( return data.conflicts?.contains(other.key) ?: super.conflictsWith(other) } + @Suppress("UNCHECKED_CAST") fun register() { - EcoEnchants.register(this) + org.bukkit.enchantments.Enchantment::class.java.getDeclaredField("byKey") + .apply { + isAccessible = true + (get(null) as MutableMap).apply { remove(key) } + } + + org.bukkit.enchantments.Enchantment::class.java.getDeclaredField("byName") + .apply { + isAccessible = true + (get(null) as MutableMap).apply { remove(name) } + } + + org.bukkit.enchantments.Enchantment::class.java.getDeclaredField("acceptingNew") + .apply { + isAccessible = true + set(null, true) + } + + org.bukkit.enchantments.Enchantment.registerEnchantment(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 index 4cf97e62..8c10ae8b 100644 --- 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 @@ -1,11 +1,8 @@ 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 com.willfp.ecoenchants.enchant.EcoCraftEnchantmentManagerProxy +import com.willfp.ecoenchants.enchant.VanillaEnchantmentData import net.minecraft.core.registries.BuiltInRegistries -import net.minecraft.core.registries.Registries -import org.bukkit.NamespacedKey import org.bukkit.enchantments.Enchantment class EcoCraftEnchantmentManager : EcoCraftEnchantmentManagerProxy { diff --git a/eco-core/core-nms/v1_19_R3/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_19_R3/EcoCraftEnchantment.kt b/eco-core/core-nms/v1_19_R3/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_19_R3/EcoCraftEnchantment.kt index cfc29bb7..cb5285f7 100644 --- a/eco-core/core-nms/v1_19_R3/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_19_R3/EcoCraftEnchantment.kt +++ b/eco-core/core-nms/v1_19_R3/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_19_R3/EcoCraftEnchantment.kt @@ -1,11 +1,12 @@ package com.willfp.ecoenchants.proxy.v1_19_R3 -import com.willfp.ecoenchants.enchants.EcoEnchant -import com.willfp.ecoenchants.enchants.EcoEnchants -import com.willfp.ecoenchants.vanilla.VanillaEnchantmentData +import com.willfp.ecoenchants.enchant.EcoEnchant +import com.willfp.ecoenchants.enchant.VanillaEnchantmentData import net.minecraft.world.item.enchantment.Enchantment +import org.bukkit.NamespacedKey import org.bukkit.craftbukkit.v1_19_R3.enchantments.CraftEnchantment + class EcoCraftEnchantment( target: Enchantment, private val data: VanillaEnchantmentData @@ -20,7 +21,26 @@ class EcoCraftEnchantment( return data.conflicts?.contains(other.key) ?: super.conflictsWith(other) } + @Suppress("UNCHECKED_CAST") fun register() { - EcoEnchants.register(this) + org.bukkit.enchantments.Enchantment::class.java.getDeclaredField("byKey") + .apply { + isAccessible = true + (get(null) as MutableMap).apply { remove(key) } + } + + org.bukkit.enchantments.Enchantment::class.java.getDeclaredField("byName") + .apply { + isAccessible = true + (get(null) as MutableMap).apply { remove(name) } + } + + org.bukkit.enchantments.Enchantment::class.java.getDeclaredField("acceptingNew") + .apply { + isAccessible = true + set(null, true) + } + + org.bukkit.enchantments.Enchantment.registerEnchantment(this) } } diff --git a/eco-core/core-nms/v1_19_R3/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_19_R3/EcoCraftEnchantmentManager.kt b/eco-core/core-nms/v1_19_R3/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_19_R3/EcoCraftEnchantmentManager.kt index a08a21d7..6bc7823c 100644 --- a/eco-core/core-nms/v1_19_R3/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_19_R3/EcoCraftEnchantmentManager.kt +++ b/eco-core/core-nms/v1_19_R3/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_19_R3/EcoCraftEnchantmentManager.kt @@ -1,11 +1,8 @@ package com.willfp.ecoenchants.proxy.v1_19_R3 -import com.willfp.ecoenchants.proxy.proxies.EcoCraftEnchantmentManagerProxy -import com.willfp.ecoenchants.vanilla.VanillaEnchantmentData -import net.minecraft.core.Registry +import com.willfp.ecoenchants.enchant.EcoCraftEnchantmentManagerProxy +import com.willfp.ecoenchants.enchant.VanillaEnchantmentData import net.minecraft.core.registries.BuiltInRegistries -import net.minecraft.core.registries.Registries -import org.bukkit.NamespacedKey import org.bukkit.enchantments.Enchantment class EcoCraftEnchantmentManager : EcoCraftEnchantmentManagerProxy { diff --git a/eco-core/core-nms/v1_20_R1/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_20_R1/EcoCraftEnchantment.kt b/eco-core/core-nms/v1_20_R1/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_20_R1/EcoCraftEnchantment.kt index 9becddb6..94c01b75 100644 --- a/eco-core/core-nms/v1_20_R1/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_20_R1/EcoCraftEnchantment.kt +++ b/eco-core/core-nms/v1_20_R1/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_20_R1/EcoCraftEnchantment.kt @@ -1,11 +1,12 @@ package com.willfp.ecoenchants.proxy.v1_20_R1 -import com.willfp.ecoenchants.enchants.EcoEnchant -import com.willfp.ecoenchants.enchants.EcoEnchants -import com.willfp.ecoenchants.vanilla.VanillaEnchantmentData +import com.willfp.ecoenchants.enchant.EcoEnchant +import com.willfp.ecoenchants.enchant.VanillaEnchantmentData import net.minecraft.world.item.enchantment.Enchantment +import org.bukkit.NamespacedKey import org.bukkit.craftbukkit.v1_20_R1.enchantments.CraftEnchantment + class EcoCraftEnchantment( target: Enchantment, private val data: VanillaEnchantmentData @@ -20,7 +21,26 @@ class EcoCraftEnchantment( return data.conflicts?.contains(other.key) ?: super.conflictsWith(other) } + @Suppress("UNCHECKED_CAST") fun register() { - EcoEnchants.register(this) + org.bukkit.enchantments.Enchantment::class.java.getDeclaredField("byKey") + .apply { + isAccessible = true + (get(null) as MutableMap).apply { remove(key) } + } + + org.bukkit.enchantments.Enchantment::class.java.getDeclaredField("byName") + .apply { + isAccessible = true + (get(null) as MutableMap).apply { remove(name) } + } + + org.bukkit.enchantments.Enchantment::class.java.getDeclaredField("acceptingNew") + .apply { + isAccessible = true + set(null, true) + } + + org.bukkit.enchantments.Enchantment.registerEnchantment(this) } } diff --git a/eco-core/core-nms/v1_20_R1/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_20_R1/EcoCraftEnchantmentManager.kt b/eco-core/core-nms/v1_20_R1/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_20_R1/EcoCraftEnchantmentManager.kt index 6c14b3dc..e5701260 100644 --- a/eco-core/core-nms/v1_20_R1/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_20_R1/EcoCraftEnchantmentManager.kt +++ b/eco-core/core-nms/v1_20_R1/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_20_R1/EcoCraftEnchantmentManager.kt @@ -1,11 +1,8 @@ package com.willfp.ecoenchants.proxy.v1_20_R1 -import com.willfp.ecoenchants.proxy.proxies.EcoCraftEnchantmentManagerProxy -import com.willfp.ecoenchants.vanilla.VanillaEnchantmentData -import net.minecraft.core.Registry +import com.willfp.ecoenchants.enchant.EcoCraftEnchantmentManagerProxy +import com.willfp.ecoenchants.enchant.VanillaEnchantmentData import net.minecraft.core.registries.BuiltInRegistries -import net.minecraft.core.registries.Registries -import org.bukkit.NamespacedKey import org.bukkit.enchantments.Enchantment class EcoCraftEnchantmentManager : EcoCraftEnchantmentManagerProxy { diff --git a/eco-core/core-nms/v1_20_R2/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_20_R2/EcoCraftEnchantment.kt b/eco-core/core-nms/v1_20_R2/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_20_R2/EcoCraftEnchantment.kt index 7260f090..dad9a2c3 100644 --- a/eco-core/core-nms/v1_20_R2/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_20_R2/EcoCraftEnchantment.kt +++ b/eco-core/core-nms/v1_20_R2/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_20_R2/EcoCraftEnchantment.kt @@ -1,9 +1,10 @@ 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 com.willfp.ecoenchants.enchant.EcoEnchant +import com.willfp.ecoenchants.enchant.VanillaEnchantmentData +import com.willfp.ecoenchants.enchant.registration.legacy.LegacyDelegatedEnchantment import net.minecraft.world.item.enchantment.Enchantment +import org.bukkit.NamespacedKey import org.bukkit.craftbukkit.v1_20_R2.enchantments.CraftEnchantment class EcoCraftEnchantment( @@ -20,7 +21,26 @@ class EcoCraftEnchantment( return data.conflicts?.contains(other.key) ?: super.conflictsWith(other) } + @Suppress("UNCHECKED_CAST") fun register() { - EcoEnchants.register(this) + org.bukkit.enchantments.Enchantment::class.java.getDeclaredField("byKey") + .apply { + isAccessible = true + (get(null) as MutableMap).apply { remove(key) } + } + + org.bukkit.enchantments.Enchantment::class.java.getDeclaredField("byName") + .apply { + isAccessible = true + (get(null) as MutableMap).apply { remove(name) } + } + + org.bukkit.enchantments.Enchantment::class.java.getDeclaredField("acceptingNew") + .apply { + isAccessible = true + set(null, true) + } + + org.bukkit.enchantments.Enchantment.registerEnchantment(this) } } diff --git a/eco-core/core-nms/v1_20_R2/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_20_R2/EcoCraftEnchantmentManager.kt b/eco-core/core-nms/v1_20_R2/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_20_R2/EcoCraftEnchantmentManager.kt index 50e193f5..20699773 100644 --- a/eco-core/core-nms/v1_20_R2/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_20_R2/EcoCraftEnchantmentManager.kt +++ b/eco-core/core-nms/v1_20_R2/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_20_R2/EcoCraftEnchantmentManager.kt @@ -1,7 +1,7 @@ package com.willfp.ecoenchants.proxy.v1_20_R2 -import com.willfp.ecoenchants.proxy.proxies.EcoCraftEnchantmentManagerProxy -import com.willfp.ecoenchants.vanilla.VanillaEnchantmentData +import com.willfp.ecoenchants.enchant.EcoCraftEnchantmentManagerProxy +import com.willfp.ecoenchants.enchant.VanillaEnchantmentData import net.minecraft.core.registries.BuiltInRegistries import org.bukkit.enchantments.Enchantment diff --git a/eco-core/core-nms/v1_20_R3/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_20_R3/EcoCraftEnchantment.kt b/eco-core/core-nms/v1_20_R3/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_20_R3/EcoCraftEnchantment.kt deleted file mode 100644 index 13446a33..00000000 --- a/eco-core/core-nms/v1_20_R3/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_20_R3/EcoCraftEnchantment.kt +++ /dev/null @@ -1,28 +0,0 @@ -package com.willfp.ecoenchants.proxy.v1_20_R3 - -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.NamespacedKey -import org.bukkit.craftbukkit.v1_20_R3.enchantments.CraftEnchantment - -class EcoCraftEnchantment( - target: Enchantment, - key: NamespacedKey, - private val data: VanillaEnchantmentData -) : CraftEnchantment(key, 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_20_R3/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_20_R3/EcoCraftEnchantmentManager.kt b/eco-core/core-nms/v1_20_R3/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_20_R3/EcoCraftEnchantmentManager.kt deleted file mode 100644 index 9e7bbc3b..00000000 --- a/eco-core/core-nms/v1_20_R3/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_20_R3/EcoCraftEnchantmentManager.kt +++ /dev/null @@ -1,26 +0,0 @@ -package com.willfp.ecoenchants.proxy.v1_20_R3 - -import com.willfp.ecoenchants.proxy.proxies.EcoCraftEnchantmentManagerProxy -import com.willfp.ecoenchants.proxy.v1_20_R3.EcoCraftEnchantment -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.ENCHANTMENT) { - val key = org.bukkit.craftbukkit.v1_20_R3.util.CraftNamespacedKey.fromMinecraft( - BuiltInRegistries.ENCHANTMENT.getKey(enchant) - ) - - if (key.key != enchantment.key.key) { - continue - } - - EcoCraftEnchantment(enchant, key, data).register() - } - } -} diff --git a/eco-core/core-nms/v1_20_R3/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_20_R3/ModernEnchantmentRegisterer.kt b/eco-core/core-nms/v1_20_R3/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_20_R3/ModernEnchantmentRegisterer.kt index 0023447a..03dd16f6 100644 --- a/eco-core/core-nms/v1_20_R3/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_20_R3/ModernEnchantmentRegisterer.kt +++ b/eco-core/core-nms/v1_20_R3/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_20_R3/ModernEnchantmentRegisterer.kt @@ -4,6 +4,7 @@ import com.willfp.ecoenchants.enchant.EcoEnchant import com.willfp.ecoenchants.enchant.EcoEnchants import com.willfp.ecoenchants.enchant.registration.modern.ModernEnchantmentRegistererProxy import com.willfp.ecoenchants.proxy.v1_20_R3.registration.DelegatedCraftEnchantment +import com.willfp.ecoenchants.proxy.v1_20_R3.registration.ModifiedVanillaCraftEnchantment import com.willfp.ecoenchants.proxy.v1_20_R3.registration.VanillaEcoEnchantsEnchantment import net.minecraft.core.MappedRegistry import net.minecraft.core.Registry @@ -29,8 +30,7 @@ class ModernEnchantmentRegisterer : ModernEnchantmentRegistererProxy { .get(Bukkit.getServer()) as HashMap, org.bukkit.Registry<*>> - // Replace bukkit enchantment registry - init { + override fun replaceRegistry() { val server = Bukkit.getServer() as CraftServer registries[Enchantment::class.java] = CraftRegistry( @@ -40,7 +40,7 @@ class ModernEnchantmentRegisterer : ModernEnchantmentRegistererProxy { val enchant = EcoEnchants.getByID(key.key) if (enchant == null) { - CraftEnchantment(key, registry) + ModifiedVanillaCraftEnchantment(key, registry) } else { DelegatedCraftEnchantment(enchant, registry) } diff --git a/eco-core/core-nms/v1_20_R3/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_20_R3/registration/DelegatedCraftEnchantment.kt b/eco-core/core-nms/v1_20_R3/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_20_R3/registration/DelegatedCraftEnchantment.kt index f72d7375..14beeb40 100644 --- a/eco-core/core-nms/v1_20_R3/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_20_R3/registration/DelegatedCraftEnchantment.kt +++ b/eco-core/core-nms/v1_20_R3/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_20_R3/registration/DelegatedCraftEnchantment.kt @@ -3,7 +3,6 @@ package com.willfp.ecoenchants.proxy.v1_20_R3.registration import com.willfp.eco.util.StringUtils import com.willfp.ecoenchants.display.getFormattedName import com.willfp.ecoenchants.enchant.EcoEnchant -import com.willfp.ecoenchants.enchants.wrap import io.papermc.paper.enchantments.EnchantmentRarity import net.kyori.adventure.text.Component import net.minecraft.world.item.enchantment.Enchantment @@ -65,7 +64,7 @@ class DelegatedCraftEnchantment( } override fun displayName(level: Int): Component { - return StringUtils.toComponent(this.wrap().getFormattedName(level)) + return StringUtils.toComponent(enchant.getFormattedName(level)) } override fun isTradeable(): Boolean { @@ -112,4 +111,4 @@ class DelegatedCraftEnchantment( override fun hashCode(): Int { return Objects.hash(this.key) } -} \ No newline at end of file +} diff --git a/eco-core/core-nms/v1_20_R3/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_20_R3/registration/ModifiedVanillaCraftEnchantment.kt b/eco-core/core-nms/v1_20_R3/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_20_R3/registration/ModifiedVanillaCraftEnchantment.kt new file mode 100644 index 00000000..7b41df49 --- /dev/null +++ b/eco-core/core-nms/v1_20_R3/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_20_R3/registration/ModifiedVanillaCraftEnchantment.kt @@ -0,0 +1,13 @@ +package com.willfp.ecoenchants.proxy.v1_20_R3.registration + +import com.willfp.ecoenchants.enchant.vanillaEnchantmentData +import net.minecraft.world.item.enchantment.Enchantment +import org.bukkit.NamespacedKey +import org.bukkit.craftbukkit.v1_20_R3.enchantments.CraftEnchantment + +class ModifiedVanillaCraftEnchantment( + key: NamespacedKey, + target: Enchantment +) : CraftEnchantment(key, target) { + override fun getMaxLevel(): Int = this.vanillaEnchantmentData?.maxLevel ?: super.getMaxLevel() +} diff --git a/eco-core/core-plugin/build.gradle.kts b/eco-core/core-plugin/build.gradle.kts index fbfd3e32..20b3ea12 100644 --- a/eco-core/core-plugin/build.gradle.kts +++ b/eco-core/core-plugin/build.gradle.kts @@ -6,7 +6,6 @@ dependencies { include("*.jar") } ) - compileOnly(project(":eco-core:core-proxy")) compileOnly("io.papermc.paper:paper-api:1.19.3-R0.1-SNAPSHOT") compileOnly("net.essentialsx:EssentialsX:2.19.7") compileOnly("commons-lang:commons-lang:2.6") diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/EcoEnchantsPlugin.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/EcoEnchantsPlugin.kt index 24c61308..b4b14111 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/EcoEnchantsPlugin.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/EcoEnchantsPlugin.kt @@ -13,13 +13,11 @@ import com.willfp.ecoenchants.config.VanillaEnchantsYml import com.willfp.ecoenchants.display.DisplayCache import com.willfp.ecoenchants.display.EnchantDisplay import com.willfp.ecoenchants.display.EnchantSorter +import com.willfp.ecoenchants.enchant.EcoEnchantLevel +import com.willfp.ecoenchants.enchant.EcoEnchants +import com.willfp.ecoenchants.enchant.EnchantGUI +import com.willfp.ecoenchants.enchant.FoundEcoEnchantLevel import com.willfp.ecoenchants.enchant.registration.EnchantmentRegisterer -import com.willfp.ecoenchants.enchants.EcoEnchantLevel -import com.willfp.ecoenchants.enchants.EcoEnchants -import com.willfp.ecoenchants.enchants.EnchantGUI -import com.willfp.ecoenchants.enchants.FoundEcoEnchantLevel -import com.willfp.ecoenchants.enchants.LoreConversion -import com.willfp.ecoenchants.enchants.registerVanillaEnchants import com.willfp.ecoenchants.integrations.EnchantRegistrations import com.willfp.ecoenchants.integrations.plugins.CMIIntegration import com.willfp.ecoenchants.integrations.plugins.EssentialsIntegration @@ -40,6 +38,9 @@ import com.willfp.libreforge.registerSpecificRefreshFunction import org.bukkit.entity.Player import org.bukkit.event.Listener +internal lateinit var plugin: EcoEnchantsPlugin + private set + class EcoEnchantsPlugin : LibreforgePlugin() { val targetsYml = TargetsYml(this) val rarityYml = RarityYml(this) @@ -51,7 +52,7 @@ class EcoEnchantsPlugin : LibreforgePlugin() { val enchantmentRegisterer: EnchantmentRegisterer = TODO() init { - instance = this + plugin = this } override fun loadConfigCategories(): List { @@ -88,8 +89,6 @@ class EcoEnchantsPlugin : LibreforgePlugin() { } override fun handleReload() { - registerVanillaEnchants(this) - DisplayCache.reload() EnchantSorter.reload(this) ExtraItemSupport.reload(this) @@ -102,7 +101,7 @@ class EcoEnchantsPlugin : LibreforgePlugin() { EnchantingTableSupport(this), LootSupport(this), AnvilSupport(this), - LoreConversion(this), + //LoreConversion(this), GrindstoneSupport(this) ) } @@ -127,11 +126,4 @@ class EcoEnchantsPlugin : LibreforgePlugin() { EnchantDisplay(this) } else null } - - companion object { - /** Instance of EcoEnchants. */ - @JvmStatic - lateinit var instance: EcoEnchantsPlugin - private set - } } diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/commands/CommandEnchant.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/commands/CommandEnchant.kt index f5809a76..ba319cda 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/commands/CommandEnchant.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/commands/CommandEnchant.kt @@ -4,10 +4,8 @@ import com.willfp.eco.core.EcoPlugin import com.willfp.eco.core.command.impl.PluginCommand import com.willfp.eco.util.StringUtils import com.willfp.eco.util.savedDisplayName -import com.willfp.ecoenchants.enchants.wrap -import com.willfp.ecoenchants.rarity.EnchantmentRarities -import com.willfp.ecoenchants.type.EnchantmentTypes -import org.bukkit.Bukkit +import com.willfp.ecoenchants.display.getFormattedName +import com.willfp.ecoenchants.enchant.wrap import org.bukkit.NamespacedKey import org.bukkit.command.CommandSender import org.bukkit.enchantments.Enchantment @@ -48,7 +46,7 @@ class CommandEnchant(plugin: EcoPlugin) : PluginCommand( sender.sendMessage( plugin.langYml.getMessage("added-enchant", StringUtils.FormatOption.WITHOUT_PLACEHOLDERS) - .replace("%enchant%", enchant.wrap().displayName) + .replace("%enchant%", enchant.wrap().getFormattedName(0)) .replace("%player%", player.savedDisplayName) ) } else { @@ -59,7 +57,7 @@ class CommandEnchant(plugin: EcoPlugin) : PluginCommand( sender.sendMessage( plugin.langYml.getMessage("removed-enchant", StringUtils.FormatOption.WITHOUT_PLACEHOLDERS) - .replace("%enchant%", enchant.wrap().displayName) + .replace("%enchant%", enchant.wrap().getFormattedName(0)) .replace("%player%", player.savedDisplayName) ) } diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/commands/CommandEnchantInfo.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/commands/CommandEnchantInfo.kt index 34d731df..2079236f 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/commands/CommandEnchantInfo.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/commands/CommandEnchantInfo.kt @@ -3,7 +3,7 @@ package com.willfp.ecoenchants.commands import com.willfp.eco.core.command.impl.PluginCommand import com.willfp.ecoenchants.EcoEnchantsPlugin import com.willfp.ecoenchants.enchants.EcoEnchants -import com.willfp.ecoenchants.enchants.EnchantGUI +import com.willfp.ecoenchants.enchant.EnchantGUI import org.bukkit.ChatColor import org.bukkit.command.CommandSender import org.bukkit.entity.Player diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/commands/CommandGUI.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/commands/CommandGUI.kt index b96cbab5..a5416f95 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/commands/CommandGUI.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/commands/CommandGUI.kt @@ -2,7 +2,7 @@ package com.willfp.ecoenchants.commands import com.willfp.eco.core.EcoPlugin import com.willfp.eco.core.command.impl.Subcommand -import com.willfp.ecoenchants.enchants.EnchantGUI +import com.willfp.ecoenchants.enchant.EnchantGUI import org.bukkit.command.CommandSender import org.bukkit.entity.Player diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/commands/CommandGiveRandomBook.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/commands/CommandGiveRandomBook.kt index 3e0ea185..1ce52d50 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/commands/CommandGiveRandomBook.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/commands/CommandGiveRandomBook.kt @@ -7,8 +7,8 @@ import com.willfp.eco.core.items.builder.EnchantedBookBuilder import com.willfp.eco.util.NumberUtils import com.willfp.eco.util.StringUtils import com.willfp.ecoenchants.display.getFormattedName -import com.willfp.ecoenchants.enchants.EcoEnchants -import com.willfp.ecoenchants.enchants.wrap +import com.willfp.ecoenchants.enchant.EcoEnchants +import com.willfp.ecoenchants.enchant.wrap import com.willfp.ecoenchants.rarity.EnchantmentRarities import com.willfp.ecoenchants.rarity.EnchantmentRarity import com.willfp.ecoenchants.type.EnchantmentType @@ -51,7 +51,7 @@ class CommandGiveRandomBook(plugin: EcoPlugin) : PluginCommand( val enchantment = EcoEnchants.values() .filter { when (filter) { - is EnchantmentRarity -> it.enchantmentRarity == filter + is EnchantmentRarity -> it.rarity == filter is EnchantmentType -> it.type == filter else -> true } && it.maxLevel >= minLevel @@ -64,7 +64,7 @@ class CommandGiveRandomBook(plugin: EcoPlugin) : PluginCommand( val level = NumberUtils.randInt(minLevel, maxLevel.coerceAtMost(enchantment.maxLevel)) val item = EnchantedBookBuilder() - .addStoredEnchantment(enchantment, level) + .addStoredEnchantment(enchantment.enchantment, level) .build() DropQueue(player) @@ -75,7 +75,7 @@ class CommandGiveRandomBook(plugin: EcoPlugin) : PluginCommand( sender.sendMessage( plugin.langYml.getMessage("gave-random-book", StringUtils.FormatOption.WITHOUT_PLACEHOLDERS) .replace("%player%", player.name) - .replace("%enchantment%", enchantment.wrap().getFormattedName(level)) + .replace("%enchantment%", enchantment.getFormattedName(level)) ) } diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/config/Configs.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/config/Configs.kt index b47b0233..90d2fd75 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/config/Configs.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/config/Configs.kt @@ -3,9 +3,6 @@ package com.willfp.ecoenchants.config import com.willfp.eco.core.EcoPlugin import com.willfp.eco.core.config.BaseConfig import com.willfp.eco.core.config.ConfigType -import com.willfp.eco.core.config.ExtendableConfig -import com.willfp.ecoenchants.enchants.EcoEnchant -import org.bukkit.enchantments.Enchantment class TypesYml(plugin: EcoPlugin) : BaseConfig("types", plugin, true, ConfigType.YAML) class TargetsYml(plugin: EcoPlugin) : BaseConfig("targets", plugin, true, ConfigType.YAML) diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/DescriptionPlaceholder.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/display/DescriptionPlaceholder.kt similarity index 65% rename from eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/DescriptionPlaceholder.kt rename to eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/display/DescriptionPlaceholder.kt index 922f2348..27cf4167 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/DescriptionPlaceholder.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/display/DescriptionPlaceholder.kt @@ -1,4 +1,4 @@ -package com.willfp.ecoenchants.enchants +package com.willfp.ecoenchants.display class DescriptionPlaceholder( val id: String, diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/display/EnchantDisplay.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/display/EnchantDisplay.kt index 791205b9..3227a4b4 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/display/EnchantDisplay.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/display/EnchantDisplay.kt @@ -9,8 +9,8 @@ import com.willfp.eco.core.fast.fast import com.willfp.ecoenchants.EcoEnchantsPlugin import com.willfp.ecoenchants.commands.CommandToggleDescriptions.Companion.seesEnchantmentDescriptions import com.willfp.ecoenchants.display.EnchantSorter.sortForDisplay -import com.willfp.ecoenchants.enchants.EcoEnchant -import com.willfp.ecoenchants.enchants.wrap +import com.willfp.ecoenchants.enchant.EcoEnchant +import com.willfp.ecoenchants.enchant.wrap import com.willfp.ecoenchants.target.EnchantmentTargets.isEnchantable import com.willfp.libreforge.ItemProvidedHolder import org.bukkit.Material diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/display/EnchantmentFormatting.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/display/EnchantmentFormatting.kt index 6a20ad60..de99d45c 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/display/EnchantmentFormatting.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/display/EnchantmentFormatting.kt @@ -7,7 +7,7 @@ import com.willfp.eco.util.NumberUtils import com.willfp.eco.util.StringUtils import com.willfp.eco.util.formatEco import com.willfp.ecoenchants.EcoEnchantsPlugin -import com.willfp.ecoenchants.enchants.EcoEnchantLike +import com.willfp.ecoenchants.enchant.EcoEnchantLike import org.bukkit.entity.Player // This is an object to be able to invalidate the cache on reload @@ -35,20 +35,18 @@ fun EcoEnchantLike.getFormattedName( level: Int, showNotMet: Boolean = false ): String { - val plugin = EcoEnchantsPlugin.instance - return DisplayCache.nameCache.get(DisplayableEnchant(this, level, showNotMet)) { val numerals = plugin.configYml.getBool("display.numerals.enabled") && level <= plugin.configYml.getInt("display.numerals.threshold") val typeFormat = this.type.format - val name = this.unformattedDisplayName + val name = this.rawDisplayName val number = if (numerals) NumberUtils.toNumeral(level) else level.toString() - val dontShowNumber = (level == 1 && this.enchant.maxLevel == 1) || level < 1 + val dontShowNumber = (level == 1 && this.enchantment.maxLevel == 1) || level < 1 val notMetFormat = if (showNotMet) plugin.configYml.getString("display.not-met.format") else "" - if (plugin.configYml.getBool("display.above-max-level.enabled") && level > this.enchant.maxLevel) { + if (plugin.configYml.getBool("display.above-max-level.enabled") && level > this.enchantment.maxLevel) { val format = plugin.configYml.getString("display.above-max-level.format") val levelOnly = plugin.configYml.getBool("display.above-max-level.level-only") @@ -74,13 +72,11 @@ private val resetTags = arrayOf( ) fun EcoEnchantLike.getFormattedDescription(level: Int, player: Player? = null): List { - val plugin = EcoEnchantsPlugin.instance - return DisplayCache.descriptionCache.get(DisplayableEnchant(this, level)) { val descriptionFormat = plugin.configYml.getString("display.descriptions.format") val wrap = plugin.configYml.getInt("display.descriptions.word-wrap") - var description = descriptionFormat + this.getUnformattedDescription(level, player) + var description = descriptionFormat + this.getRawDescription(level, player) // Replace reset tags with description format for (tag in resetTags) { diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/display/Sorters.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/display/Sorters.kt index 6f6d4411..b3af6069 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/display/Sorters.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/display/Sorters.kt @@ -1,7 +1,7 @@ package com.willfp.ecoenchants.display import com.willfp.ecoenchants.EcoEnchantsPlugin -import com.willfp.ecoenchants.enchants.wrap +import com.willfp.ecoenchants.enchant.wrap import com.willfp.ecoenchants.rarity.EnchantmentRarities import com.willfp.ecoenchants.rarity.EnchantmentRarity import com.willfp.ecoenchants.type.EnchantmentType @@ -41,13 +41,13 @@ fun List.getSafely(index: Int) = object AlphabeticSorter : EnchantmentSorter { override fun sort(enchantments: Collection, children: List): List { - return enchantments.sortedBy { ChatColor.stripColor(it.wrap().displayName) } + return enchantments.sortedBy { ChatColor.stripColor(it.wrap().getFormattedName(0)) } } } object LengthSorter : EnchantmentSorter { override fun sort(enchantments: Collection, children: List): List { - return enchantments.sortedBy { ChatColor.stripColor(it.wrap().displayName)!!.length } + return enchantments.sortedBy { ChatColor.stripColor(it.wrap().getFormattedName(0))!!.length } } } @@ -93,7 +93,7 @@ object RaritySorter : EnchantmentSorter { for (rarity in rarities) { for (enchantment in children.getSafely(0).sort(enchantments, children.drop(1))) { - if (rarity != enchantment.wrap().enchantmentRarity) { + if (rarity != enchantment.wrap().rarity) { continue } diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/EcoEnchant.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/EcoEnchant.kt index 9e6cfebd..f10b23ba 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/EcoEnchant.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/EcoEnchant.kt @@ -24,6 +24,16 @@ interface EcoEnchant : KRegistrable, EcoEnchantLike { */ val maxLevel: Int + /** + * If this enchantment conflicts with all other enchantments. + */ + val conflictsWithEverything: Boolean + + /** + * The conflicts. + */ + val conflicts: Set + /** * The enchantment targets. */ diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/EcoEnchantLike.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/EcoEnchantLike.kt index 1f768a81..aa20b8af 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/EcoEnchantLike.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/EcoEnchantLike.kt @@ -8,8 +8,7 @@ import com.willfp.eco.core.placeholder.StaticPlaceholder import com.willfp.eco.core.placeholder.context.placeholderContext import com.willfp.eco.util.NumberUtils import com.willfp.ecoenchants.EcoEnchantsPlugin -import com.willfp.ecoenchants.enchants.DescriptionPlaceholder -import com.willfp.ecoenchants.enchants.wrap +import com.willfp.ecoenchants.display.DescriptionPlaceholder import com.willfp.ecoenchants.mechanics.infiniteIfNegative import com.willfp.ecoenchants.rarity.EnchantmentRarity import com.willfp.ecoenchants.type.EnchantmentType diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/EcoEnchants.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/EcoEnchants.kt index cb945746..5ee19406 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/EcoEnchants.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/EcoEnchants.kt @@ -7,7 +7,6 @@ import com.willfp.ecoenchants.enchant.impl.hardcoded.EnchantmentPermanenceCurse import com.willfp.ecoenchants.enchant.impl.hardcoded.EnchantmentRepairing import com.willfp.ecoenchants.enchant.impl.hardcoded.EnchantmentReplenish import com.willfp.ecoenchants.enchant.impl.hardcoded.EnchantmentSoulbound -import com.willfp.ecoenchants.enchants.sendPrompts import com.willfp.ecoenchants.integrations.EnchantRegistrations import com.willfp.ecoenchants.rarity.EnchantmentRarities import com.willfp.ecoenchants.target.EnchantmentTargets @@ -39,42 +38,46 @@ object EcoEnchants : RegistrableCategory("enchant", "enchants") { override fun afterReload(plugin: LibreforgePlugin) { plugin as EcoEnchantsPlugin - sendPrompts(plugin) registerHardcodedEnchantments(plugin) } override fun acceptConfig(plugin: LibreforgePlugin, id: String, config: Config) { plugin as EcoEnchantsPlugin - val enchant = createEnchantment(plugin, id, config) ?: return + if (!config.has("effects")) { + return + } - registry.register(enchant) + val enchant = LibreforgeEcoEnchant( + id, + config, + plugin + ) + + doRegister(plugin, enchant) + } + + private fun doRegister(plugin: EcoEnchantsPlugin, enchant: EcoEnchant) { plugin.enchantmentRegisterer.register(enchant) + // Register delegated versions + registry.register(enchant.enchantment as EcoEnchant) EnchantRegistrations.registerEnchantments() } - private fun createEnchantment(plugin: LibreforgePlugin, id: String, config: Config): EcoEnchant? { - plugin as EcoEnchantsPlugin - - if (config.has("effects")) { - // Libreforge - return LibreforgeEcoEnchant( - id, - config, - plugin - ) - } else { - TODO() - } - } - - /** Register the hardcoded enchantments. */ private fun registerHardcodedEnchantments( plugin: EcoEnchantsPlugin ) { - EnchantmentPermanenceCurse(plugin) - EnchantmentRepairing(plugin) - EnchantmentReplenish(plugin) - EnchantmentSoulbound(plugin) + val hardcodedEnchantments = listOf( + EnchantmentPermanenceCurse(plugin), + EnchantmentRepairing(plugin), + EnchantmentReplenish(plugin), + EnchantmentSoulbound(plugin) + ) + + for (enchantment in hardcodedEnchantments) { + if (enchantment.isPresent) { + doRegister(plugin, enchantment) + } + } } } diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/EnchantGUI.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/EnchantGUI.kt similarity index 92% rename from eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/EnchantGUI.kt rename to eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/EnchantGUI.kt index e7bf455a..8ab320fc 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/EnchantGUI.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/EnchantGUI.kt @@ -1,4 +1,4 @@ -package com.willfp.ecoenchants.enchants +package com.willfp.ecoenchants.enchant import com.github.benmanes.caffeine.cache.Caffeine import com.willfp.eco.core.config.base.LangYml @@ -73,7 +73,7 @@ object EnchantGUI { onRender { player, menu -> val atCaptive = menu.getCaptiveItem(player, captiveRow, captiveColumn) if (atCaptive.isEmpty || atCaptive == null || atCaptive.type == Material.BOOK) { - menu.setState(player, "enchants", EcoEnchants.values().sortForDisplay()) + menu.setState(player, "enchants", EcoEnchants.values().map { it.enchantment }.sortForDisplay()) } else { menu.setState( player, @@ -207,32 +207,32 @@ private val cachedEnchantmentSlots = Caffeine.newBuilder() private fun EcoEnchant.getInformationSlot(plugin: EcoEnchantsPlugin, player: Player): Slot { return cachedEnchantmentSlots.get(this) { val level = if (plugin.configYml.getBool("enchantinfo.item.show-max-level")) { - enchant.maxLevel + it.maxLevel } else { 1 } slot( EnchantedBookBuilder() - .addStoredEnchantment(enchant, level) + .addStoredEnchantment(enchantment, level) .addItemFlag(ItemFlag.HIDE_ENCHANTS) - .setDisplayName(enchant.getFormattedName(level)) - .addLoreLines(enchant.getFormattedDescription(level, player)) + .setDisplayName(this.getFormattedName(level)) + .addLoreLines(this.getFormattedDescription(level, player)) .addLoreLines { plugin.configYml.getStrings("enchantinfo.item.lore") .map { - it.replace("%max_level%", enchant.maxLevel.toString()) - .replace("%rarity%", enchant.enchantmentRarity.displayName) + it.replace("%max_level%", enchantment.maxLevel.toString()) + .replace("%rarity%", this.rarity.displayName) .replace( "%targets%", - enchant.targets.joinToString(", ") { target -> target.displayName } + this.targets.joinToString(", ") { target -> target.displayName } ) .replace( "%conflicts%", - if (enchant.conflictsWithEverything) { + if (this.conflictsWithEverything) { plugin.langYml.getFormattedString("all-conflicts") } else { - enchant.conflicts.joinToString(", ") { conflict -> + this.conflicts.joinToString(", ") { conflict -> conflict.wrap().getFormattedName(0) }.ifEmpty { plugin.langYml.getFormattedString("no-conflicts") } } diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/Util.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/Util.kt index 2cd838b9..004cbd11 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/Util.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/Util.kt @@ -1,7 +1,7 @@ package com.willfp.ecoenchants.enchant -import com.willfp.ecoenchants.EcoEnchantsPlugin import com.willfp.ecoenchants.enchant.impl.VanillaEcoEnchantLike +import com.willfp.ecoenchants.plugin import org.bukkit.NamespacedKey import org.bukkit.enchantments.Enchantment @@ -14,7 +14,7 @@ fun Enchantment.wrap(): EcoEnchantLike { } return ecoEnchantLikes.getOrPut(this.key) { - VanillaEcoEnchantLike(this, EcoEnchantsPlugin.instance) + VanillaEcoEnchantLike(this, plugin) } } diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/VanillaEnchantments.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/VanillaEnchantments.kt new file mode 100644 index 00000000..36a3a47c --- /dev/null +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/VanillaEnchantments.kt @@ -0,0 +1,24 @@ +package com.willfp.ecoenchants.enchant + +import com.willfp.ecoenchants.plugin +import org.bukkit.NamespacedKey +import org.bukkit.enchantments.Enchantment + +val Enchantment.vanillaEnchantmentData: VanillaEnchantmentData? + get() { + val vanilla = plugin.vanillaEnchantsYml.getSubsectionOrNull(key.key) ?: return null + + return VanillaEnchantmentData( + vanilla.getIntOrNull("max-level"), + vanilla.getStringsOrNull("conflicts")?.map { NamespacedKey.minecraft(it) } + ) + } + +interface EcoCraftEnchantmentManagerProxy { + fun registerNewCraftEnchantment(enchantment: Enchantment, data: VanillaEnchantmentData) +} + +data class VanillaEnchantmentData( + val maxLevel: Int?, + val conflicts: Collection? +) diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/impl/EcoEnchantBase.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/impl/EcoEnchantBase.kt index 141aebb2..83ae1e21 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/impl/EcoEnchantBase.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/impl/EcoEnchantBase.kt @@ -1,6 +1,7 @@ package com.willfp.ecoenchants.enchant.impl import com.willfp.eco.core.config.interfaces.Config +import com.willfp.eco.util.containsIgnoreCase import com.willfp.ecoenchants.EcoEnchantsPlugin import com.willfp.ecoenchants.enchant.EcoEnchant import com.willfp.ecoenchants.enchant.EcoEnchantLevel @@ -32,6 +33,14 @@ abstract class EcoEnchantBase( override val maxLevel = config.getInt("max-level") + override val conflictsWithEverything: Boolean + get() = conflictIds.containsIgnoreCase("all") + || conflictIds.containsIgnoreCase("everything") + + override val conflicts = config.getStrings("conflicts") + .mapNotNull { Enchantment.getByKey(NamespacedKey.minecraft(it)) } + .toSet() + override val targets = config.getStrings("targets") .mapNotNull { EnchantmentTargets[it] } .toSet() diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/impl/HardcodedEcoEnchant.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/impl/HardcodedEcoEnchant.kt index 667a86b4..7883da90 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/impl/HardcodedEcoEnchant.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/impl/HardcodedEcoEnchant.kt @@ -12,11 +12,15 @@ abstract class HardcodedEcoEnchant( id: String, plugin: EcoEnchantsPlugin ) : EcoEnchantBase(id, plugin) { - final override fun loadConfig(): Config { - return File(plugin.dataFolder, "enchants") + private val file: File? + get() = File(plugin.dataFolder, "enchants") .walk() .firstOrNull { file -> file.nameWithoutExtension == id } - .readConfig(ConfigType.YAML) + + val isPresent = file != null + + final override fun loadConfig(): Config { + return file.readConfig(ConfigType.YAML) } override fun createLevel(level: Int): EcoEnchantLevel { diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/impl/hardcoded/EnchantmentRepairing.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/impl/hardcoded/EnchantmentRepairing.kt index f8dc6777..4f737041 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/impl/hardcoded/EnchantmentRepairing.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/impl/hardcoded/EnchantmentRepairing.kt @@ -2,7 +2,7 @@ package com.willfp.ecoenchants.enchant.impl.hardcoded import com.willfp.eco.util.DurabilityUtils import com.willfp.ecoenchants.EcoEnchantsPlugin -import com.willfp.ecoenchants.enchants.EcoEnchant +import com.willfp.ecoenchants.enchant.impl.HardcodedEcoEnchant import com.willfp.ecoenchants.target.EnchantLookup.getActiveEnchantLevelInSlot import com.willfp.ecoenchants.target.EnchantLookup.hasEnchantActive import com.willfp.libreforge.slot.impl.SlotTypeHands @@ -10,12 +10,11 @@ import org.bukkit.Bukkit class EnchantmentRepairing( plugin: EcoEnchantsPlugin -) : EcoEnchant( +) : HardcodedEcoEnchant( "repairing", - plugin, - force = false + plugin ) { - override fun onInit() { + override fun onRegister() { val frequency = config.getInt("frequency").toLong() plugin.scheduler.runTimer(frequency, frequency) { diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/impl/hardcoded/EnchantmentReplenish.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/impl/hardcoded/EnchantmentReplenish.kt index dfe07358..a46e231d 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/impl/hardcoded/EnchantmentReplenish.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/impl/hardcoded/EnchantmentReplenish.kt @@ -2,7 +2,8 @@ package com.willfp.ecoenchants.enchant.impl.hardcoded import com.willfp.eco.core.EcoPlugin import com.willfp.ecoenchants.EcoEnchantsPlugin -import com.willfp.ecoenchants.enchants.EcoEnchant +import com.willfp.ecoenchants.enchant.EcoEnchant +import com.willfp.ecoenchants.enchant.impl.HardcodedEcoEnchant import com.willfp.ecoenchants.target.EnchantLookup.hasEnchantActive import org.bukkit.Bukkit import org.bukkit.Material @@ -17,13 +18,18 @@ import org.bukkit.inventory.ItemStack class EnchantmentReplenish( plugin: EcoEnchantsPlugin -) : EcoEnchant( +) : HardcodedEcoEnchant( "replenish", - plugin, - force = false + plugin ) { - override fun onInit() { - this.registerListener(ReplenishHandler(this, plugin)) + private var handler = ReplenishHandler(this, plugin) + + override fun onRegister() { + plugin.eventManager.registerListener(handler) + } + + override fun onRemove() { + plugin.eventManager.unregisterListener(handler) } private class ReplenishHandler( diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/impl/hardcoded/EnchantmentSoulbound.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/impl/hardcoded/EnchantmentSoulbound.kt index 856ca18d..fc7fa375 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/impl/hardcoded/EnchantmentSoulbound.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/impl/hardcoded/EnchantmentSoulbound.kt @@ -9,7 +9,8 @@ import com.willfp.eco.core.drops.DropQueue import com.willfp.eco.core.fast.fast import com.willfp.eco.core.items.Items import com.willfp.ecoenchants.EcoEnchantsPlugin -import com.willfp.ecoenchants.enchants.EcoEnchant +import com.willfp.ecoenchants.enchant.impl.HardcodedEcoEnchant +import com.willfp.ecoenchants.enchant.EcoEnchant import com.willfp.ecoenchants.target.EnchantLookup.getActiveEnchantLevelInSlot import com.willfp.ecoenchants.target.EnchantLookup.hasEnchantActive import org.bukkit.entity.Player @@ -24,13 +25,18 @@ import org.bukkit.persistence.PersistentDataType class EnchantmentSoulbound( plugin: EcoEnchantsPlugin -) : EcoEnchant( +) : HardcodedEcoEnchant( "soulbound", - plugin, - force = false + plugin ) { - override fun onInit() { - this.registerListener(SoulboundHandler(plugin, this)) + private val handler = SoulboundHandler(plugin, this) + + override fun onRegister() { + plugin.eventManager.registerListener(handler) + } + + override fun onRemove() { + plugin.eventManager.unregisterListener(handler) } private class SoulboundHandler( @@ -92,7 +98,7 @@ class EnchantmentSoulbound( if (enchant.config.getBool("single-use")) { val meta = item.itemMeta - meta.removeEnchant(enchant) + meta.removeEnchant(enchant.enchantment) item.itemMeta = meta } } @@ -139,7 +145,7 @@ class EnchantmentSoulbound( ) fun preventDroppingSoulboundItems(event: PlayerDeathEvent) { event.drops.removeIf { it.fast().persistentDataContainer.has(soulboundKey, PersistentDataType.INTEGER) - && it.itemMeta.hasEnchant(enchant) + && it.itemMeta.hasEnchant(enchant.enchantment) } } } diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/registration/EnchantmentRegisterer.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/registration/EnchantmentRegisterer.kt index 61f675ab..9baa0c7c 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/registration/EnchantmentRegisterer.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/registration/EnchantmentRegisterer.kt @@ -6,4 +6,4 @@ interface EnchantmentRegisterer { fun register(enchant: EcoEnchant) fun unregister(enchant: EcoEnchant) -} \ No newline at end of file +} diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/registration/legacy/LegacyDelegatedEnchantment.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/registration/legacy/LegacyDelegatedEnchantment.kt index 542bb132..f283fb25 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/registration/legacy/LegacyDelegatedEnchantment.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/registration/legacy/LegacyDelegatedEnchantment.kt @@ -3,7 +3,7 @@ package com.willfp.ecoenchants.enchant.registration.legacy import com.willfp.eco.util.StringUtils import com.willfp.ecoenchants.display.getFormattedName import com.willfp.ecoenchants.enchant.EcoEnchant -import com.willfp.ecoenchants.enchants.wrap +import com.willfp.ecoenchants.enchant.wrap import io.papermc.paper.enchantments.EnchantmentRarity import net.kyori.adventure.text.Component import org.bukkit.enchantments.Enchantment diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/registration/modern/ModernEnchantmentRegistererProxy.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/registration/modern/ModernEnchantmentRegistererProxy.kt index 4714493a..0e091768 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/registration/modern/ModernEnchantmentRegistererProxy.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchant/registration/modern/ModernEnchantmentRegistererProxy.kt @@ -3,4 +3,8 @@ package com.willfp.ecoenchants.enchant.registration.modern import com.willfp.ecoenchants.enchant.registration.EnchantmentRegisterer interface ModernEnchantmentRegistererProxy : EnchantmentRegisterer { + /** + * Replace the bukkit enchantment registry with the new EcoEnchants one. + */ + fun replaceRegistry() } diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/EcoEnchant.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/EcoEnchant.kt deleted file mode 100644 index 0bf1efd2..00000000 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/EcoEnchant.kt +++ /dev/null @@ -1,336 +0,0 @@ -package com.willfp.ecoenchants.enchants - -import com.github.benmanes.caffeine.cache.Caffeine -import com.willfp.eco.core.config.ConfigType -import com.willfp.eco.core.config.config -import com.willfp.eco.core.config.interfaces.Config -import com.willfp.eco.core.config.readConfig -import com.willfp.eco.core.fast.fast -import com.willfp.eco.core.placeholder.PlayerlessPlaceholder -import com.willfp.eco.core.placeholder.context.PlaceholderContext -import com.willfp.eco.core.placeholder.templates.SimpleInjectablePlaceholder -import com.willfp.eco.core.registry.KRegistrable -import com.willfp.eco.util.StringUtils -import com.willfp.eco.util.containsIgnoreCase -import com.willfp.ecoenchants.EcoEnchantsPlugin -import com.willfp.ecoenchants.display.getFormattedName -import com.willfp.ecoenchants.mechanics.infiniteIfNegative -import com.willfp.ecoenchants.rarity.EnchantmentRarities -import com.willfp.ecoenchants.target.EnchantmentTargets -import com.willfp.ecoenchants.type.EnchantmentTypes -import com.willfp.libreforge.SilentViolationContext -import com.willfp.libreforge.ViolationContext -import com.willfp.libreforge.conditions.ConditionList -import com.willfp.libreforge.conditions.Conditions -import com.willfp.libreforge.effects.emptyEffectList -import com.willfp.libreforge.slot.SlotType -import net.kyori.adventure.text.Component -import org.bukkit.Bukkit -import org.bukkit.Material -import org.bukkit.NamespacedKey -import org.bukkit.enchantments.Enchantment -import org.bukkit.enchantments.EnchantmentTarget -import org.bukkit.entity.EntityCategory -import org.bukkit.event.Listener -import org.bukkit.inventory.EquipmentSlot -import org.bukkit.inventory.ItemStack -import org.bukkit.permissions.Permission -import org.bukkit.permissions.PermissionDefault -import java.io.File -import java.util.Objects - - -@Suppress("DEPRECATION") -abstract class EcoEnchant( - override val id: String, - configProvider: (EcoEnchant) -> Config, - protected val plugin: EcoEnchantsPlugin -) : Enchantment(NamespacedKey.minecraft(id)), EcoEnchantLike, KRegistrable { - final override val config by lazy { configProvider(this) } - override val enchant by lazy { this } - - private val levels = Caffeine.newBuilder() - .build() - - override val displayName = config.getFormattedString("display-name") - override val unformattedDisplayName = config.getString("display-name") - - val conditions: ConditionList - - val targets = config.getStrings("targets") - .mapNotNull { EnchantmentTargets[it] } - - val slots: Set - get() = targets.map { it.slot }.toSet() - - override val type = EnchantmentTypes[config.getString("type")] ?: EnchantmentTypes.values().first() - - override val enchantmentRarity = - EnchantmentRarities[config.getString("rarity")] ?: EnchantmentRarities.values().first() - - private val conflictNames = config.getStrings("conflicts") - - private val _listeners = mutableListOf() - - val listeners: List - get() = this._listeners - - val conflictsWithEverything: Boolean - get() = conflictNames.containsIgnoreCase("all") - || conflictNames.containsIgnoreCase("everything") - - val conflicts: Collection - get() = if (conflictsWithEverything) values().toList() - else conflictNames.mapNotNull { getByKey(NamespacedKey.minecraft(it)) } - - constructor( - config: Config, - plugin: EcoEnchantsPlugin - ) : this(config.getString("id"), { config }, plugin) - - constructor( - id: String, - config: Config, - plugin: EcoEnchantsPlugin - ) : this(id, { config }, plugin) - - @JvmOverloads - constructor( - id: String, - plugin: EcoEnchantsPlugin, - force: Boolean = true - ) : this( - id, - { - if (force) { - EnchantmentConfig(id, it::class.java, plugin) - } else { - val file = File(plugin.dataFolder, "enchants") - .walk() - .firstOrNull { file -> file.nameWithoutExtension == id } - - file?.readConfig(ConfigType.YAML) ?: config { - "dont-register" to true - } - } - }, - plugin - ) - - init { - checkDependencies() - - config.injectPlaceholders( - object : SimpleInjectablePlaceholder("level") { - override fun getValue(args: String, context: PlaceholderContext): String? { - return context.itemStack?.fast()?.getEnchantmentLevel(this@EcoEnchant)?.toString() - } - } - ) - - PlayerlessPlaceholder(plugin, "${id}_name") { - this.getFormattedName(0, false) - }.register() - - conditions = Conditions.compile( - config.getSubsections("conditions"), - if (plugin.isLoaded) ViolationContext(plugin, "Enchantment $id") - else SilentViolationContext - ) - - if (Bukkit.getPluginManager().getPermission("ecoenchants.fromtable.$id") == null) { - val permission = Permission( - "ecoenchants.fromtable.$id", - "Allows getting $id from an Enchanting Table", - PermissionDefault.TRUE - ) - - if (Bukkit.getPluginManager().getPermission("ecoenchants.fromtable.*") == null) { - Bukkit.getPluginManager().addPermission( - Permission( - "ecoenchants.fromtable.*", - "Allows getting all enchantments from an Enchanting Table", - PermissionDefault.TRUE - ) - ) - } - - permission.addParent( - Bukkit.getPluginManager().getPermission("ecoenchants.fromtable.*")!!, - true - ) - - Bukkit.getPluginManager().addPermission(permission) - } - - // Non-forced enchantments with deleted configs will have this as their entire config (see above), - // and that way the enchantment isn't registered. - if (!config.getBool("dont-register")) { - register() - if (plugin.isEnabled) { - doOnInit() - } - } - } - - private fun checkDependencies() { - val missingPlugins = mutableSetOf() - - for (dependency in config.getStrings("dependencies")) { - if (!Bukkit.getPluginManager().plugins.map { it.name }.containsIgnoreCase(dependency)) { - missingPlugins += dependency - } - } - - if (missingPlugins.isNotEmpty()) { - config.set("dont-register", true) // Just in case. - throw MissingDependencyException(missingPlugins) - } - } - - private fun doOnInit() { - onInit() - } - - protected open fun onInit() { - // Override when needed - } - - private fun register() { - EcoEnchants.addNewEnchant(this) - } - - fun getLevel(level: Int): EcoEnchantLevel = levels.get(level) { - createLevel(it) - } - - open fun createLevel(level: Int) = - EcoEnchantLevel(this, level, emptyEffectList(), conditions, plugin) - - fun registerListener(listener: Listener) { - this.plugin.eventManager.registerListener(listener) - this._listeners += listener - } - - @Deprecated( - message = "getName is a legacy Spigot API", - replaceWith = ReplaceWith("this.displayName(level)") - ) - override fun getName(): String = this.id.uppercase() - - override fun getMaxLevel(): Int = this.config.getInt("max-level") - - override fun getStartLevel(): Int = 1 - - @Deprecated( - message = "getItemTargets is an incompatible Spigot API", - replaceWith = ReplaceWith("this.targets") - ) - override fun getItemTarget(): EnchantmentTarget = EnchantmentTarget.ALL - - val isEnchantable: Boolean = this.config.getBool("enchantable") - - @Deprecated( - message = "Treasure enchantments do not exist in EcoEnchants", - replaceWith = ReplaceWith("this.isEnchantable") - ) - override fun isTreasure(): Boolean = !isEnchantable - - override fun isCursed(): Boolean { - return false - } - - fun conflictsWithDirectly(other: Enchantment): Boolean { - return conflictNames.containsIgnoreCase(other.key.key) || conflictsWithEverything - } - - override fun conflictsWith(other: Enchantment): Boolean { - if (conflictsWithDirectly(other)) { - return true - } - - if (other !is EcoEnchant) { - return false - } - - return other.conflictsWithDirectly(this) - } - - override fun canEnchantItem(item: ItemStack): Boolean { - if ( - item.fast().getEnchants(true).keys - .map { it.wrap() } - .count { it.type == this.type } >= this.type.limit - ) { - return false - } - - if (item.fast().getEnchants(true).any { (enchant, _) -> enchant.conflictsWithDeep(this) }) { - return false - } - - if (item.fast().getEnchants(true).size >= plugin.configYml.getInt("anvil.enchant-limit").infiniteIfNegative()) { - return false - } - - if (item.type == Material.ENCHANTED_BOOK) { - return true - } - - return targets.any { it.matches(item) } - } - - override fun displayName(level: Int): Component { - return StringUtils.toComponent(this.wrap().getFormattedName(level)) - } - - override fun isTradeable(): Boolean = this.config.getBool("tradeable") - - override fun isDiscoverable(): Boolean = this.config.getBool("discoverable") - - @Deprecated( - message = "EcoEnchants do not have damage increase, this method is for sharpness/boa/smite", - replaceWith = ReplaceWith("0.0f") - ) - override fun getDamageIncrease(level: Int, entityCategory: EntityCategory): Float = 0.0f - - @Deprecated( - message = "getActiveSlots is an incompatible Paper API", - replaceWith = ReplaceWith("this.slots") - ) - override fun getActiveSlots() = emptySet() - - @Suppress("DeprecatedCallableAddReplaceWith") - @Deprecated( - message = "Enchant display overrides this system" - ) - override fun translationKey(): String = "ecoenchants:enchantment.$id" - - @Deprecated( - message = "EcoEnchants uses a custom system for enchantment rarity", - replaceWith = ReplaceWith("this.enchantRarity") - ) - override fun getRarity(): io.papermc.paper.enchantments.EnchantmentRarity { - return io.papermc.paper.enchantments.EnchantmentRarity.RARE - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - if (other !is EcoEnchant) { - return false - } - - return other.id == this.id - } - - override fun hashCode(): Int { - return Objects.hash(id) - } - - override fun toString(): String { - return "EcoEnchant{$key}" - } -} diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/EcoEnchantLevel.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/EcoEnchantLevel.kt deleted file mode 100644 index 6daa0d3c..00000000 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/EcoEnchantLevel.kt +++ /dev/null @@ -1,42 +0,0 @@ -package com.willfp.ecoenchants.enchants - -import com.willfp.eco.core.EcoPlugin -import com.willfp.libreforge.Holder -import com.willfp.libreforge.conditions.ConditionList -import com.willfp.libreforge.effects.EffectList -import java.util.Objects - -class EcoEnchantLevel( - val enchant: EcoEnchant, - val level: Int, - override val effects: EffectList, - override val conditions: ConditionList, - plugin: EcoPlugin -) : Holder { - override val id = plugin.createNamespacedKey("${enchant.id}_$level") - - override fun equals(other: Any?): Boolean { - if (other !is EcoEnchantLevel) { - return false - } - - return this.id == other.id - } - - override fun toString(): String { - return id.toString() - } - - override fun hashCode(): Int { - return Objects.hash(this.id) - } -} - -data class FoundEcoEnchantLevel( - val level: EcoEnchantLevel, - val activeLevel: Int -): Holder { - override val effects = level.effects - override val conditions = level.conditions - override val id = level.id -} diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/EcoEnchantLike.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/EcoEnchantLike.kt deleted file mode 100644 index 58bff892..00000000 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/EcoEnchantLike.kt +++ /dev/null @@ -1,131 +0,0 @@ -package com.willfp.ecoenchants.enchants - -import com.github.benmanes.caffeine.cache.Caffeine -import com.willfp.eco.core.config.interfaces.Config -import com.willfp.eco.core.fast.fast -import com.willfp.eco.core.placeholder.InjectablePlaceholder -import com.willfp.eco.core.placeholder.PlaceholderInjectable -import com.willfp.eco.core.placeholder.StaticPlaceholder -import com.willfp.eco.core.placeholder.context.placeholderContext -import com.willfp.eco.util.NumberUtils -import com.willfp.ecoenchants.EcoEnchantsPlugin -import com.willfp.ecoenchants.mechanics.infiniteIfNegative -import com.willfp.ecoenchants.proxy.proxies.EcoCraftEnchantmentManagerProxy -import com.willfp.ecoenchants.rarity.EnchantmentRarities -import com.willfp.ecoenchants.rarity.EnchantmentRarity -import com.willfp.ecoenchants.type.EnchantmentType -import com.willfp.ecoenchants.type.EnchantmentTypes -import com.willfp.ecoenchants.vanilla.VanillaEnchantmentData -import org.bukkit.Material -import org.bukkit.NamespacedKey -import org.bukkit.enchantments.Enchantment -import org.bukkit.entity.Player -import org.bukkit.inventory.ItemStack -import java.util.* - -interface EcoEnchantLike { - val config: Config - val type: EnchantmentType - val displayName: String - val unformattedDisplayName: String - val enchant: Enchantment - val enchantmentRarity: EnchantmentRarity - - // Includes all extra logic not found in vanilla canEnchantItem - fun canEnchantItem(item: ItemStack): Boolean - // Java backwards compatibility - fun getUnformattedDescription(level: Int): String { - return getUnformattedDescription(level, null) - } -} - -private val ecoEnchantLikes = Caffeine.newBuilder() - .build() - -fun Enchantment.wrap(): EcoEnchantLike { - if (this is EcoEnchant) { - return this - } - return ecoEnchantLikes.get(this.key) { - VanillaEcoEnchantLike(this, EcoEnchantsPlugin.instance) // Jank - } -} - -fun Enchantment.conflictsWithDeep(other: Enchantment): Boolean { - return this.conflictsWith(other) || other.conflictsWith(this) -} - -class VanillaEcoEnchantLike( - override val enchant: Enchantment, - private val plugin: EcoEnchantsPlugin -) : EcoEnchantLike { - override val config = plugin.vanillaEnchantsYml.getSubsection(enchant.key.key) - - override val type: EnchantmentType = - EnchantmentTypes[plugin.vanillaEnchantsYml.getString("${enchant.key.key}.type")] - ?: EnchantmentTypes.values().first() - - override val enchantmentRarity: EnchantmentRarity = - EnchantmentRarities[plugin.vanillaEnchantsYml.getString("${enchant.key.key}.rarity")] - ?: EnchantmentRarities.values().first() - - override val displayName = plugin.vanillaEnchantsYml.getFormattedString("${enchant.key.key}.name") - override val unformattedDisplayName = plugin.vanillaEnchantsYml.getString("${enchant.key.key}.name") - - override fun canEnchantItem(item: ItemStack): Boolean { - // Yes this code is copied from EcoEnchant, but I can't be bothered to abstract it properly - if ( - item.fast().getEnchants(true).keys - .map { it.wrap() } - .count { it.type == this.type } >= this.type.limit - ) { - return false - } - - if (item.fast().getEnchants(true).any { (enchant, _) -> enchant.conflictsWithDeep(this.enchant) }) { - return false - } - - if (item.fast().getEnchants(true).size >= plugin.configYml.getInt("anvil.enchant-limit").infiniteIfNegative()) { - return false - } - - if (item.type == Material.ENCHANTED_BOOK) { - return true - } - - return enchant.canEnchantItem(item) - } - - override fun equals(other: Any?): Boolean { - if (other !is VanillaEcoEnchantLike) { - return false - } - - return this.enchant == other.enchant - } - - override fun hashCode(): Int { - return Objects.hash(this.enchant) - } -} - -private val enchantmentOptions = arrayOf( - "max-level", - "conflicts" -) - -fun registerVanillaEnchants(plugin: EcoEnchantsPlugin) { - for (vanilla in plugin.vanillaEnchantsYml.getKeys(false)) { - if (enchantmentOptions.any { plugin.vanillaEnchantsYml.has("$vanilla.$it") }) { - plugin.getProxy(EcoCraftEnchantmentManagerProxy::class.java).registerNewCraftEnchantment( - Enchantment.getByKey(NamespacedKey.minecraft(vanilla))!!, - VanillaEnchantmentData( - plugin.vanillaEnchantsYml.getIntOrNull("$vanilla.max-level"), - plugin.vanillaEnchantsYml.getStringsOrNull("$vanilla.conflicts") - ?.map { NamespacedKey.minecraft(it) } - ) - ) - } - } -} diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/EcoEnchants.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/EcoEnchants.kt deleted file mode 100644 index 30a8c675..00000000 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/EcoEnchants.kt +++ /dev/null @@ -1,127 +0,0 @@ -package com.willfp.ecoenchants.enchants - -import com.willfp.eco.core.config.interfaces.Config -import com.willfp.ecoenchants.EcoEnchantsPlugin -import com.willfp.ecoenchants.enchant.impl.hardcoded.EnchantmentPermanenceCurse -import com.willfp.ecoenchants.enchant.impl.hardcoded.EnchantmentRepairing -import com.willfp.ecoenchants.enchant.impl.hardcoded.EnchantmentReplenish -import com.willfp.ecoenchants.enchant.impl.hardcoded.EnchantmentSoulbound -import com.willfp.ecoenchants.integrations.EnchantRegistrations -import com.willfp.ecoenchants.rarity.EnchantmentRarities -import com.willfp.ecoenchants.target.EnchantmentTargets -import com.willfp.ecoenchants.type.EnchantmentTypes -import com.willfp.libreforge.loader.LibreforgePlugin -import com.willfp.libreforge.loader.configs.RegistrableCategory -import org.bukkit.NamespacedKey -import org.bukkit.enchantments.Enchantment - -@Suppress("UNUSED") -object EcoEnchants : RegistrableCategory("enchant", "enchants") { - override fun clear(plugin: LibreforgePlugin) { - for (enchant in values()) { - removeEnchant(enchant) - - for (listener in enchant.listeners) { - plugin.eventManager.unregisterListener(listener) - } - } - } - - override fun beforeReload(plugin: LibreforgePlugin) { - plugin as EcoEnchantsPlugin - - EnchantmentRarities.update(plugin) - EnchantmentTargets.update(plugin) - EnchantmentTypes.update(plugin) - } - - override fun afterReload(plugin: LibreforgePlugin) { - plugin as EcoEnchantsPlugin - - sendPrompts(plugin) - registerHardcodedEnchantments(plugin) - } - - override fun acceptConfig(plugin: LibreforgePlugin, id: String, config: Config) { - plugin as EcoEnchantsPlugin - - if (config.has("effects")) { - try { - LibReforgeEcoEnchant( - id, - config, - plugin - ) - } catch (e: MissingDependencyException) { - addPluginPrompt(plugin, e.plugins) - } - } - } - - /** - * Remove [Enchantment] from EcoEnchants. - * - * @param enchant The [Enchantment] to remove. - */ - @JvmStatic - @Suppress("UNCHECKED_CAST", "DEPRECATION") - fun removeEnchant(enchant: Enchantment) { - if (enchant is EcoEnchant) { - registry.remove(enchant.id) - EnchantRegistrations.removeEnchant(enchant) - } - - Enchantment::class.java.getDeclaredField("byKey") - .apply { - isAccessible = true - (get(null) as MutableMap).apply { remove(enchant.key) } - } - - Enchantment::class.java.getDeclaredField("byName") - .apply { - isAccessible = true - (get(null) as MutableMap).apply { remove(enchant.name) } - } - } - - /** - * Add new [EcoEnchant] to EcoEnchants. - * - * Only for internal use, enchants are automatically added in the - * constructor. - * - * @param enchant The [EcoEnchant] to add. - */ - internal fun addNewEnchant(enchant: EcoEnchant) { - register(enchant) - } - - /** - * Register a new [Enchantment] with the server. - * - * @param enchantment The [Enchantment] to add. - */ - @JvmStatic - fun register(enchantment: Enchantment) { - Enchantment::class.java.getDeclaredField("acceptingNew") - .apply { - isAccessible = true - set(null, true) - } - - removeEnchant(enchantment) - - Enchantment.registerEnchantment(enchantment) - EnchantRegistrations.registerEnchantments() - } - - /** Register the hardcoded enchantments. */ - private fun registerHardcodedEnchantments( - plugin: EcoEnchantsPlugin - ) { - EnchantmentPermanenceCurse(plugin) - EnchantmentRepairing(plugin) - EnchantmentReplenish(plugin) - EnchantmentSoulbound(plugin) - } -} diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/EnchantmentConfigs.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/EnchantmentConfigs.kt deleted file mode 100644 index 2424b409..00000000 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/EnchantmentConfigs.kt +++ /dev/null @@ -1,18 +0,0 @@ -package com.willfp.ecoenchants.enchants - -import com.willfp.eco.core.EcoPlugin -import com.willfp.eco.core.config.ConfigType -import com.willfp.eco.core.config.ExtendableConfig - -class EnchantmentConfig( - name: String, - source: Class<*>, - plugin: EcoPlugin -) : ExtendableConfig( - name, - true, - plugin, - source, - "enchants/", - ConfigType.YAML -) diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/LibReforgeEcoEnchant.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/LibReforgeEcoEnchant.kt deleted file mode 100644 index 7c300d1d..00000000 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/LibReforgeEcoEnchant.kt +++ /dev/null @@ -1,27 +0,0 @@ -package com.willfp.ecoenchants.enchants - -import com.willfp.eco.core.config.interfaces.Config -import com.willfp.ecoenchants.EcoEnchantsPlugin -import com.willfp.libreforge.SilentViolationContext -import com.willfp.libreforge.ViolationContext -import com.willfp.libreforge.effects.Effects -import com.willfp.libreforge.effects.emptyEffectList - -class LibReforgeEcoEnchant( - id: String, - config: Config, - plugin: EcoEnchantsPlugin -) : EcoEnchant( - id, - config, - plugin -) { - private val effects = Effects.compile( - config.getSubsections("effects"), - if (plugin.isLoaded) ViolationContext(plugin, "Enchantment $id") - else SilentViolationContext - ) - - override fun createLevel(level: Int): EcoEnchantLevel = - EcoEnchantLevel(this, level, effects, conditions, plugin) -} diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/LoreConversion.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/LoreConversion.kt deleted file mode 100644 index d13ca4b2..00000000 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/LoreConversion.kt +++ /dev/null @@ -1,116 +0,0 @@ -package com.willfp.ecoenchants.enchants - -import com.willfp.eco.core.EcoPlugin -import com.willfp.eco.core.fast.fast -import com.willfp.eco.util.NumberUtils -import org.bukkit.ChatColor -import org.bukkit.enchantments.Enchantment -import org.bukkit.event.EventHandler -import org.bukkit.event.Listener -import org.bukkit.event.inventory.InventoryOpenEvent -import org.bukkit.event.player.PlayerItemHeldEvent -import org.bukkit.inventory.BlockInventoryHolder -import org.bukkit.inventory.ItemStack -import org.bukkit.inventory.meta.EnchantmentStorageMeta - - -class LoreConversion( - private val plugin: EcoPlugin -) : Listener { - @EventHandler - fun loreConverter(event: PlayerItemHeldEvent) { - if (!plugin.configYml.getBool("lore-conversion.enabled")) { - return - } - - convertLore(event.player.inventory.getItem(event.newSlot)) - } - - @EventHandler - fun aggressiveLoreConverter(event: InventoryOpenEvent) { - if (!plugin.configYml.getBool("lore-conversion.enabled")) { - return - } - if (!plugin.configYml.getBool("lore-conversion.aggressive")) { - return - } - - val inventory = event.inventory - - if (inventory.holder !is BlockInventoryHolder) { - return - } - - for (itemStack in inventory.contents) { - convertLore(itemStack) - } - } - - private fun convertLore(itemStack: ItemStack?) { - if (itemStack == null) { - return - } - - val meta = itemStack.itemMeta ?: return - - val toAdd = mutableMapOf() - - val lore = itemStack.fast().lore.toMutableList() - - for (line in lore.toList()) { - val uncolored = ChatColor.stripColor(line) ?: continue - - var enchant: EcoEnchant? - var level: Int - val split = uncolored.split(" ").toMutableList() - - if (split.isEmpty()) { - continue - } - - if (split.size == 1) { - enchant = EcoEnchants.getByName(split[0]) - level = 1 - } else { - val attemptFullLine = EcoEnchants.getByName(line) - if (attemptFullLine != null) { - enchant = attemptFullLine - level = 1 - } else { - var levelString = split.last() - split.remove(levelString) - levelString = levelString.trim { it <= ' ' } - level = try { - NumberUtils.fromNumeral(levelString) - } catch (e: IllegalArgumentException) { - continue - } - val enchantName = split.joinToString(" ") - enchant = EcoEnchants.getByName(enchantName) - } - } - - if (enchant == null) { - continue - } - - toAdd[enchant] = level - } - - - if (meta is EnchantmentStorageMeta) { - lore.clear() - for ((enchant, level) in toAdd) { - meta.addStoredEnchant(enchant, level, true) - } - } else { - lore.clear() - for ((enchant, level) in toAdd) { - meta.addEnchant(enchant, level, true) - } - } - - itemStack.itemMeta = meta - itemStack.fast().lore = lore - } -} diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/MissingDependencyException.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/MissingDependencyException.kt deleted file mode 100644 index 6da9b010..00000000 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/MissingDependencyException.kt +++ /dev/null @@ -1,34 +0,0 @@ -package com.willfp.ecoenchants.enchants - -import com.willfp.eco.core.EcoPlugin -import com.willfp.ecoenchants.EcoEnchantsPlugin - -class MissingDependencyException( - val plugins: Set -) : Exception() { - override val message = "Missing the following plugins: ${plugins.joinToString(", ")}" -} - -// Plugin names mapped to enchants that aren't installed. -private val prompts = mutableMapOf() - -fun addPluginPrompt(plugin: EcoEnchantsPlugin, plugins: Set) { - if (!plugin.isLoaded) { - return - } - - for (pluginName in plugins) { - prompts[pluginName] = prompts.getOrDefault(pluginName, 0) + 1 - } -} - -fun sendPrompts(plugin: EcoPlugin) { - for ((pl, amount) in prompts) { - plugin.logger.apply { - warning("$amount enchantments were not loaded because they need $pl to be installed!") - warning("Either download $pl or delete the folder at /plugins/EcoEnchants/enchants/${pl.lowercase()} to remove this message") - } - } - - prompts.clear() -} diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/libreforge/TriggerEnchantType.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/libreforge/TriggerEnchantType.kt index 75343f7c..4e039930 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/libreforge/TriggerEnchantType.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/libreforge/TriggerEnchantType.kt @@ -2,7 +2,7 @@ package com.willfp.ecoenchants.libreforge import com.willfp.eco.core.EcoPlugin import com.willfp.eco.core.fast.fast -import com.willfp.ecoenchants.enchants.wrap +import com.willfp.ecoenchants.enchant.wrap import com.willfp.ecoenchants.type.EnchantmentType import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/mechanics/AnvilSupport.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/mechanics/AnvilSupport.kt index dc690a5f..c57857aa 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/mechanics/AnvilSupport.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/mechanics/AnvilSupport.kt @@ -4,9 +4,8 @@ import com.willfp.eco.core.EcoPlugin import com.willfp.eco.core.fast.fast import com.willfp.eco.core.proxy.ProxyConstants import com.willfp.eco.util.StringUtils -import com.willfp.ecoenchants.enchants.EcoEnchants -import com.willfp.ecoenchants.enchants.wrap -import com.willfp.ecoenchants.proxy.proxies.OpenInventoryProxy +import com.willfp.ecoenchants.enchant.EcoEnchants +import com.willfp.ecoenchants.enchant.wrap import org.bukkit.ChatColor import org.bukkit.Material import org.bukkit.Tag @@ -35,6 +34,10 @@ fun Int.infiniteIfNegative() = if (this < 1) Int.MAX_VALUE else this private val FAIL = AnvilResult(null, null) +interface OpenInventoryProxy { + fun getOpenInventory(player: Player): Any +} + @Suppress("DEPRECATION") class AnvilSupport( private val plugin: EcoPlugin @@ -155,7 +158,7 @@ class AnvilSupport( val permanenceCurse = EcoEnchants.getByID("permanence_curse") if (permanenceCurse != null) { - if (left.fast().getEnchants(true).containsKey(permanenceCurse)) { + if (left.fast().getEnchants(true).containsKey(permanenceCurse.enchantment)) { return FAIL } } diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/mechanics/EnchantingTableSupport.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/mechanics/EnchantingTableSupport.kt index a7f47236..6baa9c5e 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/mechanics/EnchantingTableSupport.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/mechanics/EnchantingTableSupport.kt @@ -6,9 +6,9 @@ import com.willfp.eco.core.recipe.parts.EmptyTestableItem import com.willfp.eco.util.NumberUtils import com.willfp.eco.util.randDouble import com.willfp.ecoenchants.EcoEnchantsPlugin -import com.willfp.ecoenchants.enchants.EcoEnchant -import com.willfp.ecoenchants.enchants.EcoEnchants -import com.willfp.ecoenchants.enchants.conflictsWithDeep +import com.willfp.ecoenchants.enchant.EcoEnchant +import com.willfp.ecoenchants.enchant.EcoEnchants +import com.willfp.ecoenchants.enchant.conflictsWithDeep import org.bukkit.Bukkit import org.bukkit.GameMode import org.bukkit.Material @@ -93,16 +93,16 @@ class EnchantingTableSupport( continue } - val baseChance = enchantment.enchantmentRarity.tableChance * multiplier + val baseChance = enchantment.rarity.tableChance * multiplier - val chanceEvent = EnchantingTableChanceGenerateEvent(player, item, enchantment, baseChance) + val chanceEvent = EnchantingTableChanceGenerateEvent(player, item, enchantment.enchantment, baseChance) Bukkit.getPluginManager().callEvent(chanceEvent) if (NumberUtils.randFloat(0.0, 1.0) > chanceEvent.chance) { continue } - if (enchantment.enchantmentRarity.minimumLevel > cost) { + if (enchantment.rarity.minimumLevel > cost) { continue } @@ -114,7 +114,7 @@ class EnchantingTableSupport( break } - if (toAdd.any { (it, _) -> enchantment.conflictsWithDeep(it) }) { + if (toAdd.any { (it, _) -> enchantment.enchantment.conflictsWithDeep(it) }) { continue } @@ -140,7 +140,7 @@ class EnchantingTableSupport( multiplier /= this.plugin.configYml.getDouble("enchanting-table.reduction") - toAdd[enchantment] = level + toAdd[enchantment.enchantment] = level } toAdd.forEach(event.enchantsToAdd::putIfAbsent) diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/mechanics/GrindstoneSupport.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/mechanics/GrindstoneSupport.kt index 5a674e5a..7f96a1f6 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/mechanics/GrindstoneSupport.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/mechanics/GrindstoneSupport.kt @@ -2,32 +2,15 @@ package com.willfp.ecoenchants.mechanics import com.willfp.eco.core.EcoPlugin import com.willfp.eco.core.fast.fast -import com.willfp.eco.util.StringUtils -import com.willfp.ecoenchants.enchants.EcoEnchants -import com.willfp.ecoenchants.enchants.wrap -import org.bukkit.ChatColor -import org.bukkit.Material +import com.willfp.ecoenchants.enchant.wrap import org.bukkit.enchantments.Enchantment -import org.bukkit.entity.EntityType -import org.bukkit.entity.ExperienceOrb -import org.bukkit.entity.Player import org.bukkit.event.EventHandler -import org.bukkit.event.EventPriority import org.bukkit.event.Listener import org.bukkit.event.inventory.InventoryClickEvent -import org.bukkit.event.inventory.InventoryType -import org.bukkit.event.inventory.PrepareAnvilEvent import org.bukkit.inventory.GrindstoneInventory -import org.bukkit.inventory.ItemStack -import org.bukkit.inventory.meta.Damageable import org.bukkit.inventory.meta.EnchantmentStorageMeta import java.util.* -import javax.swing.text.html.HTML.Tag.P -import kotlin.math.abs import kotlin.math.max -import kotlin.math.min -import kotlin.math.pow -import kotlin.math.roundToInt @Suppress("DEPRECATION") class GrindstoneSupport( diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/mechanics/LootSupport.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/mechanics/LootSupport.kt index f0d3ca92..d29c6567 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/mechanics/LootSupport.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/mechanics/LootSupport.kt @@ -3,9 +3,9 @@ package com.willfp.ecoenchants.mechanics import com.willfp.eco.core.fast.fast import com.willfp.eco.util.NumberUtils import com.willfp.ecoenchants.EcoEnchantsPlugin -import com.willfp.ecoenchants.enchants.EcoEnchant -import com.willfp.ecoenchants.enchants.EcoEnchants -import com.willfp.ecoenchants.enchants.conflictsWithDeep +import com.willfp.ecoenchants.enchant.EcoEnchant +import com.willfp.ecoenchants.enchant.EcoEnchants +import com.willfp.ecoenchants.enchant.conflictsWithDeep import com.willfp.ecoenchants.target.EnchantmentTargets.isEnchantable import org.bukkit.Material import org.bukkit.event.EventHandler @@ -53,11 +53,11 @@ class LootSupport( continue } - if (NumberUtils.randFloat(0.0, 1.0) > enchantment.enchantmentRarity.lootChance * multiplier) { + if (NumberUtils.randFloat(0.0, 1.0) > enchantment.rarity.lootChance * multiplier) { continue } - if (enchants.any { (it, _) -> enchantment.conflictsWithDeep(it) }) { + if (enchants.any { (it, _) -> enchantment.enchantment.conflictsWithDeep(it) }) { continue } @@ -80,7 +80,7 @@ class LootSupport( multiplier /= this.plugin.configYml.getDouble("villager.reduction") - enchants[enchantment] = level + enchants[enchantment.enchantment] = level } val meta = item.itemMeta diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/mechanics/VillagerSupport.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/mechanics/VillagerSupport.kt index aac4c319..91ee81b8 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/mechanics/VillagerSupport.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/mechanics/VillagerSupport.kt @@ -3,9 +3,9 @@ package com.willfp.ecoenchants.mechanics import com.willfp.eco.core.fast.fast import com.willfp.eco.util.NumberUtils import com.willfp.ecoenchants.EcoEnchantsPlugin -import com.willfp.ecoenchants.enchants.EcoEnchant -import com.willfp.ecoenchants.enchants.EcoEnchants -import com.willfp.ecoenchants.enchants.conflictsWithDeep +import com.willfp.ecoenchants.enchant.EcoEnchant +import com.willfp.ecoenchants.enchant.EcoEnchants +import com.willfp.ecoenchants.enchant.conflictsWithDeep import com.willfp.ecoenchants.target.EnchantmentTargets.isEnchantable import org.bukkit.Material import org.bukkit.event.EventHandler @@ -54,11 +54,11 @@ class VillagerSupport( continue } - if (NumberUtils.randFloat(0.0, 1.0) > enchantment.enchantmentRarity.villagerChance * multiplier) { + if (NumberUtils.randFloat(0.0, 1.0) > enchantment.rarity.villagerChance * multiplier) { continue } - if (enchants.any { (it, _) -> enchantment.conflictsWithDeep(it) }) { + if (enchants.any { (it, _) -> enchantment.enchantment.conflictsWithDeep(it) }) { continue } @@ -85,10 +85,10 @@ class VillagerSupport( if (result.type == Material.ENCHANTED_BOOK) { // Only allow one enchantment enchants.clear() - enchants[enchantment] = level + enchants[enchantment.enchantment] = level break } else { - enchants[enchantment] = level + enchants[enchantment.enchantment] = level } } diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/target/EnchantLookup.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/target/EnchantLookup.kt index d037c13c..1e8d4f8e 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/target/EnchantLookup.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/target/EnchantLookup.kt @@ -4,9 +4,10 @@ import com.github.benmanes.caffeine.cache.Caffeine import com.willfp.eco.core.fast.fast import com.willfp.eco.core.items.HashedItem import com.willfp.ecoenchants.EcoEnchantsPlugin -import com.willfp.ecoenchants.enchants.EcoEnchant -import com.willfp.ecoenchants.enchants.EcoEnchantLevel -import com.willfp.ecoenchants.enchants.FoundEcoEnchantLevel +import com.willfp.ecoenchants.enchant.EcoEnchant +import com.willfp.ecoenchants.enchant.EcoEnchantLevel +import com.willfp.ecoenchants.enchant.FoundEcoEnchantLevel +import com.willfp.ecoenchants.plugin import com.willfp.libreforge.ItemProvidedHolder import com.willfp.libreforge.slot.SlotType import com.willfp.libreforge.slot.SlotTypes @@ -302,7 +303,7 @@ object EnchantLookup { // This is such a fucking disgusting way of implementing %active_level%, // and it's probably quite slow too. - return if (EcoEnchantsPlugin.instance.configYml.getBool("extra-placeholders.active-level")) { + return if (plugin.configYml.getBool("extra-placeholders.active-level")) { found.map { val level = it.holder as EcoEnchantLevel diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/target/EnchantmentTarget.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/target/EnchantmentTarget.kt index 6552a075..351a8a67 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/target/EnchantmentTarget.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/target/EnchantmentTarget.kt @@ -6,12 +6,11 @@ import com.willfp.eco.core.items.TestableItem import com.willfp.eco.core.recipe.parts.EmptyTestableItem import com.willfp.eco.core.registry.Registrable import com.willfp.ecoenchants.EcoEnchantsPlugin +import com.willfp.ecoenchants.plugin import com.willfp.libreforge.slot.SlotType import com.willfp.libreforge.slot.SlotTypes import com.willfp.libreforge.slot.impl.SlotTypeAny -import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack -import java.lang.IllegalArgumentException import java.util.Objects interface EnchantmentTarget : Registrable { @@ -62,7 +61,7 @@ class ConfiguredEnchantmentTarget( internal object AllEnchantmentTarget : EnchantmentTarget { override val id = "all" - override val displayName = EcoEnchantsPlugin.instance.langYml.getFormattedString("all") + override val displayName = plugin.langYml.getFormattedString("all") override val slot = SlotTypeAny override var items = emptyList() private set diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/target/EnchantmentTargets.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/target/EnchantmentTargets.kt index 32763cf4..c99f2756 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/target/EnchantmentTargets.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/target/EnchantmentTargets.kt @@ -1,22 +1,20 @@ package com.willfp.ecoenchants.target import com.github.benmanes.caffeine.cache.Caffeine -import com.google.common.collect.ImmutableSet import com.willfp.eco.core.items.HashedItem import com.willfp.eco.core.registry.Registry import com.willfp.ecoenchants.EcoEnchantsPlugin -import com.willfp.ecoenchants.enchants.EcoEnchant -import com.willfp.ecoenchants.enchants.EcoEnchants -import com.willfp.ecoenchants.enchants.wrap +import com.willfp.ecoenchants.enchant.EcoEnchant +import com.willfp.ecoenchants.enchant.EcoEnchants +import com.willfp.ecoenchants.plugin import org.bukkit.Material -import org.bukkit.enchantments.Enchantment import org.bukkit.inventory.ItemStack import java.util.concurrent.TimeUnit -object EnchantmentTargets: Registry() { +object EnchantmentTargets : Registry() { init { register(AllEnchantmentTarget) - update(EcoEnchantsPlugin.instance) + update(plugin) } private fun getForItem(item: ItemStack): List { diff --git a/eco-core/core-proxy/build.gradle.kts b/eco-core/core-proxy/build.gradle.kts deleted file mode 100644 index 5f2e1936..00000000 --- a/eco-core/core-proxy/build.gradle.kts +++ /dev/null @@ -1,6 +0,0 @@ -group = "com.willfp" -version = rootProject.version - -dependencies { - compileOnly("io.papermc.paper:paper-api:1.17.1-R0.1-SNAPSHOT") -} diff --git a/eco-core/core-proxy/src/main/kotlin/com/willfp/ecoenchants/proxy/proxies/EcoCraftEnchantmentManagerProxy.kt b/eco-core/core-proxy/src/main/kotlin/com/willfp/ecoenchants/proxy/proxies/EcoCraftEnchantmentManagerProxy.kt deleted file mode 100644 index 3a996ad8..00000000 --- a/eco-core/core-proxy/src/main/kotlin/com/willfp/ecoenchants/proxy/proxies/EcoCraftEnchantmentManagerProxy.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.willfp.ecoenchants.proxy.proxies - -import com.willfp.ecoenchants.vanilla.VanillaEnchantmentData -import org.bukkit.NamespacedKey -import org.bukkit.enchantments.Enchantment - -interface EcoCraftEnchantmentManagerProxy { - fun registerNewCraftEnchantment(enchantment: Enchantment, data: VanillaEnchantmentData) -} diff --git a/eco-core/core-proxy/src/main/kotlin/com/willfp/ecoenchants/proxy/proxies/OpenInventoryProxy.kt b/eco-core/core-proxy/src/main/kotlin/com/willfp/ecoenchants/proxy/proxies/OpenInventoryProxy.kt deleted file mode 100644 index 0cbd9f34..00000000 --- a/eco-core/core-proxy/src/main/kotlin/com/willfp/ecoenchants/proxy/proxies/OpenInventoryProxy.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.willfp.ecoenchants.proxy.proxies - -import org.bukkit.entity.Player - -interface OpenInventoryProxy { - fun getOpenInventory(player: Player): Any -} diff --git a/eco-core/core-proxy/src/main/kotlin/com/willfp/ecoenchants/vanilla/VanillaEnchantmentData.kt b/eco-core/core-proxy/src/main/kotlin/com/willfp/ecoenchants/vanilla/VanillaEnchantmentData.kt deleted file mode 100644 index 7049d312..00000000 --- a/eco-core/core-proxy/src/main/kotlin/com/willfp/ecoenchants/vanilla/VanillaEnchantmentData.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.willfp.ecoenchants.vanilla - -import org.bukkit.NamespacedKey - -data class VanillaEnchantmentData( - val maxLevel: Int?, - val conflicts: Collection? -) diff --git a/settings.gradle.kts b/settings.gradle.kts index 242bed00..6db2ec69 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -12,7 +12,6 @@ rootProject.name = "EcoEnchants" // Core include(":eco-core") include(":eco-core:core-plugin") -include(":eco-core:core-proxy") include(":eco-core:core-nms") include(":eco-core:core-nms:v1_17_R1") include(":eco-core:core-nms:v1_18_R1")