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

@@ -17,11 +17,12 @@ 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 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..00000000000000000000000000000000
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public TurtleGoHomeEvent(@NotNull Turtle turtle) {
+ public TurtleGoHomeEvent(final Turtle turtle) {
+ super(turtle);
+ }
+
@@ -38,7 +39,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ *
+ * @return The turtle
+ */
+ @NotNull
+ public Turtle getEntity() {
+ return (Turtle) super.getEntity();
+ }
@@ -49,16 +49,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;
+ }
@@ -77,23 +75,23 @@ 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 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..00000000000000000000000000000000
+ *
+ * @return The turtle
+ */
+ @NotNull
+ public Turtle getEntity() {
+ return (Turtle) super.getEntity();
+ }
@@ -114,7 +111,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ *
+ * @return Location of eggs
+ */
+ @NotNull
+ public Location getLocation() {
+ return this.location.clone();
+ }
@@ -133,7 +129,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ *
+ * @param eggCount Number of eggs
+ */
+ public void setEggCount(int eggCount) {
+ public void setEggCount(final int eggCount) {
+ if (eggCount < 1) {
+ this.cancelled = true;
+ return;
@@ -147,16 +143,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;
+ }
@@ -175,20 +169,21 @@ 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 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..00000000000000000000000000000000
+ *
+ * @return The turtle
+ */
+ @NotNull
+ public Turtle getEntity() {
+ return (Turtle) super.getEntity();
+ }
@@ -208,7 +202,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ *
+ * @return Location where digging
+ */
+ @NotNull
+ public Location getLocation() {
+ return this.location.clone();
+ }
@@ -219,16 +212,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;
+ }