Began spell cooldown recode

This commit is contained in:
Auxilor 2021-03-09 18:57:23 +00:00
parent 0134c919c3
commit 4b058ab73a
2 changed files with 69 additions and 0 deletions

View File

@ -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

View File

@ -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;
}
}