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

@ -6,10 +6,10 @@ Subject: [PATCH] Turtle API
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/TurtleGoHomeEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/TurtleGoHomeEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..cfbc8aaf862ac90e794ee38bf8a6cb9ea414b13e
index 0000000000000000000000000000000000000000..560b46b7b4fdd3394bc5e8fc917776a5838eba09
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/TurtleGoHomeEvent.java
@@ -0,0 +1,53 @@
@@ -0,0 +1,51 @@
+package com.destroystokyo.paper.event.entity;
+
+import org.bukkit.entity.Turtle;
@ -17,11 +17,12 @@ index 0000000000000000000000000000000000000000..cfbc8aaf862ac90e794ee38bf8a6cb9e
+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 Turtle decides to go home
+ */
+@NullMarked
+public class TurtleGoHomeEvent extends EntityEvent implements Cancellable {
+
+ private static final HandlerList HANDLER_LIST = new HandlerList();
@ -29,7 +30,7 @@ index 0000000000000000000000000000000000000000..cfbc8aaf862ac90e794ee38bf8a6cb9e
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public TurtleGoHomeEvent(@NotNull Turtle turtle) {
+ public TurtleGoHomeEvent(final Turtle turtle) {
+ super(turtle);
+ }
+
@ -38,7 +39,6 @@ index 0000000000000000000000000000000000000000..cfbc8aaf862ac90e794ee38bf8a6cb9e
+ *
+ * @return The turtle
+ */
+ @NotNull
+ public Turtle getEntity() {
+ return (Turtle) super.getEntity();
+ }
@ -49,26 +49,24 @@ index 0000000000000000000000000000000000000000..cfbc8aaf862ac90e794ee38bf8a6cb9e
+ }
+
+ @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;
+ }
+}
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/TurtleLayEggEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/TurtleLayEggEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..3029e406cd684efb5645e38711dff9c0bb7b01e4
index 0000000000000000000000000000000000000000..d1b2bbb57280726690e704c5978d312d856243eb
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/TurtleLayEggEvent.java
@@ -0,0 +1,92 @@
@@ -0,0 +1,88 @@
+package com.destroystokyo.paper.event.entity;
+
+import org.bukkit.Location;
@ -77,23 +75,23 @@ index 0000000000000000000000000000000000000000..3029e406cd684efb5645e38711dff9c0
+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 Turtle lays eggs
+ */
+@NullMarked
+public class TurtleLayEggEvent extends EntityEvent implements Cancellable {
+
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ @NotNull
+ private final Location location;
+ private int eggCount;
+
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public TurtleLayEggEvent(@NotNull Turtle turtle, @NotNull Location location, int eggCount) {
+ public TurtleLayEggEvent(final Turtle turtle, final Location location, final int eggCount) {
+ super(turtle);
+ this.location = location;
+ this.eggCount = eggCount;
@ -104,7 +102,6 @@ index 0000000000000000000000000000000000000000..3029e406cd684efb5645e38711dff9c0
+ *
+ * @return The turtle
+ */
+ @NotNull
+ public Turtle getEntity() {
+ return (Turtle) super.getEntity();
+ }
@ -114,7 +111,6 @@ index 0000000000000000000000000000000000000000..3029e406cd684efb5645e38711dff9c0
+ *
+ * @return Location of eggs
+ */
+ @NotNull
+ public Location getLocation() {
+ return this.location.clone();
+ }
@ -133,7 +129,7 @@ index 0000000000000000000000000000000000000000..3029e406cd684efb5645e38711dff9c0
+ *
+ * @param eggCount Number of eggs
+ */
+ public void setEggCount(int eggCount) {
+ public void setEggCount(final int eggCount) {
+ if (eggCount < 1) {
+ this.cancelled = true;
+ return;
@ -147,26 +143,24 @@ index 0000000000000000000000000000000000000000..3029e406cd684efb5645e38711dff9c0
+ }
+
+ @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;
+ }
+}
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/TurtleStartDiggingEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/TurtleStartDiggingEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..7a2fa4a11b47e4982d1644830d7e28f12b4378ec
index 0000000000000000000000000000000000000000..4a53af5da307cd71e0e647917bec9be44136e6aa
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/TurtleStartDiggingEvent.java
@@ -0,0 +1,66 @@
@@ -0,0 +1,63 @@
+package com.destroystokyo.paper.event.entity;
+
+import org.bukkit.Location;
@ -175,20 +169,21 @@ index 0000000000000000000000000000000000000000..7a2fa4a11b47e4982d1644830d7e28f1
+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 Turtle starts digging to lay eggs
+ */
+@NullMarked
+public class TurtleStartDiggingEvent extends EntityEvent implements Cancellable {
+
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ @NotNull private final Location location;
+ private final Location location;
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public TurtleStartDiggingEvent(@NotNull Turtle turtle, @NotNull Location location) {
+ public TurtleStartDiggingEvent(final Turtle turtle, final Location location) {
+ super(turtle);
+ this.location = location;
+ }
@ -198,7 +193,6 @@ index 0000000000000000000000000000000000000000..7a2fa4a11b47e4982d1644830d7e28f1
+ *
+ * @return The turtle
+ */
+ @NotNull
+ public Turtle getEntity() {
+ return (Turtle) super.getEntity();
+ }
@ -208,7 +202,6 @@ index 0000000000000000000000000000000000000000..7a2fa4a11b47e4982d1644830d7e28f1
+ *
+ * @return Location where digging
+ */
+ @NotNull
+ public Location getLocation() {
+ return this.location.clone();
+ }
@ -219,16 +212,14 @@ index 0000000000000000000000000000000000000000..7a2fa4a11b47e4982d1644830d7e28f1
+ }
+
+ @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;
+ }