From 80f20528ed6c2dcffd0442e32a62f27279b078ea Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Fri, 23 Aug 2019 20:30:10 +1000 Subject: [PATCH] SPIGOT-5282: Improve bucket event API By: md_5 --- .../event/player/PlayerBucketEmptyEvent.java | 5 +++++ .../bukkit/event/player/PlayerBucketEvent.java | 17 +++++++++++++++++ .../event/player/PlayerBucketFillEvent.java | 5 +++++ 3 files changed, 27 insertions(+) diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerBucketEmptyEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerBucketEmptyEvent.java index cdf2e2016b..7f225baa9f 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerBucketEmptyEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerBucketEmptyEvent.java @@ -14,10 +14,15 @@ import org.jetbrains.annotations.NotNull; public class PlayerBucketEmptyEvent extends PlayerBucketEvent { private static final HandlerList handlers = new HandlerList(); + @Deprecated public PlayerBucketEmptyEvent(@NotNull final Player who, @NotNull final Block blockClicked, @NotNull final BlockFace blockFace, @NotNull final Material bucket, @NotNull final ItemStack itemInHand) { super(who, blockClicked, blockFace, bucket, itemInHand); } + public PlayerBucketEmptyEvent(@NotNull final Player who, @NotNull final Block block, @NotNull final Block blockClicked, @NotNull final BlockFace blockFace, @NotNull final Material bucket, @NotNull final ItemStack itemInHand) { + super(who, block, blockClicked, blockFace, bucket, itemInHand); + } + @NotNull @Override public HandlerList getHandlers() { diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerBucketEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerBucketEvent.java index d2990a20d7..0e4fa04ea7 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerBucketEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerBucketEvent.java @@ -15,12 +15,19 @@ import org.jetbrains.annotations.Nullable; public abstract class PlayerBucketEvent extends PlayerEvent implements Cancellable { private ItemStack itemStack; private boolean cancelled = false; + private final Block block; private final Block blockClicked; private final BlockFace blockFace; private final Material bucket; + @Deprecated public PlayerBucketEvent(@NotNull final Player who, @NotNull final Block blockClicked, @NotNull final BlockFace blockFace, @NotNull final Material bucket, @NotNull final ItemStack itemInHand) { + this(who, null, blockClicked.getRelative(blockFace), blockFace, bucket, itemInHand); + } + + public PlayerBucketEvent(@NotNull final Player who, @NotNull final Block block, @NotNull final Block blockClicked, @NotNull final BlockFace blockFace, @NotNull final Material bucket, @NotNull final ItemStack itemInHand) { super(who); + this.block = block; this.blockClicked = blockClicked; this.blockFace = blockFace; this.itemStack = itemInHand; @@ -56,6 +63,16 @@ public abstract class PlayerBucketEvent extends PlayerEvent implements Cancellab this.itemStack = itemStack; } + /** + * Gets the block involved in this event. + * + * @return The Block which block is involved in this event + */ + @NotNull + public final Block getBlock() { + return block; + } + /** * Return the block clicked * diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerBucketFillEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerBucketFillEvent.java index cc1b03eb27..77c3a6e5c8 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerBucketFillEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerBucketFillEvent.java @@ -14,10 +14,15 @@ import org.jetbrains.annotations.NotNull; public class PlayerBucketFillEvent extends PlayerBucketEvent { private static final HandlerList handlers = new HandlerList(); + @Deprecated public PlayerBucketFillEvent(@NotNull final Player who, @NotNull final Block blockClicked, @NotNull final BlockFace blockFace, @NotNull final Material bucket, @NotNull final ItemStack itemInHand) { super(who, blockClicked, blockFace, bucket, itemInHand); } + public PlayerBucketFillEvent(@NotNull final Player who, @NotNull final Block block, @NotNull final Block blockClicked, @NotNull final BlockFace blockFace, @NotNull final Material bucket, @NotNull final ItemStack itemInHand) { + super(who, block, blockClicked, blockFace, bucket, itemInHand); + } + @NotNull @Override public HandlerList getHandlers() {