mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 16:16:17 +02:00
clone use item adder on custom items adder item
This commit is contained in:
parent
638df714fd
commit
e00c5e8b47
3 changed files with 30 additions and 9 deletions
|
|
@ -303,10 +303,10 @@ object DependencyManager {
|
|||
}
|
||||
|
||||
private fun unsafeCloneItem(item: ItemStack): ItemStack {
|
||||
var cloned: ItemStack? = null
|
||||
val cloned = itemsAdderCompatibility?.tryClone(item)
|
||||
if(cloned != null) return cloned
|
||||
|
||||
if(cloned == null) cloned = item.clone()
|
||||
return cloned
|
||||
return item.clone()
|
||||
}
|
||||
|
||||
fun stripLore(item: ItemStack): MutableList<Component?> {
|
||||
|
|
|
|||
|
|
@ -1,12 +1,27 @@
|
|||
package xyz.alexcrea.cuanvil.dependency.plugins;
|
||||
package xyz.alexcrea.cuanvil.dependency.plugins
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import dev.lone.itemsadder.api.CustomStack
|
||||
import dev.lone.itemsadder.api.ItemsAdder
|
||||
import io.delilaheve.CustomAnvil
|
||||
import org.bukkit.inventory.ItemStack
|
||||
import org.bukkit.plugin.Plugin
|
||||
|
||||
public class ItemsAdderDependency extends GenericPluginDependency{
|
||||
class ItemsAdderDependency(plugin: Plugin) : GenericPluginDependency(plugin) {
|
||||
var isLoaded: Boolean = false
|
||||
get() {
|
||||
if (field) return true
|
||||
|
||||
public ItemsAdderDependency(@NotNull Plugin plugin) {
|
||||
super(plugin);
|
||||
// We can't be sure the event is registered before being triggered so we need to use this function
|
||||
field = ItemsAdder.areItemsLoaded()
|
||||
return field
|
||||
}
|
||||
|
||||
fun tryClone(item: ItemStack): ItemStack? {
|
||||
if(!isLoaded) return null
|
||||
val customItem = CustomStack.byItemStack(item) ?: return null
|
||||
|
||||
CustomAnvil.instance.logger.warning("testing equal: ${customItem.itemStack == item}")
|
||||
return customItem.itemStack
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue