From 93ce5cccd22179faf19f3bed87401b24bd249472 Mon Sep 17 00:00:00 2001 From: Auxilor Date: Mon, 5 Sep 2022 17:24:21 +0100 Subject: [PATCH] Fixed replenish --- .../ecoenchants/enchants/impl/EnchantmentReplenish.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 bdb662e9..bbdd3df2 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 @@ -2,6 +2,7 @@ package com.willfp.ecoenchants.enchants.impl import com.willfp.ecoenchants.EcoEnchantsPlugin import com.willfp.ecoenchants.enchants.EcoEnchant +import com.willfp.ecoenchants.target.EnchantLookup.hasEnchantActive import org.bukkit.Material import org.bukkit.block.data.Ageable import org.bukkit.event.EventHandler @@ -16,10 +17,11 @@ class EnchantmentReplenish( force = false ) { init { - this.registerListener(ReplenishHandler(plugin)) + this.registerListener(ReplenishHandler(this, plugin)) } private class ReplenishHandler( + private val enchant: EcoEnchant, private val plugin: EcoEnchantsPlugin ) : Listener { @EventHandler( @@ -27,6 +29,11 @@ class EnchantmentReplenish( ) fun handle(event: BlockBreakEvent) { val player = event.player + + if (!player.hasEnchantActive(enchant)) { + return + } + val block = event.block val type = block.type