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
|
|
@ -37,6 +37,9 @@ repositories {
|
||||||
// ExcellentEnchants
|
// ExcellentEnchants
|
||||||
maven(url = "https://repo.nightexpressdev.com/releases")
|
maven(url = "https://repo.nightexpressdev.com/releases")
|
||||||
|
|
||||||
|
// ItemsAdder
|
||||||
|
maven(url = "https://maven.devs.beer/")
|
||||||
|
|
||||||
// for fast stats
|
// for fast stats
|
||||||
maven {
|
maven {
|
||||||
name = "thenextlvlReleases"
|
name = "thenextlvlReleases"
|
||||||
|
|
@ -97,6 +100,9 @@ dependencies {
|
||||||
// SuperEnchants
|
// SuperEnchants
|
||||||
compileOnly(files("libs/SuperEnchants-4.6.2-all.jar"))
|
compileOnly(files("libs/SuperEnchants-4.6.2-all.jar"))
|
||||||
|
|
||||||
|
// ItemsAdder API
|
||||||
|
compileOnly("dev.lone:api-itemsadder:4.0.10")
|
||||||
|
|
||||||
// Include nms
|
// Include nms
|
||||||
implementation(project(":nms:nms-common"))
|
implementation(project(":nms:nms-common"))
|
||||||
implementation(project(":nms:nms-paper"))
|
implementation(project(":nms:nms-paper"))
|
||||||
|
|
|
||||||
|
|
@ -303,10 +303,10 @@ object DependencyManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun unsafeCloneItem(item: ItemStack): ItemStack {
|
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 item.clone()
|
||||||
return cloned
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun stripLore(item: ItemStack): MutableList<Component?> {
|
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 dev.lone.itemsadder.api.CustomStack
|
||||||
import org.jetbrains.annotations.NotNull;
|
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) {
|
// We can't be sure the event is registered before being triggered so we need to use this function
|
||||||
super(plugin);
|
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