clone use item adder on custom items adder item

This commit is contained in:
alexcrea 2026-04-12 11:12:38 +02:00
parent 638df714fd
commit e00c5e8b47
Signed by: alexcrea
GPG key ID: E346CD16413450E3
3 changed files with 30 additions and 9 deletions

View file

@ -37,6 +37,9 @@ repositories {
// ExcellentEnchants
maven(url = "https://repo.nightexpressdev.com/releases")
// ItemsAdder
maven(url = "https://maven.devs.beer/")
// for fast stats
maven {
name = "thenextlvlReleases"
@ -97,6 +100,9 @@ dependencies {
// SuperEnchants
compileOnly(files("libs/SuperEnchants-4.6.2-all.jar"))
// ItemsAdder API
compileOnly("dev.lone:api-itemsadder:4.0.10")
// Include nms
implementation(project(":nms:nms-common"))
implementation(project(":nms:nms-paper"))

View file

@ -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?> {

View file

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