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 committed by GitHub
parent 6d7a438fad
commit f9c7f2a5c1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
66 changed files with 750 additions and 920 deletions

View file

@ -6,10 +6,10 @@ Subject: [PATCH] AnvilDamageEvent
diff --git a/src/main/java/com/destroystokyo/paper/event/block/AnvilDamagedEvent.java b/src/main/java/com/destroystokyo/paper/event/block/AnvilDamagedEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..4f88c101d81e5c3a8a065260304d5816337666d7
index 0000000000000000000000000000000000000000..456e2a638421b435ede4205d3eedfafeedb196c1
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/block/AnvilDamagedEvent.java
@@ -0,0 +1,154 @@
@@ -0,0 +1,148 @@
+package com.destroystokyo.paper.event.block;
+
+import org.bukkit.Material;
@ -20,12 +20,13 @@ index 0000000000000000000000000000000000000000..4f88c101d81e5c3a8a065260304d5816
+import org.bukkit.inventory.AnvilInventory;
+import org.bukkit.inventory.InventoryView;
+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 an anvil is damaged from being used
+ */
+@NullMarked
+public class AnvilDamagedEvent extends InventoryEvent implements Cancellable {
+
+ private static final HandlerList HANDLER_LIST = new HandlerList();
@ -34,12 +35,11 @@ index 0000000000000000000000000000000000000000..4f88c101d81e5c3a8a065260304d5816
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public AnvilDamagedEvent(@NotNull InventoryView inventory, @Nullable BlockData blockData) {
+ public AnvilDamagedEvent(final InventoryView inventory, final @Nullable BlockData blockData) {
+ super(inventory);
+ this.damageState = DamageState.getState(blockData);
+ }
+
+ @NotNull
+ @Override
+ public AnvilInventory getInventory() {
+ return (AnvilInventory) super.getInventory();
@ -50,7 +50,6 @@ index 0000000000000000000000000000000000000000..4f88c101d81e5c3a8a065260304d5816
+ *
+ * @return Damage state
+ */
+ @NotNull
+ public DamageState getDamageState() {
+ return this.damageState;
+ }
@ -60,7 +59,7 @@ index 0000000000000000000000000000000000000000..4f88c101d81e5c3a8a065260304d5816
+ *
+ * @param damageState Damage state
+ */
+ public void setDamageState(@NotNull DamageState damageState) {
+ public void setDamageState(final DamageState damageState) {
+ this.damageState = damageState;
+ }
+
@ -78,7 +77,7 @@ index 0000000000000000000000000000000000000000..4f88c101d81e5c3a8a065260304d5816
+ *
+ * @param breaking {@code true} if breaking
+ */
+ public void setBreaking(boolean breaking) {
+ public void setBreaking(final boolean breaking) {
+ if (breaking) {
+ this.damageState = DamageState.BROKEN;
+ } else if (this.damageState == DamageState.BROKEN) {
@ -92,16 +91,14 @@ index 0000000000000000000000000000000000000000..4f88c101d81e5c3a8a065260304d5816
+ }
+
+ @Override
+ public void setCancelled(boolean cancel) {
+ public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel;
+ }
+
+ @NotNull
+ public HandlerList getHandlers() {
+ return HANDLER_LIST;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return HANDLER_LIST;
+ }
@ -117,7 +114,7 @@ index 0000000000000000000000000000000000000000..4f88c101d81e5c3a8a065260304d5816
+
+ private final Material material;
+
+ DamageState(@NotNull Material material) {
+ DamageState(final Material material) {
+ this.material = material;
+ }
+
@ -126,7 +123,6 @@ index 0000000000000000000000000000000000000000..4f88c101d81e5c3a8a065260304d5816
+ *
+ * @return Material
+ */
+ @NotNull
+ public Material getMaterial() {
+ return this.material;
+ }
@ -138,8 +134,7 @@ index 0000000000000000000000000000000000000000..4f88c101d81e5c3a8a065260304d5816
+ * @return DamageState
+ * @throws IllegalArgumentException If non anvil block data is given
+ */
+ @NotNull
+ public static DamageState getState(@Nullable BlockData blockData) {
+ public static DamageState getState(final @Nullable BlockData blockData) {
+ return blockData == null ? BROKEN : getState(blockData.getMaterial());
+ }
+
@ -150,12 +145,11 @@ index 0000000000000000000000000000000000000000..4f88c101d81e5c3a8a065260304d5816
+ * @return DamageState
+ * @throws IllegalArgumentException If non anvil material is given
+ */
+ @NotNull
+ public static DamageState getState(@Nullable Material material) {
+ public static DamageState getState(final @Nullable Material material) {
+ if (material == null) {
+ return BROKEN;
+ }
+ for (DamageState state : values()) {
+ for (final DamageState state : values()) {
+ if (state.getMaterial() == material) {
+ return state;
+ }