Add BlockShearEntityEvent for Dispensers shearing Sheep

By: nathat890 <nathat890@outlook.com>
This commit is contained in:
Bukkit/Spigot 2019-05-07 16:46:20 +01:00
parent 7285d5d822
commit a3e5b8bdf0

View file

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