Begin switching to JSpecify annotations (#11448)
* Begin switching to JSpecify annotations * more * fixes
This commit is contained in:
		
					parent
					
						
							
								fa1f6a5d78
							
						
					
				
			
			
				commit
				
					
						64e918335c
					
				
			
		
					 62 changed files with 580 additions and 750 deletions
				
			
		| 
						 | 
				
			
			@ -20,12 +20,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 | 
			
		|||
+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..00000000000000000000000000000000
 | 
			
		|||
+    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..00000000000000000000000000000000
 | 
			
		|||
+     *
 | 
			
		||||
+     * @return Damage state
 | 
			
		||||
+     */
 | 
			
		||||
+    @NotNull
 | 
			
		||||
+    public DamageState getDamageState() {
 | 
			
		||||
+        return this.damageState;
 | 
			
		||||
+    }
 | 
			
		||||
| 
						 | 
				
			
			@ -60,7 +59,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 | 
			
		|||
+     *
 | 
			
		||||
+     * @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..00000000000000000000000000000000
 | 
			
		|||
+     *
 | 
			
		||||
+     * @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..00000000000000000000000000000000
 | 
			
		|||
+    }
 | 
			
		||||
+
 | 
			
		||||
+    @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..00000000000000000000000000000000
 | 
			
		|||
+
 | 
			
		||||
+        private final Material material;
 | 
			
		||||
+
 | 
			
		||||
+        DamageState(@NotNull Material material) {
 | 
			
		||||
+        DamageState(final Material material) {
 | 
			
		||||
+            this.material = material;
 | 
			
		||||
+        }
 | 
			
		||||
+
 | 
			
		||||
| 
						 | 
				
			
			@ -126,7 +123,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 | 
			
		|||
+         *
 | 
			
		||||
+         * @return Material
 | 
			
		||||
+         */
 | 
			
		||||
+        @NotNull
 | 
			
		||||
+        public Material getMaterial() {
 | 
			
		||||
+            return this.material;
 | 
			
		||||
+        }
 | 
			
		||||
| 
						 | 
				
			
			@ -138,8 +134,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 | 
			
		|||
+         * @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..00000000000000000000000000000000
 | 
			
		|||
+         * @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;
 | 
			
		||||
+                }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue