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 b9ddf3af..67cae70e 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 @@ -7,6 +7,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; import com.willfp.ecoenchants.enchantments.util.EnchantChecks; import com.willfp.ecoenchants.enchantments.util.SpellActivateEvent; +import com.willfp.ecoenchants.enchantments.util.SpellCancellationInterrupt; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.Sound; @@ -146,7 +147,11 @@ public abstract class Spell extends EcoEnchant { player.sendMessage(message); player.playSound(player.getLocation(), this.getActivationSound(), SoundCategory.PLAYERS, 1, 1); - onUse(player, level, event); + try { + onUse(player, level, event); + } catch (SpellCancellationInterrupt ignored) { + // Do nothing + } } } } @@ -169,7 +174,7 @@ public abstract class Spell extends EcoEnchant { */ public abstract void onUse(@NotNull Player player, int level, - @NotNull PlayerInteractEvent event); + @NotNull PlayerInteractEvent event) throws SpellCancellationInterrupt; /** * Utility method to get a player's cooldown time of a specific spell. diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/SpellCancellationInterrupt.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/SpellCancellationInterrupt.java new file mode 100644 index 00000000..ef6866f5 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/SpellCancellationInterrupt.java @@ -0,0 +1,8 @@ +package com.willfp.ecoenchants.enchantments.util; + +/** + * Exception to cancel spells (janky). + */ +public class SpellCancellationInterrupt extends Exception { + +}