Finish converting all events to jspecify annotations

This commit is contained in:
Jake Potrebic
2024-09-29 16:48:34 -07:00
parent fa97c59a4e
commit 29a25df60e
78 changed files with 757 additions and 883 deletions

View File

@@ -17,11 +17,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull;
+import org.jspecify.annotations.NullMarked;
+
+/**
+ * Called when a world border changes its bounds, either over time, or instantly.
+ */
+@NullMarked
+public class WorldBorderBoundsChangeEvent extends WorldBorderEvent implements Cancellable {
+
+ private static final HandlerList HANDLER_LIST = new HandlerList();
@@ -33,7 +34,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public WorldBorderBoundsChangeEvent(@NotNull World world, @NotNull WorldBorder worldBorder, @NotNull Type type, double oldSize, double newSize, long duration) {
+ public WorldBorderBoundsChangeEvent(final World world, final WorldBorder worldBorder, final Type type, final double oldSize, final double newSize, final long duration) {
+ super(world, worldBorder);
+ this.type = type;
+ this.oldSize = oldSize;
@@ -46,7 +47,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ *
+ * @return the change type
+ */
+ @NotNull
+ public Type getType() {
+ return this.type;
+ }
@@ -74,7 +74,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ *
+ * @param newSize the new size
+ */
+ public void setNewSize(double newSize) {
+ public void setNewSize(final double newSize) {
+ this.newSize = Math.min(this.worldBorder.getMaxSize(), Math.max(1.0D, newSize));
+ }
+
@@ -93,7 +93,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ *
+ * @param duration the time in milliseconds for the change
+ */
+ public void setDuration(long duration) {
+ public void setDuration(final long duration) {
+ // PAIL: TODO: Magic Values
+ this.duration = Math.min(9223372036854775L, Math.max(0L, duration));
+ if (duration >= 0 && this.type == Type.INSTANT_MOVE) {
@@ -107,17 +107,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;
+ }
@@ -139,11 +137,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.WorldBorder;
+import org.bukkit.event.HandlerList;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull;
+import org.jspecify.annotations.NullMarked;
+
+/**
+ * Called when a moving world border has finished its move.
+ */
+@NullMarked
+public class WorldBorderBoundsChangeFinishEvent extends WorldBorderEvent {
+
+ private static final HandlerList HANDLER_LIST = new HandlerList();
@@ -153,7 +152,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private final double duration;
+
+ @ApiStatus.Internal
+ public WorldBorderBoundsChangeFinishEvent(@NotNull World world, @NotNull WorldBorder worldBorder, double oldSize, double newSize, double duration) {
+ public WorldBorderBoundsChangeFinishEvent(final World world, final WorldBorder worldBorder, final double oldSize, final double newSize, final double duration) {
+ super(world, worldBorder);
+ this.oldSize = oldSize;
+ this.newSize = newSize;
@@ -189,13 +188,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return this.duration;
+ }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return HANDLER_LIST;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return HANDLER_LIST;
+ }
@@ -214,11 +211,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull;
+import org.jspecify.annotations.NullMarked;
+
+/**
+ * Called when a world border's center is changed.
+ */
+@NullMarked
+public class WorldBorderCenterChangeEvent extends WorldBorderEvent implements Cancellable {
+
+ private static final HandlerList HANDLER_LIST = new HandlerList();
@@ -229,7 +227,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public WorldBorderCenterChangeEvent(@NotNull World world, @NotNull WorldBorder worldBorder, @NotNull Location oldCenter, @NotNull Location newCenter) {
+ public WorldBorderCenterChangeEvent(final World world, final WorldBorder worldBorder, final Location oldCenter, final Location newCenter) {
+ super(world, worldBorder);
+ this.oldCenter = oldCenter;
+ this.newCenter = newCenter;
@@ -240,7 +238,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ *
+ * @return the old center
+ */
+ @NotNull
+ public Location getOldCenter() {
+ return this.oldCenter.clone();
+ }
@@ -250,7 +247,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ *
+ * @return the new center
+ */
+ @NotNull
+ public Location getNewCenter() {
+ return this.newCenter;
+ }
@@ -260,7 +256,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ *
+ * @param newCenter the new center
+ */
+ public void setNewCenter(@NotNull Location newCenter) {
+ public void setNewCenter(final Location newCenter) {
+ this.newCenter = newCenter;
+ }
+
@@ -270,17 +266,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;
+ }
@@ -297,19 +291,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.WorldBorder;
+import org.bukkit.event.world.WorldEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull;
+import org.jspecify.annotations.NullMarked;
+
+@NullMarked
+public abstract class WorldBorderEvent extends WorldEvent {
+
+ protected final WorldBorder worldBorder;
+
+ @ApiStatus.Internal
+ protected WorldBorderEvent(@NotNull World world, @NotNull WorldBorder worldBorder) {
+ protected WorldBorderEvent(final World world, final WorldBorder worldBorder) {
+ super(world);
+ this.worldBorder = worldBorder;
+ }
+
+ @NotNull
+ public WorldBorder getWorldBorder() {
+ return this.worldBorder;
+ }