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

@@ -18,7 +18,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.player.PlayerEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull;
+import org.jspecify.annotations.NullMarked;
+
+/**
+ * Called when the player tries to attack an entity.
@@ -31,18 +31,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * <p>
+ * Note: there may be other factors (invulnerability, etc.) that will prevent this entity from being attacked that this event will not cover
+ */
+@NullMarked
+public class PrePlayerAttackEntityEvent extends PlayerEvent implements Cancellable {
+
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ @NotNull
+ private final Entity attacked;
+ private final boolean willAttack;
+
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public PrePlayerAttackEntityEvent(@NotNull Player player, @NotNull Entity attacked, boolean willAttack) {
+ public PrePlayerAttackEntityEvent(final Player player, final Entity attacked, final boolean willAttack) {
+ super(player);
+ this.attacked = attacked;
+ this.willAttack = willAttack;
@@ -54,7 +54,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ *
+ * @return entity that was attacked
+ */
+ @NotNull
+ public Entity getAttacked() {
+ return this.attacked;
+ }
@@ -84,7 +83,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param cancel {@code true} if you wish to cancel this event
+ */
+ @Override
+ public void setCancelled(boolean cancel) {
+ public void setCancelled(final boolean cancel) {
+ if (!this.willAttack) {
+ return;
+ }
@@ -92,13 +91,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ this.cancelled = cancel;
+ }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return HANDLER_LIST;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return HANDLER_LIST;
+ }