SPIGOT-6369: Add ItemStack to HangingPlaceEvent

By: DerFrZocker <derrieple@gmail.com>
This commit is contained in:
Bukkit/Spigot 2021-07-21 09:32:48 +10:00
parent 2e77f4180e
commit a2f69a4ad8

View File

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