From c7c949f990af2036f7871f320d465d17dd70803a Mon Sep 17 00:00:00 2001 From: Auxilor Date: Fri, 8 Jan 2021 17:14:42 +0000 Subject: [PATCH] Prevented spells activating on block click --- .../ecoenchants/enchantments/itemtypes/Spell.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/itemtypes/Spell.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/itemtypes/Spell.java index 8b88a744..f33062c2 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/itemtypes/Spell.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/itemtypes/Spell.java @@ -11,6 +11,7 @@ import com.willfp.ecoenchants.enchantments.util.SpellRunnable; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.SoundCategory; +import org.bukkit.block.Container; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.block.Action; @@ -116,6 +117,17 @@ public abstract class Spell extends EcoEnchant { int cooldown = getCooldown(this, player); + if (event.getClickedBlock() != null) { + if (event.getClickedBlock().getState() instanceof Container + || event.getClickedBlock().getType() == Material.CRAFTING_TABLE + || event.getClickedBlock().getType() == Material.GRINDSTONE + || event.getClickedBlock().getType() == Material.ENCHANTING_TABLE + || event.getClickedBlock().getType() == Material.ANVIL + || event.getClickedBlock().getType() == Material.FURNACE) { + return; + } + } + if (cooldown > 0) { String message = Configs.LANG.getMessage("on-cooldown").replace("%seconds%", String.valueOf(cooldown)).replace("%name%", EnchantmentCache.getEntry(this).getRawName()); player.sendMessage(message);