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

@ -7,10 +7,10 @@ Fires when an Entity decides to start moving to a location.
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/EntityPathfindEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/EntityPathfindEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..8267e8f1f0ade29a284831069e1268ee4b29e109
index 0000000000000000000000000000000000000000..2dd25136d81624025244a82de119fbecd0d7224c
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/EntityPathfindEvent.java
@@ -0,0 +1,87 @@
@@ -0,0 +1,83 @@
+package com.destroystokyo.paper.event.entity;
+
+import org.bukkit.Location;
@ -19,8 +19,8 @@ index 0000000000000000000000000000000000000000..8267e8f1f0ade29a284831069e1268ee
+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..8267e8f1f0ade29a284831069e1268ee
+ * 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..8267e8f1f0ade29a284831069e1268ee
+ *
+ * @return The Entity that is pathfinding.
+ */
+ @NotNull
+ public Entity getEntity() {
+ return this.entity;
+ }
@ -56,12 +56,11 @@ index 0000000000000000000000000000000000000000..8267e8f1f0ade29a284831069e1268ee
+ /**
+ * 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..8267e8f1f0ade29a284831069e1268ee
+ *
+ * @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..8267e8f1f0ade29a284831069e1268ee
+ }
+
+ @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;
+ }