2019-06-06 17:36:57 +02:00
From 7289028e35c34417342840a7d8bc49228fc2d6c3 Mon Sep 17 00:00:00 2001
2018-08-07 16:44:44 +02:00
From: BillyGalbreath <Blake.Galbreath@GMail.com>
Date: Thu, 2 Aug 2018 08:44:20 -0500
Subject: [PATCH] Add hand to bucket events
diff --git a/src/main/java/org/bukkit/event/player/PlayerBucketEmptyEvent.java b/src/main/java/org/bukkit/event/player/PlayerBucketEmptyEvent.java
2019-06-06 17:36:57 +02:00
index cdf2e2016..5e93f1bbb 100644
2018-08-07 16:44:44 +02:00
--- a/src/main/java/org/bukkit/event/player/PlayerBucketEmptyEvent.java
+++ b/src/main/java/org/bukkit/event/player/PlayerBucketEmptyEvent.java
@@ -5,6 +5,7 @@ import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
+import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
2019-03-20 01:28:15 +01:00
import org.jetbrains.annotations.NotNull;
2018-08-07 16:44:44 +02:00
2019-03-20 01:28:15 +01:00
@@ -18,6 +19,12 @@ public class PlayerBucketEmptyEvent extends PlayerBucketEvent {
2018-08-07 16:44:44 +02:00
super(who, blockClicked, blockFace, bucket, itemInHand);
}
+ // Paper start - add EquipmentSlot
2019-03-20 01:28:15 +01:00
+ public PlayerBucketEmptyEvent(@NotNull final Player who, @NotNull final Block blockClicked, @NotNull final BlockFace blockFace, @NotNull final Material bucket, @NotNull final ItemStack itemInHand, @org.jetbrains.annotations.Nullable final EquipmentSlot hand) {
2018-08-07 16:44:44 +02:00
+ super(who, blockClicked, blockFace, bucket, itemInHand, hand);
+ }
+ // Paper end
+
2019-03-20 01:28:15 +01:00
@NotNull
2018-08-07 16:44:44 +02:00
@Override
public HandlerList getHandlers() {
diff --git a/src/main/java/org/bukkit/event/player/PlayerBucketEvent.java b/src/main/java/org/bukkit/event/player/PlayerBucketEvent.java
2019-06-06 17:36:57 +02:00
index d2990a20d..dfc76add1 100644
2018-08-07 16:44:44 +02:00
--- a/src/main/java/org/bukkit/event/player/PlayerBucketEvent.java
+++ b/src/main/java/org/bukkit/event/player/PlayerBucketEvent.java
@@ -5,6 +5,7 @@ import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
+import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
2019-03-20 01:28:15 +01:00
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -18,13 +19,21 @@ public abstract class PlayerBucketEvent extends PlayerEvent implements Cancellab
2018-08-07 16:44:44 +02:00
private final Block blockClicked;
private final BlockFace blockFace;
private final Material bucket;
+ private final EquipmentSlot hand; // Paper - add EquipmentSlot
2019-03-20 01:28:15 +01:00
public PlayerBucketEvent(@NotNull final Player who, @NotNull final Block blockClicked, @NotNull final BlockFace blockFace, @NotNull final Material bucket, @NotNull final ItemStack itemInHand) {
2018-08-07 16:44:44 +02:00
+ // Paper start - add EquipmentSlot
+ this(who, blockClicked, blockFace, bucket, itemInHand, null);
+ }
+
2019-03-20 01:28:15 +01:00
+ public PlayerBucketEvent(@NotNull final Player who, @NotNull final Block blockClicked, @NotNull final BlockFace blockFace, @NotNull final Material bucket, @NotNull final ItemStack itemInHand, @Nullable final EquipmentSlot hand) {
2018-08-07 16:44:44 +02:00
+ // Paper end
super(who);
this.blockClicked = blockClicked;
this.blockFace = blockFace;
this.itemStack = itemInHand;
this.bucket = bucket;
+ this.hand = hand == null ? player.getInventory().getItemInMainHand().equals(itemInHand) ? EquipmentSlot.HAND : EquipmentSlot.OFF_HAND : hand; // Paper - add EquipmentSlot
}
/**
2019-03-20 01:28:15 +01:00
@@ -76,6 +85,18 @@ public abstract class PlayerBucketEvent extends PlayerEvent implements Cancellab
2018-08-07 16:44:44 +02:00
return blockFace;
}
+ // Paper start
+ /**
+ * The hand used to perform this action.
+ *
+ * @return the hand used
+ */
2019-03-20 01:28:15 +01:00
+ @NotNull
2018-08-07 16:44:44 +02:00
+ public EquipmentSlot getHand() {
+ return hand;
+ }
+ // Paper end
+
2019-05-06 04:58:04 +02:00
@Override
2018-08-07 16:44:44 +02:00
public boolean isCancelled() {
return cancelled;
diff --git a/src/main/java/org/bukkit/event/player/PlayerBucketFillEvent.java b/src/main/java/org/bukkit/event/player/PlayerBucketFillEvent.java
2019-06-06 17:36:57 +02:00
index cc1b03eb2..15be7128b 100644
2018-08-07 16:44:44 +02:00
--- a/src/main/java/org/bukkit/event/player/PlayerBucketFillEvent.java
+++ b/src/main/java/org/bukkit/event/player/PlayerBucketFillEvent.java
@@ -5,6 +5,7 @@ import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
+import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
2019-03-20 01:28:15 +01:00
import org.jetbrains.annotations.NotNull;
2018-08-07 16:44:44 +02:00
2019-03-20 01:28:15 +01:00
@@ -18,6 +19,13 @@ public class PlayerBucketFillEvent extends PlayerBucketEvent {
2018-08-07 16:44:44 +02:00
super(who, blockClicked, blockFace, bucket, itemInHand);
}
2019-03-20 01:28:15 +01:00
+
2018-08-07 16:44:44 +02:00
+ // Paper start - add EquipmentSlot
2019-03-20 01:28:15 +01:00
+ public PlayerBucketFillEvent(@NotNull final Player who, @NotNull final Block blockClicked, @NotNull final BlockFace blockFace, @NotNull final Material bucket, @NotNull final ItemStack itemInHand, @org.jetbrains.annotations.Nullable final EquipmentSlot hand) {
2018-08-07 16:44:44 +02:00
+ super(who, blockClicked, blockFace, bucket, itemInHand, hand);
+ }
+ // Paper end
+
2019-03-20 01:28:15 +01:00
@NotNull
2018-08-07 16:44:44 +02:00
@Override
public HandlerList getHandlers() {
--
2019-03-20 01:28:15 +01:00
2.21.0
2018-08-07 16:44:44 +02:00