mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 16:16:17 +02:00
item adder namespace considered for unit merge
This commit is contained in:
parent
e00c5e8b47
commit
459e3351fd
3 changed files with 33 additions and 4 deletions
|
|
@ -1,6 +1,5 @@
|
|||
package xyz.alexcrea.cuanvil.enchant.wrapped;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import su.nightexpress.excellentenchants.api.enchantment.CustomEnchantment;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package xyz.alexcrea.cuanvil.dependency.plugins
|
|||
|
||||
import dev.lone.itemsadder.api.CustomStack
|
||||
import dev.lone.itemsadder.api.ItemsAdder
|
||||
import io.delilaheve.CustomAnvil
|
||||
import org.bukkit.NamespacedKey
|
||||
import org.bukkit.inventory.ItemStack
|
||||
import org.bukkit.plugin.Plugin
|
||||
|
||||
|
|
@ -20,8 +20,19 @@ class ItemsAdderDependency(plugin: Plugin) : GenericPluginDependency(plugin) {
|
|||
if(!isLoaded) return null
|
||||
val customItem = CustomStack.byItemStack(item) ?: return null
|
||||
|
||||
CustomAnvil.instance.logger.warning("testing equal: ${customItem.itemStack == item}")
|
||||
return customItem.itemStack
|
||||
return CustomStack.getInstance(customItem.namespacedID)?.itemStack
|
||||
}
|
||||
|
||||
fun fromKey(key: NamespacedKey): ItemStack? {
|
||||
if(!isLoaded) return null
|
||||
return CustomStack.getInstance(key.toString())?.itemStack
|
||||
}
|
||||
|
||||
fun getKey(item: ItemStack) : NamespacedKey? {
|
||||
if(!isLoaded) return null
|
||||
val customItem = CustomStack.byItemStack(item) ?: return null
|
||||
|
||||
return NamespacedKey.fromString(customItem.namespacedID)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import org.bukkit.Bukkit
|
|||
import org.bukkit.Material
|
||||
import org.bukkit.NamespacedKey
|
||||
import org.bukkit.inventory.ItemStack
|
||||
import xyz.alexcrea.cuanvil.dependency.DependencyManager
|
||||
import xyz.alexcrea.cuanvil.dependency.plugins.EcoItemDependencyUtil
|
||||
|
||||
object MaterialUtil {
|
||||
|
|
@ -27,6 +28,12 @@ object MaterialUtil {
|
|||
if(result != null) return result
|
||||
}
|
||||
|
||||
val itemAdder = DependencyManager.itemsAdderCompatibility
|
||||
if(itemAdder != null) {
|
||||
val result = itemAdder.getKey(this)
|
||||
if (result != null) return result
|
||||
}
|
||||
|
||||
return this.type.key
|
||||
}
|
||||
|
||||
|
|
@ -41,6 +48,12 @@ object MaterialUtil {
|
|||
if(result != null) return result
|
||||
}
|
||||
|
||||
val itemAdder = DependencyManager.itemsAdderCompatibility
|
||||
if(itemAdder != null) {
|
||||
val result = itemAdder.fromKey(key)
|
||||
if (result != null) return result.type
|
||||
}
|
||||
|
||||
return bukkitMaterialFromKey(key)
|
||||
}
|
||||
|
||||
|
|
@ -50,6 +63,12 @@ object MaterialUtil {
|
|||
if(result != null) return result
|
||||
}
|
||||
|
||||
val itemAdder = DependencyManager.itemsAdderCompatibility
|
||||
if(itemAdder != null) {
|
||||
val result = itemAdder.fromKey(key)
|
||||
if (result != null) return result
|
||||
}
|
||||
|
||||
return ItemStack(bukkitMaterialFromKey(key)!!)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue