From f20aef3dec9c77eea6c2be97cb4b6e2f04ba561f Mon Sep 17 00:00:00 2001 From: Auxilor Date: Sun, 9 Oct 2022 17:53:56 +0100 Subject: [PATCH] Added consume-seeds to replenish --- .../enchants/impl/EnchantmentReplenish.kt | 15 +++++++++++++++ .../src/main/resources/enchants/replenish.yml | 1 + 2 files changed, 16 insertions(+) diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/impl/EnchantmentReplenish.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/impl/EnchantmentReplenish.kt index 22b842a2..ebe809e2 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/impl/EnchantmentReplenish.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/impl/EnchantmentReplenish.kt @@ -8,6 +8,7 @@ import org.bukkit.block.data.Ageable import org.bukkit.event.EventHandler import org.bukkit.event.Listener import org.bukkit.event.block.BlockBreakEvent +import org.bukkit.inventory.ItemStack class EnchantmentReplenish( plugin: EcoEnchantsPlugin @@ -55,6 +56,20 @@ class EnchantmentReplenish( return } + if (enchant.config.getBool("consume-seeds")) { + val item = ItemStack( + if (type == Material.WHEAT) { + Material.WHEAT_SEEDS + } else type + ) + + val hasSeeds = player.inventory.removeItem(item).isEmpty() + + if (!hasSeeds) { + return + } + } + if (data.age != data.maximumAge) { event.isDropItems = false event.expToDrop = 0 diff --git a/eco-core/core-plugin/src/main/resources/enchants/replenish.yml b/eco-core/core-plugin/src/main/resources/enchants/replenish.yml index be3531dc..c54d5174 100644 --- a/eco-core/core-plugin/src/main/resources/enchants/replenish.yml +++ b/eco-core/core-plugin/src/main/resources/enchants/replenish.yml @@ -14,3 +14,4 @@ enchantable: true conditions: [ ] +consume-seeds: true # If seeds should be consumed in replanting