Begin switching to JSpecify annotations (#11448)

* Begin switching to JSpecify annotations

* more

* fixes
This commit is contained in:
Jake Potrebic 2024-09-29 12:52:13 -07:00 committed by GitHub
parent 6d7a438fad
commit f9c7f2a5c1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
66 changed files with 750 additions and 920 deletions

View file

@ -6,12 +6,13 @@ Subject: [PATCH] Add PlayerShearBlockEvent
diff --git a/src/main/java/io/papermc/paper/event/block/PlayerShearBlockEvent.java b/src/main/java/io/papermc/paper/event/block/PlayerShearBlockEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..9bb4a79320eac7d662d9d04765664b6a7e955a4f
index 0000000000000000000000000000000000000000..33c6e1868e1bad4802bcadecebc2b46633690fce
--- /dev/null
+++ b/src/main/java/io/papermc/paper/event/block/PlayerShearBlockEvent.java
@@ -0,0 +1,113 @@
@@ -0,0 +1,107 @@
+package io.papermc.paper.event.block;
+
+import java.util.List;
+import org.bukkit.block.Block;
+import org.bukkit.entity.Player;
+import org.bukkit.event.Cancellable;
@ -20,9 +21,7 @@ index 0000000000000000000000000000000000000000..9bb4a79320eac7d662d9d04765664b6a
+import org.bukkit.inventory.EquipmentSlot;
+import org.bukkit.inventory.ItemStack;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.List;
+import org.jspecify.annotations.NullMarked;
+
+/**
+ * Called when a player uses sheers on a block.
@ -32,6 +31,7 @@ index 0000000000000000000000000000000000000000..9bb4a79320eac7d662d9d04765664b6a
+ * <p>
+ * Examples include shearing a pumpkin to turn it into a carved pumpkin or shearing a beehive to get honeycomb.
+ */
+@NullMarked
+public class PlayerShearBlockEvent extends PlayerEvent implements Cancellable {
+
+ private static final HandlerList HANDLER_LIST = new HandlerList();
@ -44,7 +44,7 @@ index 0000000000000000000000000000000000000000..9bb4a79320eac7d662d9d04765664b6a
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public PlayerShearBlockEvent(@NotNull Player player, @NotNull Block block, @NotNull ItemStack item, @NotNull EquipmentSlot hand, @NotNull List<ItemStack> drops) {
+ public PlayerShearBlockEvent(final Player player, final Block block, final ItemStack item, final EquipmentSlot hand, final List<ItemStack> drops) {
+ super(player);
+ this.block = block;
+ this.item = item;
@ -57,7 +57,6 @@ index 0000000000000000000000000000000000000000..9bb4a79320eac7d662d9d04765664b6a
+ *
+ * @return The {@link Block} which block is being sheared in this event.
+ */
+ @NotNull
+ public Block getBlock() {
+ return this.block;
+ }
@ -67,7 +66,6 @@ index 0000000000000000000000000000000000000000..9bb4a79320eac7d662d9d04765664b6a
+ *
+ * @return The {@link ItemStack} of the shears.
+ */
+ @NotNull
+ public ItemStack getItem() {
+ return this.item;
+ }
@ -77,7 +75,6 @@ index 0000000000000000000000000000000000000000..9bb4a79320eac7d662d9d04765664b6a
+ *
+ * @return Either {@link EquipmentSlot#HAND} OR {@link EquipmentSlot#OFF_HAND}.
+ */
+ @NotNull
+ public EquipmentSlot getHand() {
+ return this.hand;
+ }
@ -85,9 +82,8 @@ index 0000000000000000000000000000000000000000..9bb4a79320eac7d662d9d04765664b6a
+ /**
+ * Gets the resulting drops of this event.
+ *
+ * @return A {@link List list} of {@link ItemStack items} that will be dropped as result of this event.
+ * @return A mutable {@link List list} of {@link ItemStack items} that will be dropped as result of this event.
+ */
+ @NotNull
+ public List<ItemStack> getDrops() {
+ return this.drops;
+ }
@ -108,17 +104,15 @@ index 0000000000000000000000000000000000000000..9bb4a79320eac7d662d9d04765664b6a
+ * @param cancel whether the shearing of the block should be cancelled or not.
+ */
+ @Override
+ public void setCancelled(boolean cancel) {
+ public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel;
+ }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return HANDLER_LIST;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return HANDLER_LIST;
+ }