From 0a95a8dba5d79e7b529e40c739334189e862d4ea Mon Sep 17 00:00:00 2001 From: Auxilor Date: Thu, 4 Feb 2021 21:40:08 +0000 Subject: [PATCH] Fixed dyamite triggering on air click --- .../enchantments/ecoenchants/spell/Dynamite.java | 5 +++++ .../ecoenchants/enchantments/itemtypes/Spell.java | 15 +++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Dynamite.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Dynamite.java index 31397ad7..38187432 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Dynamite.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Dynamite.java @@ -81,4 +81,9 @@ public class Dynamite extends Spell { AnticheatManager.unexemptPlayer(player); } + + @Override + protected boolean requiresBlockClick() { + return true; + } } 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 c3e788e0..01eec4c6 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 @@ -92,10 +92,16 @@ public abstract class Spell extends EcoEnchant { if (!(event.getAction().equals(Action.LEFT_CLICK_AIR) || event.getAction().equals(Action.LEFT_CLICK_BLOCK))) { return; } + if (requiresBlockClick() && !event.getAction().equals(Action.LEFT_CLICK_BLOCK)) { + return; + } } else { if (!(event.getAction().equals(Action.RIGHT_CLICK_AIR) || event.getAction().equals(Action.RIGHT_CLICK_BLOCK))) { return; } + if (requiresBlockClick() && !event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) { + return; + } } if (!EnchantChecks.mainhand(player, this)) { @@ -140,6 +146,15 @@ public abstract class Spell extends EcoEnchant { runnable.run(); } + /** + * Get if the spell requires a block to be clicked to trigger the spell. + * + * @return If the spell requires a block to be clicked. + */ + protected boolean requiresBlockClick() { + return false; + } + /** * Actual spell-specific implementations; the functionality. *