mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-08-28 16:35:57 +02:00
Compare commits
3 commits
dff35bcc00
...
ab47a9df93
| Author | SHA1 | Date | |
|---|---|---|---|
| ab47a9df93 | |||
| d18ee56ff1 | |||
| 58c9fa129a |
6 changed files with 23 additions and 13 deletions
|
|
@ -69,10 +69,10 @@ dependencies {
|
||||||
compileOnly(files("libs/EnchantsSquared.jar"))
|
compileOnly(files("libs/EnchantsSquared.jar"))
|
||||||
|
|
||||||
// EcoEnchants & item
|
// EcoEnchants & item
|
||||||
compileOnly("com.willfp:libreforge:4.79.0:all")
|
compileOnly("com.willfp:libreforge:2026.32:all")
|
||||||
compileOnly("com.willfp:eco:6.74.5")
|
compileOnly("com.willfp:eco:2026.32")
|
||||||
|
|
||||||
compileOnly("com.willfp:EcoEnchants:12.11.1")
|
compileOnly("com.willfp:EcoEnchants:2026.32:all")
|
||||||
compileOnly(project(":impl:LegacyEcoEnchant"))
|
compileOnly(project(":impl:LegacyEcoEnchant"))
|
||||||
|
|
||||||
compileOnly("com.willfp:EcoItems:5.66.0")
|
compileOnly("com.willfp:EcoItems:5.66.0")
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@ object DependencyManager {
|
||||||
|
|
||||||
var enchantmentSquaredCompatibility: EnchantmentSquaredDependency? = null
|
var enchantmentSquaredCompatibility: EnchantmentSquaredDependency? = null
|
||||||
var ecoEnchantCompatibility: EcoEnchantDependency? = null
|
var ecoEnchantCompatibility: EcoEnchantDependency? = null
|
||||||
|
var hasEcoItem: Boolean = false
|
||||||
var excellentEnchantsCompatibility: ExcellentEnchantsDependency? = null
|
var excellentEnchantsCompatibility: ExcellentEnchantsDependency? = null
|
||||||
|
|
||||||
var disenchantmentCompatibility: DisenchantmentDependency? = null
|
var disenchantmentCompatibility: DisenchantmentDependency? = null
|
||||||
|
|
@ -78,6 +79,10 @@ object DependencyManager {
|
||||||
ecoEnchantCompatibility = EcoEnchantDependency(pluginManager.getPlugin("EcoEnchants")!!)
|
ecoEnchantCompatibility = EcoEnchantDependency(pluginManager.getPlugin("EcoEnchants")!!)
|
||||||
ecoEnchantCompatibility!!.disableAnvilListener()
|
ecoEnchantCompatibility!!.disableAnvilListener()
|
||||||
}
|
}
|
||||||
|
// EcoItem check
|
||||||
|
if (pluginManager.isPluginEnabled("EcoItems")) {
|
||||||
|
hasEcoItem = true
|
||||||
|
}
|
||||||
|
|
||||||
// Excellent Enchants dependency
|
// Excellent Enchants dependency
|
||||||
if (pluginManager.isPluginEnabled("ExcellentEnchants")) {
|
if (pluginManager.isPluginEnabled("ExcellentEnchants")) {
|
||||||
|
|
|
||||||
|
|
@ -223,7 +223,11 @@ object DataPackDependency {
|
||||||
|
|
||||||
private fun setEnchantAsAll(ench: String) {
|
private fun setEnchantAsAll(ench: String) {
|
||||||
// We assume current is not null and of type CABukkitEnchantment
|
// We assume current is not null and of type CABukkitEnchantment
|
||||||
val current = EnchantmentApi.getByKey(NamespacedKey.fromString(ench)!!) as CABukkitEnchantment
|
val current = EnchantmentApi.getByKey(NamespacedKey.fromString(ench)!!) as? CABukkitEnchantment
|
||||||
|
if(current == null) {
|
||||||
|
CustomAnvil.instance.logger.warning("Could not find enchant $ench")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// We need to replace current wrapped enchantment with the all conflict wrapper
|
// We need to replace current wrapped enchantment with the all conflict wrapper
|
||||||
EnchantmentApi.unregisterEnchantment(current)
|
EnchantmentApi.unregisterEnchantment(current)
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ package xyz.alexcrea.cuanvil.dependency.plugins
|
||||||
import com.willfp.eco.core.EcoPlugin
|
import com.willfp.eco.core.EcoPlugin
|
||||||
import com.willfp.ecoenchants.enchant.EcoEnchant
|
import com.willfp.ecoenchants.enchant.EcoEnchant
|
||||||
import com.willfp.ecoenchants.enchant.EcoEnchants
|
import com.willfp.ecoenchants.enchant.EcoEnchants
|
||||||
import com.willfp.ecoenchants.mechanics.infiniteIfNegative
|
import com.willfp.ecoenchants.enchant.UtilKt
|
||||||
import io.delilaheve.CustomAnvil
|
import io.delilaheve.CustomAnvil
|
||||||
import org.bukkit.event.inventory.PrepareAnvilEvent
|
import org.bukkit.event.inventory.PrepareAnvilEvent
|
||||||
import org.bukkit.plugin.Plugin
|
import org.bukkit.plugin.Plugin
|
||||||
|
|
@ -35,7 +35,7 @@ class EcoEnchantDependency(private val ecoEnchantPlugin: Plugin) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public fun getEcoLevelLimit(): Int {
|
public fun getEcoLevelLimit(): Int {
|
||||||
return (ecoEnchantPlugin as EcoPlugin).configYml.getInt("anvil.enchant-limit").infiniteIfNegative()
|
return UtilKt.infiniteIfNegative((ecoEnchantPlugin as EcoPlugin).configYml.getInt("anvil.enchant-limit"))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun disableAnvilListener() {
|
fun disableAnvilListener() {
|
||||||
|
|
@ -51,7 +51,7 @@ class EcoEnchantDependency(private val ecoEnchantPlugin: Plugin) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val enchantments = EcoEnchants.values()
|
val enchantments = EcoEnchants.INSTANCE.values()
|
||||||
for (ecoEnchant in enchantments) {
|
for (ecoEnchant in enchantments) {
|
||||||
EnchantmentApi.unregisterEnchantment(ecoEnchant.enchantment) // As eco enchants is loaded before custom anvil and register enchantment to registry, we need to unregister old "vanilla" enchant.
|
EnchantmentApi.unregisterEnchantment(ecoEnchant.enchantment) // As eco enchants is loaded before custom anvil and register enchantment to registry, we need to unregister old "vanilla" enchant.
|
||||||
EnchantmentApi.registerEnchantment(CAEcoEnchant(ecoEnchant))
|
EnchantmentApi.registerEnchantment(CAEcoEnchant(ecoEnchant))
|
||||||
|
|
@ -71,7 +71,7 @@ class EcoEnchantDependency(private val ecoEnchantPlugin: Plugin) {
|
||||||
// Should not happen in known case.
|
// Should not happen in known case.
|
||||||
if (this.ecoEnchantOldEnchantments == null) return
|
if (this.ecoEnchantOldEnchantments == null) return
|
||||||
|
|
||||||
val newEnchantments = EcoEnchants.values()
|
val newEnchantments = EcoEnchants.INSTANCE.values()
|
||||||
|
|
||||||
// Add new enchantments
|
// Add new enchantments
|
||||||
for (ecoEnchant in newEnchantments)
|
for (ecoEnchant in newEnchantments)
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ object MaterialUtil {
|
||||||
|
|
||||||
val ItemStack.customType: NamespacedKey
|
val ItemStack.customType: NamespacedKey
|
||||||
get() {
|
get() {
|
||||||
if(DependencyManager.ecoEnchantCompatibility != null) {
|
if(DependencyManager.hasEcoItem) {
|
||||||
val result = EcoItemDependencyUtil.ecoItemNamespace(this)
|
val result = EcoItemDependencyUtil.ecoItemNamespace(this)
|
||||||
if(result != null) return result
|
if(result != null) return result
|
||||||
}
|
}
|
||||||
|
|
@ -43,7 +43,7 @@ object MaterialUtil {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
fun getMatFromKey(key: NamespacedKey): Material? {
|
fun getMatFromKey(key: NamespacedKey): Material? {
|
||||||
if(DependencyManager.ecoEnchantCompatibility != null) {
|
if(DependencyManager.hasEcoItem) {
|
||||||
val result = EcoItemDependencyUtil.ecoItemMaterialFromKey(key)
|
val result = EcoItemDependencyUtil.ecoItemMaterialFromKey(key)
|
||||||
if(result != null) return result
|
if(result != null) return result
|
||||||
}
|
}
|
||||||
|
|
@ -58,7 +58,7 @@ object MaterialUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun itemFromKey(key: NamespacedKey): ItemStack {
|
fun itemFromKey(key: NamespacedKey): ItemStack {
|
||||||
if(DependencyManager.ecoEnchantCompatibility != null) {
|
if(DependencyManager.hasEcoItem) {
|
||||||
val result = EcoItemDependencyUtil.newEcoItemstack(key)
|
val result = EcoItemDependencyUtil.newEcoItemstack(key)
|
||||||
if(result != null) return result
|
if(result != null) return result
|
||||||
}
|
}
|
||||||
|
|
@ -78,7 +78,7 @@ object MaterialUtil {
|
||||||
|
|
||||||
fun getMaterialCount(): Int {
|
fun getMaterialCount(): Int {
|
||||||
var count = Material.entries.size
|
var count = Material.entries.size
|
||||||
if(DependencyManager.ecoEnchantCompatibility != null) {
|
if(DependencyManager.hasEcoItem) {
|
||||||
count += EcoItemDependencyUtil.getItems().size
|
count += EcoItemDependencyUtil.getItems().size
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -92,7 +92,7 @@ object MaterialUtil {
|
||||||
|
|
||||||
fun getMaterials(): MutableList<NamespacedKey> {
|
fun getMaterials(): MutableList<NamespacedKey> {
|
||||||
val all = ArrayList(Material.entries.map { it.key })
|
val all = ArrayList(Material.entries.map { it.key })
|
||||||
if(DependencyManager.ecoEnchantCompatibility != null) {
|
if(DependencyManager.hasEcoItem) {
|
||||||
all.addAll(EcoItemDependencyUtil.getItems())
|
all.addAll(EcoItemDependencyUtil.getItems())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,7 @@ softdepend:
|
||||||
- Disenchantment
|
- Disenchantment
|
||||||
- EnchantsSquared
|
- EnchantsSquared
|
||||||
- EcoEnchants
|
- EcoEnchants
|
||||||
|
- EcoItems
|
||||||
- eco
|
- eco
|
||||||
- ExcellentEnchants
|
- ExcellentEnchants
|
||||||
- HavenBags
|
- HavenBags
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue