mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 08:14:00 +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
|
|
@ -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"))
|
||||
|
|
|
|||
|
|
@ -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