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 PlayerJumpEvent
diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerJumpEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerJumpEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..8c2fd2c1120d634052f9bc345365272ad3a67b6f
index 0000000000000000000000000000000000000000..1d07c3d6bf3b9283371ca45698178979113085fa
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerJumpEvent.java
@@ -0,0 +1,106 @@
@@ -0,0 +1,105 @@
+package com.destroystokyo.paper.event.player;
+
+import com.google.common.base.Preconditions;
@ -20,7 +20,7 @@ index 0000000000000000000000000000000000000000..8c2fd2c1120d634052f9bc345365272a
+import org.bukkit.event.player.PlayerEvent;
+import org.bukkit.event.player.PlayerMoveEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull;
+import org.jspecify.annotations.NullMarked;
+
+/**
+ * Called when the server detects the player is jumping.
@ -29,17 +29,18 @@ index 0000000000000000000000000000000000000000..8c2fd2c1120d634052f9bc345365272a
+ * when checking for jumps via {@link PlayerMoveEvent}, this event is fired whenever
+ * the server detects that the player is jumping.
+ */
+@NullMarked
+public class PlayerJumpEvent extends PlayerEvent implements Cancellable {
+
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ @NotNull private final Location to;
+ @NotNull private Location from;
+ private final Location to;
+ private Location from;
+
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public PlayerJumpEvent(@NotNull final Player player, @NotNull final Location from, @NotNull final Location to) {
+ public PlayerJumpEvent(final Player player, final Location from, final Location to) {
+ super(player);
+ this.from = from;
+ this.to = to;
@ -54,6 +55,7 @@ index 0000000000000000000000000000000000000000..8c2fd2c1120d634052f9bc345365272a
+ *
+ * @return {@code true} if this event is cancelled
+ */
+ @Override
+ public boolean isCancelled() {
+ return this.cancelled;
+ }
@ -67,7 +69,8 @@ index 0000000000000000000000000000000000000000..8c2fd2c1120d634052f9bc345365272a
+ *
+ * @param cancel {@code true} if you wish to cancel this event
+ */
+ public void setCancelled(boolean cancel) {
+ @Override
+ public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel;
+ }
+
@ -76,7 +79,6 @@ index 0000000000000000000000000000000000000000..8c2fd2c1120d634052f9bc345365272a
+ *
+ * @return Location the player jumped from
+ */
+ @NotNull
+ public Location getFrom() {
+ return this.from;
+ }
@ -86,7 +88,7 @@ index 0000000000000000000000000000000000000000..8c2fd2c1120d634052f9bc345365272a
+ *
+ * @param from New location to mark as the players previous location
+ */
+ public void setFrom(@NotNull Location from) {
+ public void setFrom(final Location from) {
+ Preconditions.checkArgument(from != null, "Cannot use null from location!");
+ Preconditions.checkArgument(from.getWorld() != null, "Cannot use from location with null world!");
+ this.from = from;
@ -100,18 +102,15 @@ index 0000000000000000000000000000000000000000..8c2fd2c1120d634052f9bc345365272a
+ *
+ * @return Location the player jumped to
+ */
+ @NotNull
+ public Location getTo() {
+ return this.to.clone();
+ }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return HANDLER_LIST;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return HANDLER_LIST;
+ }