diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockShearEntityEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockShearEntityEvent.java new file mode 100644 index 0000000000..71c0af9373 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockShearEntityEvent.java @@ -0,0 +1,67 @@ +package org.bukkit.event.block; + +import org.bukkit.block.Block; +import org.bukkit.entity.Entity; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; + +/** + * Event fired when a dispenser shears a nearby sheep. + */ +public class BlockShearEntityEvent extends BlockEvent implements Cancellable { + + private static final HandlerList handlers = new HandlerList(); + // + private final Entity sheared; + private final ItemStack tool; + private boolean cancelled; + + public BlockShearEntityEvent(@NotNull Block dispenser, @NotNull Entity sheared, @NotNull ItemStack tool) { + super(dispenser); + this.sheared = sheared; + this.tool = tool; + } + + /** + * Gets the entity that was sheared. + * + * @return the entity that was sheared. + */ + @NotNull + public Entity getEntity() { + return sheared; + } + + /** + * Gets the item used to shear this sheep. + * + * @return the item used to shear this sheep. + */ + @NotNull + public ItemStack getTool() { + return tool.clone(); + } + + @Override + public boolean isCancelled() { + return cancelled; + } + + @Override + public void setCancelled(boolean cancelled) { + this.cancelled = cancelled; + } + + @NotNull + @Override + public HandlerList getHandlers() { + return handlers; + } + + @NotNull + public static HandlerList getHandlerList() { + return handlers; + } +}