Added a config option to enforce additional crafting recipe check (in case you're encountering issues with 3d party custom item plugins like ItemsAdder or Oraxen)

This commit is contained in:
_OfTeN_
2023-07-30 20:38:09 +03:00
parent 5c267d500a
commit d3c831c19b
3 changed files with 19 additions and 2 deletions

View File

@@ -390,7 +390,7 @@ abstract class EcoSpigotPlugin : EcoPlugin() {
val listeners = mutableListOf(
ArmorListener(),
EntityDeathByEntityListeners(this),
CraftingRecipeListener(),
CraftingRecipeListener(this),
StackedRecipeListener(this),
GUIListener(this),
ArrowDataListener(this),

View File

@@ -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) {

View File

@@ -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