From a2f69a4ad89e18ee1775a62d90d6410f5158bdef Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Wed, 21 Jul 2021 09:32:48 +1000 Subject: [PATCH] SPIGOT-6369: Add ItemStack to HangingPlaceEvent By: DerFrZocker --- .../event/hanging/HangingPlaceEvent.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/paper-api/src/main/java/org/bukkit/event/hanging/HangingPlaceEvent.java b/paper-api/src/main/java/org/bukkit/event/hanging/HangingPlaceEvent.java index 959b9f3fb4..1bcff119ec 100644 --- a/paper-api/src/main/java/org/bukkit/event/hanging/HangingPlaceEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/hanging/HangingPlaceEvent.java @@ -6,6 +6,7 @@ import org.bukkit.entity.Hanging; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -18,12 +19,19 @@ public class HangingPlaceEvent extends HangingEvent implements Cancellable { private final Player player; private final Block block; private final BlockFace blockFace; + private final ItemStack itemStack; + @Deprecated public HangingPlaceEvent(@NotNull final Hanging hanging, @Nullable final Player player, @NotNull final Block block, @NotNull final BlockFace blockFace) { + this(hanging, player, block, blockFace, null); + } + + public HangingPlaceEvent(@NotNull final Hanging hanging, @Nullable final Player player, @NotNull final Block block, @NotNull final BlockFace blockFace, @Nullable ItemStack itemStack) { super(hanging); this.player = player; this.block = block; this.blockFace = blockFace; + this.itemStack = itemStack; } /** @@ -56,6 +64,16 @@ public class HangingPlaceEvent extends HangingEvent implements Cancellable { return blockFace; } + /** + * Gets the item from which the hanging entity originated + * + * @return the item from which the hanging entity originated + */ + @Nullable + public ItemStack getItemStack() { + return itemStack; + } + @Override public boolean isCancelled() { return cancelled;