Finish converting all events to jspecify annotations

This commit is contained in:
Jake Potrebic 2024-09-29 16:48:34 -07:00
parent ea00be3aaa
commit ba3c29b92e
No known key found for this signature in database
GPG key ID: ECE0B3C133C016C5
82 changed files with 977 additions and 1103 deletions

View file

@ -6,10 +6,10 @@ Subject: [PATCH] Add worldborder events
diff --git a/src/main/java/io/papermc/paper/event/world/border/WorldBorderBoundsChangeEvent.java b/src/main/java/io/papermc/paper/event/world/border/WorldBorderBoundsChangeEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..02ac479840c137ca5afcec149ef884e5a5d62928
index 0000000000000000000000000000000000000000..3c168b3522c538c1576238738d48eaef6559450d
--- /dev/null
+++ b/src/main/java/io/papermc/paper/event/world/border/WorldBorderBoundsChangeEvent.java
@@ -0,0 +1,117 @@
@@ -0,0 +1,115 @@
+package io.papermc.paper.event.world.border;
+
+import org.bukkit.World;
@ -17,11 +17,12 @@ index 0000000000000000000000000000000000000000..02ac479840c137ca5afcec149ef884e5
+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..02ac479840c137ca5afcec149ef884e5
+ 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..02ac479840c137ca5afcec149ef884e5
+ *
+ * @return the change type
+ */
+ @NotNull
+ public Type getType() {
+ return this.type;
+ }
@ -74,7 +74,7 @@ index 0000000000000000000000000000000000000000..02ac479840c137ca5afcec149ef884e5
+ *
+ * @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..02ac479840c137ca5afcec149ef884e5
+ *
+ * @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..02ac479840c137ca5afcec149ef884e5
+ }
+
+ @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;
+ }
@ -129,21 +127,22 @@ index 0000000000000000000000000000000000000000..02ac479840c137ca5afcec149ef884e5
+}
diff --git a/src/main/java/io/papermc/paper/event/world/border/WorldBorderBoundsChangeFinishEvent.java b/src/main/java/io/papermc/paper/event/world/border/WorldBorderBoundsChangeFinishEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..a44964593b7f78c5086dc4928e75ad892e624671
index 0000000000000000000000000000000000000000..6a264660897f0b621e3fb112e6056d98bb510f52
--- /dev/null
+++ b/src/main/java/io/papermc/paper/event/world/border/WorldBorderBoundsChangeFinishEvent.java
@@ -0,0 +1,67 @@
@@ -0,0 +1,66 @@
+package io.papermc.paper.event.world.border;
+
+import org.bukkit.World;
+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..a44964593b7f78c5086dc4928e75ad89
+ 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,23 +188,21 @@ index 0000000000000000000000000000000000000000..a44964593b7f78c5086dc4928e75ad89
+ return this.duration;
+ }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return HANDLER_LIST;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return HANDLER_LIST;
+ }
+}
diff --git a/src/main/java/io/papermc/paper/event/world/border/WorldBorderCenterChangeEvent.java b/src/main/java/io/papermc/paper/event/world/border/WorldBorderCenterChangeEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..dd96dcc0dd68d71bf27c758ed496153d434fb386
index 0000000000000000000000000000000000000000..74fe5ad50517374631fa3009249833e2b99a55f0
--- /dev/null
+++ b/src/main/java/io/papermc/paper/event/world/border/WorldBorderCenterChangeEvent.java
@@ -0,0 +1,79 @@
@@ -0,0 +1,76 @@
+package io.papermc.paper.event.world.border;
+
+import org.bukkit.Location;
@ -214,11 +211,12 @@ index 0000000000000000000000000000000000000000..dd96dcc0dd68d71bf27c758ed496153d
+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..dd96dcc0dd68d71bf27c758ed496153d
+ 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..dd96dcc0dd68d71bf27c758ed496153d
+ *
+ * @return the old center
+ */
+ @NotNull
+ public Location getOldCenter() {
+ return this.oldCenter.clone();
+ }
@ -250,7 +247,6 @@ index 0000000000000000000000000000000000000000..dd96dcc0dd68d71bf27c758ed496153d
+ *
+ * @return the new center
+ */
+ @NotNull
+ public Location getNewCenter() {
+ return this.newCenter;
+ }
@ -260,7 +256,7 @@ index 0000000000000000000000000000000000000000..dd96dcc0dd68d71bf27c758ed496153d
+ *
+ * @param newCenter the new center
+ */
+ public void setNewCenter(@NotNull Location newCenter) {
+ public void setNewCenter(final Location newCenter) {
+ this.newCenter = newCenter;
+ }
+
@ -270,24 +266,22 @@ index 0000000000000000000000000000000000000000..dd96dcc0dd68d71bf27c758ed496153d
+ }
+
+ @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;
+ }
+}
diff --git a/src/main/java/io/papermc/paper/event/world/border/WorldBorderEvent.java b/src/main/java/io/papermc/paper/event/world/border/WorldBorderEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..adb244f9be35c43ff99dbc3a771e1fdfb21da68c
index 0000000000000000000000000000000000000000..1f260e4d693903361d54c0af42144faa66adf4ea
--- /dev/null
+++ b/src/main/java/io/papermc/paper/event/world/border/WorldBorderEvent.java
@@ -0,0 +1,23 @@
@ -297,19 +291,19 @@ index 0000000000000000000000000000000000000000..adb244f9be35c43ff99dbc3a771e1fdf
+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;
+ }