diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/EcoSpigotPlugin.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/EcoSpigotPlugin.kt index 3dd1ef79..a0a18201 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/EcoSpigotPlugin.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/EcoSpigotPlugin.kt @@ -390,7 +390,7 @@ abstract class EcoSpigotPlugin : EcoPlugin() { val listeners = mutableListOf( ArmorListener(), EntityDeathByEntityListeners(this), - CraftingRecipeListener(), + CraftingRecipeListener(this), StackedRecipeListener(this), GUIListener(this), ArrowDataListener(this), diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/recipes/CraftingRecipeListener.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/recipes/CraftingRecipeListener.kt index b26634b0..a04e2d14 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/recipes/CraftingRecipeListener.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/recipes/CraftingRecipeListener.kt @@ -1,15 +1,17 @@ package com.willfp.eco.internal.spigot.recipes +import com.willfp.eco.core.Eco import com.willfp.eco.core.EcoPlugin import com.willfp.eco.core.recipe.Recipes import org.bukkit.Keyed +import org.bukkit.entity.Player import org.bukkit.event.EventHandler import org.bukkit.event.Listener import org.bukkit.event.inventory.CraftItemEvent import org.bukkit.event.inventory.PrepareItemCraftEvent import org.bukkit.event.player.PlayerRecipeDiscoverEvent -class CraftingRecipeListener : Listener { +class CraftingRecipeListener(val plugin: EcoPlugin) : Listener { @EventHandler fun preventLearningDisplayedRecipes(event: PlayerRecipeDiscoverEvent) { if (!EcoPlugin.getPluginNames().contains(event.recipe.namespace)) { @@ -22,6 +24,16 @@ class CraftingRecipeListener : Listener { @EventHandler fun processListeners(event: PrepareItemCraftEvent) { + handlePrepare(event) + + if (plugin.configYml.getBool("enforce-preparing-recipes")) { + plugin.scheduler.runLater(1) { + handlePrepare(event) + } + } + } + + private fun handlePrepare(event: PrepareItemCraftEvent) { var recipe = event.recipe as? Keyed if (recipe == null) { diff --git a/eco-core/core-plugin/src/main/resources/config.yml b/eco-core/core-plugin/src/main/resources/config.yml index 716ad988..defc125a 100644 --- a/eco-core/core-plugin/src/main/resources/config.yml +++ b/eco-core/core-plugin/src/main/resources/config.yml @@ -97,3 +97,8 @@ math-cache-ttl: 200 # counts. This is completely anonymous and no personal information is logged. This data # is primarily used for optimisation and server insights. playerflow: true + +# If eco should make sure its recipes are not affected by other plugins on PrepareCraftItemEvent +# Turn this on if you use ItemsAdder/Oraxen/Other 3d party plugins custom items in eco recipes +# And having issues with the item being invisible when you are trying to craft ir. +enforce-preparing-recipes: false