proper eco item check

This commit is contained in:
alexcrea 2026-08-12 07:24:21 +02:00
parent 82b41fb1c1
commit 685e046063
Signed by: alexcrea
GPG key ID: E59DF23EE2A2266C
3 changed files with 11 additions and 5 deletions

View file

@ -46,6 +46,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
@ -82,6 +83,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")) {

View file

@ -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())
} }

View file

@ -80,6 +80,7 @@ softdepend:
- Disenchantment - Disenchantment
- EnchantsSquared - EnchantsSquared
- EcoEnchants - EcoEnchants
- EcoItems
- eco - eco
- ExcellentEnchants - ExcellentEnchants
- HavenBags - HavenBags