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

@@ -29,7 +29,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.CreatureSpawnEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull;
+import org.jspecify.annotations.NullMarked;
+
+/**
+ * WARNING: This event only fires for a limited number of cases, and not for every case that {@link CreatureSpawnEvent} does.
@@ -41,19 +41,20 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * Currently: NATURAL and SPAWNER based reasons. <!-- Please submit a Pull Request for future additions. -->
+ * Also, Plugins that replace Entity Registrations with their own custom entities might not fire this event.
+ */
+@NullMarked
+public class PreCreatureSpawnEvent extends Event implements Cancellable {
+
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ @NotNull private final Location location;
+ @NotNull private final EntityType type;
+ @NotNull private final CreatureSpawnEvent.SpawnReason reason;
+ private final Location location;
+ private final EntityType type;
+ private final CreatureSpawnEvent.SpawnReason reason;
+ private boolean shouldAbortSpawn;
+
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public PreCreatureSpawnEvent(@NotNull Location location, @NotNull EntityType type, @NotNull CreatureSpawnEvent.SpawnReason reason) {
+ public PreCreatureSpawnEvent(final Location location, final EntityType type, final CreatureSpawnEvent.SpawnReason reason) {
+ this.location = location;
+ this.type = type;
+ this.reason = reason;
@@ -62,7 +63,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ /**
+ * @return The location this creature is being spawned at
+ */
+ @NotNull
+ public Location getSpawnLocation() {
+ return this.location.clone();
+ }
@@ -70,7 +70,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ /**
+ * @return The type of creature being spawned
+ */
+ @NotNull
+ public EntityType getType() {
+ return this.type;
+ }
@@ -78,7 +77,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ /**
+ * @return Reason this creature is spawning (ie, NATURAL vs SPAWNER)
+ */
+ @NotNull
+ public CreatureSpawnEvent.SpawnReason getReason() {
+ return this.reason;
+ }
@@ -96,7 +94,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ *
+ * @param shouldAbortSpawn Set if the spawn process should be aborted vs trying more attempts
+ */
+ public void setShouldAbortSpawn(boolean shouldAbortSpawn) {
+ public void setShouldAbortSpawn(final boolean shouldAbortSpawn) {
+ this.shouldAbortSpawn = shouldAbortSpawn;
+ }
+
@@ -114,17 +112,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param cancel {@code true} if you wish to cancel this event, and abort the spawn of this creature
+ */
+ @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;
+ }