switch to JSpecify annotations

This commit is contained in:
granny
2024-10-03 19:33:40 -07:00
parent 212c942316
commit 2eaea6a060
13 changed files with 158 additions and 173 deletions

View File

@@ -6,10 +6,10 @@ Subject: [PATCH] Add PreExplodeEvents
diff --git a/src/main/java/org/purpurmc/purpur/event/PreBlockExplodeEvent.java b/src/main/java/org/purpurmc/purpur/event/PreBlockExplodeEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..b22f28357bec72256b1f5f96e97d228d5882b4e0
index 0000000000000000000000000000000000000000..4b4d32c58224e1208f14024ca214078a37550bb5
--- /dev/null
+++ b/src/main/java/org/purpurmc/purpur/event/PreBlockExplodeEvent.java
@@ -0,0 +1,54 @@
@@ -0,0 +1,56 @@
+package org.purpurmc.purpur.event;
+
+import org.bukkit.ExplosionResult;
@@ -18,18 +18,21 @@ index 0000000000000000000000000000000000000000..b22f28357bec72256b1f5f96e97d228d
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.block.BlockExplodeEvent;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.ApiStatus;
+import java.util.Collections;
+import org.jspecify.annotations.NullMarked;
+
+/**
+ * Called before a block's explosion is processed
+ */
+@NullMarked
+public class PreBlockExplodeEvent extends BlockExplodeEvent implements Cancellable {
+ private static final HandlerList handlers = new HandlerList();
+ private boolean cancelled;
+ private final float yield;
+
+ public PreBlockExplodeEvent(@NotNull final Block what, final float yield, @NotNull BlockState explodedBlockState, @NotNull ExplosionResult result) {
+ @ApiStatus.Internal
+ public PreBlockExplodeEvent(final Block what, final float yield, BlockState explodedBlockState, ExplosionResult result) {
+ super(what, explodedBlockState, Collections.emptyList(), yield, result);
+ this.yield = yield;
+ this.cancelled = false;
@@ -55,21 +58,20 @@ index 0000000000000000000000000000000000000000..b22f28357bec72256b1f5f96e97d228d
+ }
+
+ @Override
+ public @NotNull HandlerList getHandlers() {
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+}
diff --git a/src/main/java/org/purpurmc/purpur/event/entity/PreEntityExplodeEvent.java b/src/main/java/org/purpurmc/purpur/event/entity/PreEntityExplodeEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..bd5e647d52b2c69da684bb246325e0d6ca81f96e
index 0000000000000000000000000000000000000000..d56fb066455007cc710f7ba34ba722af6e89bc1d
--- /dev/null
+++ b/src/main/java/org/purpurmc/purpur/event/entity/PreEntityExplodeEvent.java
@@ -0,0 +1,65 @@
@@ -0,0 +1,66 @@
+package org.purpurmc.purpur.event.entity;
+
+import org.bukkit.ExplosionResult;
@@ -77,19 +79,22 @@ index 0000000000000000000000000000000000000000..bd5e647d52b2c69da684bb246325e0d6
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityExplodeEvent;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.ApiStatus;
+import java.util.Collections;
+import org.jspecify.annotations.NullMarked;
+
+/**
+ * Called before an entity's explosion is processed
+ */
+@NullMarked
+public class PreEntityExplodeEvent extends EntityExplodeEvent implements Cancellable {
+ private static final HandlerList handlers = new HandlerList();
+ private boolean cancelled;
+ private final float yield;
+ private final Location location;
+
+ public PreEntityExplodeEvent(@NotNull org.bukkit.entity.Entity what, @NotNull final Location location, final float yield, @NotNull ExplosionResult result) {
+ @ApiStatus.Internal
+ public PreEntityExplodeEvent(org.bukkit.entity.Entity what, final Location location, final float yield, ExplosionResult result) {
+ super(what, location, Collections.emptyList(), yield, result);
+ this.cancelled = false;
+ this.yield = yield;
@@ -110,7 +115,6 @@ index 0000000000000000000000000000000000000000..bd5e647d52b2c69da684bb246325e0d6
+ *
+ * @return The location of the explosion
+ */
+ @NotNull
+ public Location getLocation() {
+ return location;
+ }
@@ -126,11 +130,10 @@ index 0000000000000000000000000000000000000000..bd5e647d52b2c69da684bb246325e0d6
+ }
+
+ @Override
+ public @NotNull HandlerList getHandlers() {
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }