Prevented spells activating on block click

This commit is contained in:
Auxilor 2021-01-08 17:14:42 +00:00
parent 1559cb5c05
commit c7c949f990

View File

@ -11,6 +11,7 @@ import com.willfp.ecoenchants.enchantments.util.SpellRunnable;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.SoundCategory;
import org.bukkit.block.Container;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action;
@ -116,6 +117,17 @@ public abstract class Spell extends EcoEnchant {
int cooldown = getCooldown(this, player);
if (event.getClickedBlock() != null) {
if (event.getClickedBlock().getState() instanceof Container
|| event.getClickedBlock().getType() == Material.CRAFTING_TABLE
|| event.getClickedBlock().getType() == Material.GRINDSTONE
|| event.getClickedBlock().getType() == Material.ENCHANTING_TABLE
|| event.getClickedBlock().getType() == Material.ANVIL
|| event.getClickedBlock().getType() == Material.FURNACE) {
return;
}
}
if (cooldown > 0) {
String message = Configs.LANG.getMessage("on-cooldown").replace("%seconds%", String.valueOf(cooldown)).replace("%name%", EnchantmentCache.getEntry(this).getRawName());
player.sendMessage(message);