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
parent fa1f6a5d78
commit 64e918335c
62 changed files with 580 additions and 750 deletions

View File

@@ -24,7 +24,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.block.BlockExpEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull;
+import org.jspecify.annotations.NullMarked;
+
+/**
+ * Fired anytime the server intends to 'destroy' a block through some triggering reason.
@@ -36,11 +36,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * <p>
+ * Events such as leaves decaying, pistons retracting (where the block is moving), does NOT fire this event.
+ */
+@NullMarked
+public class BlockDestroyEvent extends BlockExpEvent implements Cancellable {
+
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ @NotNull private final BlockData newState;
+ private final BlockData newState;
+ private boolean willDrop;
+ private boolean playEffect = true;
+ private BlockData effectBlock;
@@ -48,7 +49,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public BlockDestroyEvent(@NotNull Block block, @NotNull BlockData newState, @NotNull BlockData effectBlock, int xp, boolean willDrop) {
+ public BlockDestroyEvent(final Block block, final BlockData newState, final BlockData effectBlock, final int xp, final boolean willDrop) {
+ super(block, xp);
+ this.newState = newState;
+ this.effectBlock = effectBlock;
@@ -60,7 +61,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ *
+ * @return block break effect
+ */
+ @NotNull
+ public BlockData getEffectBlock() {
+ return this.effectBlock;
+ }
@@ -72,14 +72,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ *
+ * @param effectBlock block effect
+ */
+ public void setEffectBlock(@NotNull BlockData effectBlock) {
+ public void setEffectBlock(final BlockData effectBlock) {
+ this.effectBlock = effectBlock;
+ }
+
+ /**
+ * @return The new state of this block (Air, or a Fluid type)
+ */
+ public @NotNull BlockData getNewState() {
+ public BlockData getNewState() {
+ return this.newState.clone();
+ }
+
@@ -93,7 +93,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ /**
+ * @param willDrop If the server is going to drop the block in question with this destroy event
+ */
+ public void setWillDrop(boolean willDrop) {
+ public void setWillDrop(final boolean willDrop) {
+ this.willDrop = willDrop;
+ }
+
@@ -107,7 +107,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ /**
+ * @param playEffect If the server should play the sound effect for this destruction
+ */
+ public void setPlayEffect(boolean playEffect) {
+ public void setPlayEffect(final boolean playEffect) {
+ this.playEffect = playEffect;
+ }
+
@@ -123,17 +123,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * If the event is cancelled, the block will remain in its previous state.
+ */
+ @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;
+ }