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

@@ -19,8 +19,8 @@ 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.jetbrains.annotations.Nullable;
+import org.jspecify.annotations.NullMarked;
+import org.jspecify.annotations.Nullable;
+
+/**
+ * Fired when an Entity decides to start moving towards a location.
@@ -28,16 +28,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * This event does not fire for the entities actual movement. Only when it
+ * is choosing to start moving to a location.
+ */
+@NullMarked
+public class EntityPathfindEvent extends EntityEvent implements Cancellable {
+
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ @Nullable private final Entity targetEntity;
+ @NotNull private final Location location;
+ private final @Nullable Entity targetEntity;
+ private final Location location;
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public EntityPathfindEvent(@NotNull Entity entity, @NotNull Location location, @Nullable Entity targetEntity) {
+ public EntityPathfindEvent(final Entity entity, final Location location, final @Nullable Entity targetEntity) {
+ super(entity);
+ this.targetEntity = targetEntity;
+ this.location = location;
@@ -48,7 +49,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ *
+ * @return The Entity that is pathfinding.
+ */
+ @NotNull
+ public Entity getEntity() {
+ return this.entity;
+ }
@@ -56,12 +56,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ /**
+ * If the Entity is trying to pathfind to an entity, this is the entity in relation.
+ * <br>
+ * Otherwise this will return {@code null}.
+ * Otherwise, this will return {@code null}.
+ *
+ * @return The entity target or {@code null}
+ */
+ @Nullable
+ public Entity getTargetEntity() {
+ public @Nullable Entity getTargetEntity() {
+ return this.targetEntity;
+ }
+
@@ -72,7 +71,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ *
+ * @return Location of where the entity is trying to pathfind to.
+ */
+ @NotNull
+ public Location getLoc() {
+ return this.location.clone();
+ }
@@ -83,17 +81,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ }
+
+ @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;
+ }