call an event on beheading so other plugins can modify the dropped head

This commit is contained in:
2024-10-26 11:45:53 +02:00
parent 776359f355
commit ae1524ad6e
2 changed files with 70 additions and 7 deletions
@@ -0,0 +1,53 @@
package me.youhavetrouble.enchantio.events;
import org.bukkit.entity.Entity;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.event.entity.EntityEvent;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
/**
* Called when an entity is beheaded by a weapon with the Beheading enchantment.
*/
public class EntityBeheadEvent extends EntityEvent implements Cancellable {
private static final HandlerList HANDLERS = new HandlerList();
private ItemStack headToDrop;
private boolean cancelled = false;
public EntityBeheadEvent(@NotNull Entity entity, @NotNull ItemStack headToDrop) {
super(entity);
this.headToDrop = headToDrop;
}
public @NotNull ItemStack getHeadToDrop() {
return headToDrop;
}
public void setHeadToDrop(@NotNull ItemStack headToDrop) {
this.headToDrop = headToDrop;
}
@Override
public boolean isCancelled() {
return cancelled;
}
@Override
public void setCancelled(boolean cancel) {
this.cancelled = cancel;
}
@Override
public @NotNull HandlerList getHandlers() {
return HANDLERS;
}
@NotNull
public static HandlerList getHandlerList() {
return HANDLERS;
}
}