Fixed oraxen integration
This commit is contained in:
@@ -2,33 +2,30 @@ package com.willfp.eco.internal.spigot.integrations.customitems
|
||||
|
||||
import com.willfp.eco.core.integrations.customitems.CustomItemsWrapper
|
||||
import com.willfp.eco.core.items.CustomItem
|
||||
import com.willfp.eco.core.items.Items
|
||||
import com.willfp.eco.core.items.TestableItem
|
||||
import com.willfp.eco.core.items.provider.ItemProvider
|
||||
import com.willfp.eco.util.NamespacedKeyUtils
|
||||
import io.th0rgal.oraxen.items.OraxenItems
|
||||
import org.bukkit.NamespacedKey
|
||||
import org.bukkit.inventory.ItemStack
|
||||
import java.util.Objects
|
||||
import java.util.function.Predicate
|
||||
|
||||
class CustomItemsOraxen : CustomItemsWrapper {
|
||||
override fun registerAllItems() {
|
||||
for (item in OraxenItems.getItems()) {
|
||||
val stack = item.build()
|
||||
val id: String = Objects.requireNonNullElse(OraxenItems.getIdByItem(item), "")
|
||||
if (id.isEmpty()) {
|
||||
continue
|
||||
}
|
||||
val key: NamespacedKey = NamespacedKeyUtils.create("oraxen", id.lowercase())
|
||||
CustomItem(
|
||||
key, Predicate { test: ItemStack ->
|
||||
val oraxenId: String = OraxenItems.getIdByItem(test) ?: return@Predicate false
|
||||
oraxenId.equals(id, ignoreCase = true)
|
||||
},
|
||||
stack
|
||||
).register()
|
||||
}
|
||||
Items.registerItemProvider(OraxenProvider())
|
||||
}
|
||||
|
||||
override fun getPluginName(): String {
|
||||
return "Oraxen"
|
||||
}
|
||||
}
|
||||
|
||||
private class OraxenProvider : ItemProvider("oraxen") {
|
||||
override fun provideForKey(id: String): TestableItem? {
|
||||
val item = OraxenItems.getItemById(id) ?: return null
|
||||
val key = NamespacedKeyUtils.create("oraxen", id)
|
||||
return CustomItem(
|
||||
key,
|
||||
{ id.equals(OraxenItems.getIdByItem(it), ignoreCase = true) },
|
||||
item.build()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user