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 01eec4c6..79fa4ce6 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 @@ -15,6 +15,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.block.Action; import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.BlockInventoryHolder; import org.bukkit.util.NumberConversions; import org.jetbrains.annotations.NotNull; @@ -124,6 +125,7 @@ public abstract class Spell extends EcoEnchant { if (event.getClickedBlock() != null) { if (event.getClickedBlock().getState() instanceof Container + || event.getClickedBlock().getState() instanceof BlockInventoryHolder || event.getClickedBlock().getType() == Material.CRAFTING_TABLE || event.getClickedBlock().getType() == Material.GRINDSTONE || event.getClickedBlock().getType() == Material.ENCHANTING_TABLE diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/SpellActivateEvent.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/SpellActivateEvent.java new file mode 100644 index 00000000..6b115d7f --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/SpellActivateEvent.java @@ -0,0 +1,67 @@ +package com.willfp.ecoenchants.enchantments.util; + +import com.willfp.ecoenchants.enchantments.itemtypes.Spell; +import lombok.Getter; +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; +import org.jetbrains.annotations.NotNull; + +public class SpellActivateEvent extends PlayerEvent implements Cancellable { + /** + * Internal, for bukkit. + */ + private static final HandlerList HANDLERS = new HandlerList(); + + /** + * The spell that was activated. + */ + @Getter + private final Spell spell; + + /** + * If the spell activation was cancelled. + */ + private boolean cancelled; + + /** + * Create new SpellActivateEvent. + * + * @param player The player. + * @param spell The spell. + */ + public SpellActivateEvent(@NotNull final Player player, + @NotNull final Spell spell) { + super(player); + + this.spell = spell; + this.cancelled = false; + } + + + @Override + public boolean isCancelled() { + return cancelled; + } + + @Override + public void setCancelled(final boolean cancel) { + this.cancelled = cancel; + } + + @NotNull + @Override + public HandlerList getHandlers() { + return HANDLERS; + } + + /** + * Bukkit parity. + * + * @return The handler list. + */ + public static HandlerList getHandlerList() { + return HANDLERS; + } +}