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

@ -14,7 +14,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+
+import org.bukkit.entity.Slime;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull;
+import org.jspecify.annotations.NullMarked;
+
+/**
+ * Fired when a Slime decides to change its facing direction.
@ -22,12 +22,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * This event does not fire for the entity's actual movement. Only when it
+ * is choosing to change direction.
+ */
+@NullMarked
+public class SlimeChangeDirectionEvent extends SlimePathfindEvent {
+
+ private float yaw;
+
+ @ApiStatus.Internal
+ public SlimeChangeDirectionEvent(@NotNull Slime slime, float yaw) {
+ public SlimeChangeDirectionEvent(final Slime slime, final float yaw) {
+ super(slime);
+ this.yaw = yaw;
+ }
@ -46,7 +47,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ *
+ * @param yaw Chosen yaw
+ */
+ public void setNewYaw(float yaw) {
+ public void setNewYaw(final float yaw) {
+ this.yaw = yaw;
+ }
+}
@ -63,7 +64,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull;
+import org.jspecify.annotations.NullMarked;
+
+/**
+ * Fired when a Slime decides to start pathfinding.
@ -71,6 +72,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * This event does not fire for the entity's actual movement. Only when it
+ * is choosing to start moving.
+ */
+@NullMarked
+public class SlimePathfindEvent extends EntityEvent implements Cancellable {
+
+ private static final HandlerList HANDLER_LIST = new HandlerList();
@ -78,7 +80,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public SlimePathfindEvent(@NotNull Slime slime) {
+ public SlimePathfindEvent(final Slime slime) {
+ super(slime);
+ }
+
@ -87,7 +89,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ *
+ * @return The Slime that is pathfinding.
+ */
+ @NotNull
+ public Slime getEntity() {
+ return (Slime) super.getEntity();
+ }
@ -98,16 +99,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ }
+
+ @Override
+ public void setCancelled(boolean cancel) {
+ public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel;
+ }
+
+ @NotNull
+ public HandlerList getHandlers() {
+ return HANDLER_LIST;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return HANDLER_LIST;
+ }
@ -122,7 +121,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+
+import org.bukkit.entity.Slime;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull;
+import org.jspecify.annotations.NullMarked;
+
+/**
+ * Fired when a Slime decides to start jumping while swimming in water/lava.
@ -130,10 +129,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * This event does not fire for the entity's actual movement. Only when it
+ * is choosing to start jumping.
+ */
+@NullMarked
+public class SlimeSwimEvent extends SlimeWanderEvent {
+
+ @ApiStatus.Internal
+ public SlimeSwimEvent(@NotNull Slime slime) {
+ public SlimeSwimEvent(final Slime slime) {
+ super(slime);
+ }
+}
@ -148,7 +148,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.entity.LivingEntity;
+import org.bukkit.entity.Slime;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull;
+import org.jspecify.annotations.NullMarked;
+
+/**
+ * Fired when a Slime decides to change direction to target a LivingEntity.
@ -156,12 +156,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * This event does not fire for the entity's actual movement. Only when it
+ * is choosing to start moving.
+ */
+@NullMarked
+public class SlimeTargetLivingEntityEvent extends SlimePathfindEvent {
+
+ @NotNull private final LivingEntity target;
+ private final LivingEntity target;
+
+ @ApiStatus.Internal
+ public SlimeTargetLivingEntityEvent(@NotNull Slime slime, @NotNull LivingEntity target) {
+ public SlimeTargetLivingEntityEvent(final Slime slime, final LivingEntity target) {
+ super(slime);
+ this.target = target;
+ }
@ -171,7 +172,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ *
+ * @return Targeted entity
+ */
+ @NotNull
+ public LivingEntity getTarget() {
+ return this.target;
+ }
@ -186,7 +186,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+
+import org.bukkit.entity.Slime;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull;
+import org.jspecify.annotations.NullMarked;
+
+/**
+ * Fired when a Slime decides to start wandering.
@ -194,10 +194,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * This event does not fire for the entity's actual movement. Only when it
+ * is choosing to start moving.
+ */
+@NullMarked
+public class SlimeWanderEvent extends SlimePathfindEvent {
+
+ @ApiStatus.Internal
+ public SlimeWanderEvent(@NotNull Slime slime) {
+ public SlimeWanderEvent(final Slime slime) {
+ super(slime);
+ }
+}