From b6c3aecf03cc92c9188890254c2ded07166a23a6 Mon Sep 17 00:00:00 2001 From: Auxilor Date: Fri, 20 Nov 2020 18:17:10 +0000 Subject: [PATCH] Fixed left-click spell detection --- .../enchantments/itemtypes/Spell.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/itemtypes/Spell.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/itemtypes/Spell.java index 185733a0..980102ac 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/itemtypes/Spell.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/itemtypes/Spell.java @@ -56,19 +56,20 @@ public abstract class Spell extends EcoEnchant { public void onUseEventHandler(PlayerInteractEvent event) { Player player = event.getPlayer(); - if(!leftClickItems.contains(player.getInventory().getItemInMainHand().getType())) { - if(!(event.getAction().equals(Action.RIGHT_CLICK_AIR) || event.getAction().equals(Action.RIGHT_CLICK_BLOCK))) - return; - } else { - if(!(event.getAction().equals(Action.LEFT_CLICK_AIR) || event.getAction().equals(Action.LEFT_CLICK_BLOCK))) - return; - } - if(runningSpell.contains(player.getUniqueId())) return; - runningSpell.add(player.getUniqueId()); Bukkit.getScheduler().runTaskLater(EcoEnchantsPlugin.getInstance(), () -> runningSpell.remove(player.getUniqueId()), 5); + if(leftClickItems.contains(player.getInventory().getItemInMainHand().getType())) { + if(!(event.getAction().equals(Action.LEFT_CLICK_AIR) || 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(!EnchantChecks.mainhand(player, this)) return;