Skip to content

Commit

Permalink
Added AutocrafterPatch
Browse files Browse the repository at this point in the history
  • Loading branch information
WillFP committed Jul 20, 2024
1 parent 8a4243e commit 25d572c
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@file:Suppress("UnstableApiUsage")

package com.willfp.eco.internal.compat.modern.recipes

import com.willfp.eco.core.EcoPlugin
import com.willfp.eco.internal.recipes.AutocrafterPatch
import org.bukkit.event.EventHandler
import org.bukkit.event.block.CrafterCraftEvent

class AutocrafterPatchImpl: AutocrafterPatch {
@EventHandler
fun preventEcoRecipes(event: CrafterCraftEvent) {
if (!EcoPlugin.getPluginNames().contains(event.recipe.key.namespace)) {
return
}

event.isCancelled = true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.willfp.eco.internal.recipes

import com.willfp.eco.internal.compat.ModernCompatibilityProxy
import org.bukkit.event.Listener

@ModernCompatibilityProxy("recipes.AutocrafterPatchImpl")
interface AutocrafterPatch: Listener
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import com.willfp.eco.internal.particle.ParticleFactoryRGB
import com.willfp.eco.internal.price.PriceFactoryEconomy
import com.willfp.eco.internal.price.PriceFactoryXP
import com.willfp.eco.internal.price.PriceFactoryXPLevels
import com.willfp.eco.internal.recipes.AutocrafterPatch
import com.willfp.eco.internal.spigot.arrows.ArrowDataListener
import com.willfp.eco.internal.spigot.data.DataListener
import com.willfp.eco.internal.spigot.data.DataYml
Expand Down Expand Up @@ -433,6 +434,10 @@ abstract class EcoSpigotPlugin : EcoPlugin() {
listeners.add(NaturalExpGainListenersSpigot())
}

ifModern {
listeners += loadProxy<AutocrafterPatch>()
}

return listeners
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
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
Expand All @@ -17,6 +15,7 @@ class CraftingRecipeListener(val plugin: EcoPlugin) : Listener {
if (!EcoPlugin.getPluginNames().contains(event.recipe.namespace)) {
return
}

if (event.recipe.key.contains("_displayed")) {
event.isCancelled = true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ class WrappedCraftItemEvent(
event.result = Event.Result.DENY
event.isCancelled = true
}
}
}

0 comments on commit 25d572c

Please sign in to comment.