Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ allprojects {
// Nexo
maven("https://repo.nexomc.com/releases")

// CraftEngine
maven("https://repo.momirealms.net/releases/")

// CoinsEngine
maven("https://repo.nightexpressdev.com/releases")
}
Expand Down
2 changes: 2 additions & 0 deletions eco-core/core-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ dependencies {
})
compileOnly("com.github.LoneDev6:API-ItemsAdder:2.4.7")
compileOnly("com.nexomc:nexo:1.10.0")
compileOnly("net.momirealms:craft-engine-core:0.0.66")
compileOnly("net.momirealms:craft-engine-bukkit:0.0.66")
compileOnly("com.arcaniax:HeadDatabase-API:1.3.1")
compileOnly("com.gmail.filoghost.holographicdisplays:holographicdisplays-api:2.4.0")
compileOnly("net.essentialsx:EssentialsX:2.21.2", {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ import com.willfp.eco.internal.spigot.integrations.antigrief.AntigriefSuperiorSk
import com.willfp.eco.internal.spigot.integrations.antigrief.AntigriefTowny
import com.willfp.eco.internal.spigot.integrations.antigrief.AntigriefWorldGuard
import com.willfp.eco.internal.spigot.integrations.customentities.CustomEntitiesMythicMobs
import com.willfp.eco.internal.spigot.integrations.customitems.CustomItemsCraftEngine
import com.willfp.eco.internal.spigot.integrations.customitems.CustomItemsCustomCrafting
import com.willfp.eco.internal.spigot.integrations.customitems.CustomItemsDenizen
import com.willfp.eco.internal.spigot.integrations.customitems.CustomItemsExecutableItems
Expand Down Expand Up @@ -361,6 +362,7 @@ abstract class EcoSpigotPlugin : EcoPlugin() {
IntegrationLoader("Oraxen") { CustomItemsManager.register(CustomItemsOraxen(this)) },
IntegrationLoader("Nexo") { CustomItemsManager.register(CustomItemsNexo(this)) },
IntegrationLoader("ItemsAdder") { CustomItemsManager.register(CustomItemsItemsAdder()) },
IntegrationLoader("CraftEngine") { CustomItemsManager.register(CustomItemsCraftEngine(this)) },
IntegrationLoader("HeadDatabase") { CustomItemsManager.register(CustomItemsHeadDatabase(this)) },
IntegrationLoader("ExecutableItems") { CustomItemsManager.register(CustomItemsExecutableItems()) },
IntegrationLoader("CustomCrafting") {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package com.willfp.eco.internal.spigot.integrations.customitems

import com.willfp.eco.core.EcoPlugin
import com.willfp.eco.core.integrations.customitems.CustomItemsIntegration
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 net.momirealms.craftengine.bukkit.api.CraftEngineItems
import net.momirealms.craftengine.bukkit.api.event.CraftEngineReloadEvent
import net.momirealms.craftengine.core.util.Key
import org.bukkit.event.EventHandler
import org.bukkit.event.Listener
import org.bukkit.inventory.ItemStack
import java.util.function.Predicate

class CustomItemsCraftEngine(
private val plugin: EcoPlugin
) : CustomItemsIntegration, Listener {
override fun registerProvider() {
plugin.eventManager.registerListener(this)
}

override fun getPluginName(): String {
return "CraftEngine"
}

@EventHandler
@Suppress("UNUSED_PARAMETER")
fun onItemRegister(event: CraftEngineReloadEvent) {
Items.registerItemProvider(CraftEngineProvider())
}

private class CraftEngineProvider : ItemProvider("craftengine") {
override fun provideForKey(key: String): TestableItem? {
val split = key.split(":").toMutableList()

if (split.size < 2) {
return null
}

val namespace = split[0]
val value = split[1]

val id = Key.of(namespace, value)
val item = CraftEngineItems.byId(id) ?: return null
val namespacedKey = NamespacedKeyUtils.create("craftengine", key.lowercase().replace(":", "__"))
val stack = item.buildItemStack()

return CustomItem(
namespacedKey,
Predicate { test: ItemStack ->
val customStack = CraftEngineItems.byItemStack(test) ?: return@Predicate false
customStack.id().equals(id)
},
stack
)
}

}
}
1 change: 1 addition & 0 deletions eco-core/core-plugin/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,5 @@ softdepend:
- Denizen
- RoyaleEconomy
- FancyHolograms
- CraftEngine
- CoinsEngine
Loading