From 01b8968e4b4adce6343962b467b07810ec3b225a Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Sat, 2 May 2020 17:48:02 +1000 Subject: [PATCH] #495: Expose ItemStack and hand used in PlayerShearEntityEvent By: Parker Hawke --- .../event/player/PlayerShearEntityEvent.java | 35 +++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerShearEntityEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerShearEntityEvent.java index 93429c5339..04b3dce008 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerShearEntityEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerShearEntityEvent.java @@ -1,9 +1,12 @@ package org.bukkit.event.player; +import org.bukkit.Material; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.bukkit.inventory.EquipmentSlot; +import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; /** @@ -13,11 +16,19 @@ public class PlayerShearEntityEvent extends PlayerEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); private boolean cancel; private final Entity what; + private final ItemStack item; + private final EquipmentSlot hand; - public PlayerShearEntityEvent(@NotNull final Player who, @NotNull final Entity what) { + public PlayerShearEntityEvent(@NotNull Player who, @NotNull Entity what, @NotNull ItemStack item, @NotNull EquipmentSlot hand) { super(who); - this.cancel = false; this.what = what; + this.item = item; + this.hand = hand; + } + + @Deprecated + public PlayerShearEntityEvent(@NotNull final Player who, @NotNull final Entity what) { + this(who, what, new ItemStack(Material.SHEARS), EquipmentSlot.HAND); } @Override @@ -40,6 +51,26 @@ public class PlayerShearEntityEvent extends PlayerEvent implements Cancellable { return what; } + /** + * Gets the item used to shear the entity. + * + * @return the shears + */ + @NotNull + public ItemStack getItem() { + return item.clone(); + } + + /** + * Gets the hand used to shear the entity. + * + * @return the hand + */ + @NotNull + public EquipmentSlot getHand() { + return hand; + } + @NotNull @Override public HandlerList getHandlers() {