From d54c499cf562f7f3a41fba2378f17ebcd98e3862 Mon Sep 17 00:00:00 2001 From: Auxilor Date: Tue, 6 Apr 2021 00:22:54 +0100 Subject: [PATCH] Fixed players in spectator mode being able to use spells --- .../com/willfp/ecoenchants/enchantments/itemtypes/Spell.java | 5 +++++ 1 file changed, 5 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 39489bd2..7108b63f 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.meta.EnchantmentType; import com.willfp.ecoenchants.enchantments.util.EnchantChecks; import com.willfp.ecoenchants.enchantments.util.SpellActivateEvent; import org.bukkit.Bukkit; +import org.bukkit.GameMode; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.SoundCategory; @@ -147,6 +148,10 @@ public abstract class Spell extends EcoEnchant { preventDuplicateList.add(player.getUniqueId()); this.getPlugin().getScheduler().runLater(() -> preventDuplicateList.remove(player.getUniqueId()), 5); + if (player.getGameMode() == GameMode.SPECTATOR) { + return; + } + if (LEFT_CLICK_ITEMS.contains(player.getInventory().getItemInMainHand().getType())) { if (!(event.getAction().equals(Action.LEFT_CLICK_AIR) || event.getAction().equals(Action.LEFT_CLICK_BLOCK))) { return;