Begin switching to JSpecify annotations (#11448)

* Begin switching to JSpecify annotations

* more

* fixes
This commit is contained in:
Jake Potrebic
2024-09-29 12:52:13 -07:00
parent fa1f6a5d78
commit 64e918335c
62 changed files with 580 additions and 750 deletions

View File

@@ -17,18 +17,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.block.BlockEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull;
+import org.jspecify.annotations.NullMarked;
+
+/**
+ * Called when a beacon is activated.
+ * Activation occurs when the beacon beam becomes visible.
+ */
+@NullMarked
+public class BeaconActivatedEvent extends BlockEvent {
+
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ @ApiStatus.Internal
+ public BeaconActivatedEvent(@NotNull Block block) {
+ public BeaconActivatedEvent(final Block block) {
+ super(block);
+ }
+
@@ -37,18 +38,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ *
+ * @return the beacon that was activated.
+ */
+ @NotNull
+ public Beacon getBeacon() {
+ return (Beacon) this.block.getState();
+ }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return HANDLER_LIST;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return HANDLER_LIST;
+ }
@@ -67,18 +65,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.block.BlockEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jspecify.annotations.NullMarked;
+import org.jspecify.annotations.Nullable;
+
+/**
+ * Called when a beacon is deactivated, either because its base block(s) or itself were destroyed.
+ */
+@NullMarked
+public class BeaconDeactivatedEvent extends BlockEvent {
+
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ @ApiStatus.Internal
+ public BeaconDeactivatedEvent(@NotNull Block block) {
+ public BeaconDeactivatedEvent(final Block block) {
+ super(block);
+ }
+
@@ -89,18 +88,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ *
+ * @return The beacon that got deactivated, or {@code null} if it does not exist.
+ */
+ @Nullable
+ public Beacon getBeacon() {
+ public @Nullable Beacon getBeacon() {
+ return this.block.getType() == Material.BEACON ? (Beacon) this.block.getState() : null;
+ }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return HANDLER_LIST;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return HANDLER_LIST;
+ }