Deprecate ItemStack#setType & add ItemStack#withType (#10290)

This commit is contained in:
Owen1212055
2024-04-12 17:16:22 -04:00
parent 9e05b17b92
commit 14b0751f02
9 changed files with 229 additions and 4 deletions

View File

@@ -17,6 +17,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.player.PlayerEvent;
+import org.bukkit.inventory.EquipmentSlot;
+import org.bukkit.inventory.ItemStack;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull;
@@ -31,14 +32,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ @NotNull private final ItemStack itemStack;
+ @NotNull private final Firework firework;
+ private boolean consume = true;
+ @NotNull
+ private final EquipmentSlot hand;
+
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public PlayerElytraBoostEvent(@NotNull Player player, @NotNull ItemStack itemStack, @NotNull Firework firework) {
+ public PlayerElytraBoostEvent(@NotNull Player player, @NotNull ItemStack itemStack, @NotNull Firework firework, @NotNull EquipmentSlot hand) {
+ super(player);
+ this.itemStack = itemStack;
+ this.firework = firework;
+ this.hand = hand;
+ }
+
+ /**
@@ -79,6 +83,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ this.consume = consume;
+ }
+
+ /**
+ * Gets the hand holding the firework used for boosting this player.
+ *
+ * @return interaction hand
+ */
+ @NotNull
+ public EquipmentSlot getHand() {
+ return this.hand;
+ }
+
+ @Override
+ public boolean isCancelled() {
+ return this.cancelled;