mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2024-12-27 20:37:34 +01:00
Added janky way to cancel spells
This commit is contained in:
parent
4b107da65b
commit
d970ce08f9
@ -7,6 +7,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
|||||||
import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
|
import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
|
||||||
import com.willfp.ecoenchants.enchantments.util.EnchantChecks;
|
import com.willfp.ecoenchants.enchantments.util.EnchantChecks;
|
||||||
import com.willfp.ecoenchants.enchantments.util.SpellActivateEvent;
|
import com.willfp.ecoenchants.enchantments.util.SpellActivateEvent;
|
||||||
|
import com.willfp.ecoenchants.enchantments.util.SpellCancellationInterrupt;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
@ -146,7 +147,11 @@ public abstract class Spell extends EcoEnchant {
|
|||||||
player.sendMessage(message);
|
player.sendMessage(message);
|
||||||
player.playSound(player.getLocation(), this.getActivationSound(), SoundCategory.PLAYERS, 1, 1);
|
player.playSound(player.getLocation(), this.getActivationSound(), SoundCategory.PLAYERS, 1, 1);
|
||||||
|
|
||||||
|
try {
|
||||||
onUse(player, level, event);
|
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,
|
public abstract void onUse(@NotNull Player player,
|
||||||
int level,
|
int level,
|
||||||
@NotNull PlayerInteractEvent event);
|
@NotNull PlayerInteractEvent event) throws SpellCancellationInterrupt;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility method to get a player's cooldown time of a specific spell.
|
* Utility method to get a player's cooldown time of a specific spell.
|
||||||
|
@ -0,0 +1,8 @@
|
|||||||
|
package com.willfp.ecoenchants.enchantments.util;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exception to cancel spells (janky).
|
||||||
|
*/
|
||||||
|
public class SpellCancellationInterrupt extends Exception {
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user