Finish converting most of the undeprecated api to jspecify

This commit is contained in:
Jake Potrebic 2024-09-30 11:44:36 -07:00
parent ba3c29b92e
commit e7e1ab56ca
No known key found for this signature in database
GPG key ID: ECE0B3C133C016C5
45 changed files with 1046 additions and 982 deletions

View file

@ -6,28 +6,26 @@ Subject: [PATCH] Custom Potion Mixes
diff --git a/src/main/java/io/papermc/paper/potion/PotionMix.java b/src/main/java/io/papermc/paper/potion/PotionMix.java
new file mode 100644
index 0000000000000000000000000000000000000000..3fc922ebf972418b84181cd02e68d8ef0efd739b
index 0000000000000000000000000000000000000000..01b2a7c7a6bf328b3f7c30db3be0bfb8156ebc89
--- /dev/null
+++ b/src/main/java/io/papermc/paper/potion/PotionMix.java
@@ -0,0 +1,105 @@
@@ -0,0 +1,103 @@
+package io.papermc.paper.potion;
+
+import java.util.Objects;
+import java.util.function.Predicate;
+import org.bukkit.Keyed;
+import org.bukkit.NamespacedKey;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.RecipeChoice;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.Contract;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.Objects;
+import org.jspecify.annotations.NullMarked;
+
+/**
+ * Represents a potion mix made in a Brewing Stand.
+ */
+@ApiStatus.NonExtendable
+public class PotionMix implements Keyed {
+@NullMarked
+public final class PotionMix implements Keyed {
+
+ private final NamespacedKey key;
+ private final ItemStack result;
@ -42,7 +40,7 @@ index 0000000000000000000000000000000000000000..3fc922ebf972418b84181cd02e68d8ef
+ * @param input the input placed into the bottom 3 slots
+ * @param ingredient the ingredient placed into the top slot
+ */
+ public PotionMix(final @NotNull NamespacedKey key, final @NotNull ItemStack result, final @NotNull RecipeChoice input, final @NotNull RecipeChoice ingredient) {
+ public PotionMix(final NamespacedKey key, final ItemStack result, final RecipeChoice input, final RecipeChoice ingredient) {
+ this.key = key;
+ this.result = result;
+ this.input = input;
@ -57,12 +55,12 @@ index 0000000000000000000000000000000000000000..3fc922ebf972418b84181cd02e68d8ef
+ * @return a new RecipeChoice
+ */
+ @Contract(value = "_ -> new", pure = true)
+ public static @NotNull RecipeChoice createPredicateChoice(final @NotNull Predicate<? super ItemStack> stackPredicate) {
+ public static RecipeChoice createPredicateChoice(final Predicate<? super ItemStack> stackPredicate) {
+ return new PredicateRecipeChoice(stackPredicate);
+ }
+
+ @Override
+ public @NotNull NamespacedKey getKey() {
+ public NamespacedKey getKey() {
+ return this.key;
+ }
+
@ -71,7 +69,7 @@ index 0000000000000000000000000000000000000000..3fc922ebf972418b84181cd02e68d8ef
+ *
+ * @return the result itemstack
+ */
+ public @NotNull ItemStack getResult() {
+ public ItemStack getResult() {
+ return this.result;
+ }
+
@ -80,7 +78,7 @@ index 0000000000000000000000000000000000000000..3fc922ebf972418b84181cd02e68d8ef
+ *
+ * @return the bottom 3 slot ingredients
+ */
+ public @NotNull RecipeChoice getInput() {
+ public RecipeChoice getInput() {
+ return this.input;
+ }
+
@ -89,7 +87,7 @@ index 0000000000000000000000000000000000000000..3fc922ebf972418b84181cd02e68d8ef
+ *
+ * @return the top slot input
+ */
+ public @NotNull RecipeChoice getIngredient() {
+ public RecipeChoice getIngredient() {
+ return this.ingredient;
+ }
+
@ -117,21 +115,20 @@ index 0000000000000000000000000000000000000000..3fc922ebf972418b84181cd02e68d8ef
+}
diff --git a/src/main/java/io/papermc/paper/potion/PredicateRecipeChoice.java b/src/main/java/io/papermc/paper/potion/PredicateRecipeChoice.java
new file mode 100644
index 0000000000000000000000000000000000000000..3ede1e8f7bf0436fdc5bf395c0f9eaf11c252453
index 0000000000000000000000000000000000000000..c252b432a9df5fd7da71a5eecba37a8844820700
--- /dev/null
+++ b/src/main/java/io/papermc/paper/potion/PredicateRecipeChoice.java
@@ -0,0 +1,33 @@
@@ -0,0 +1,32 @@
+package io.papermc.paper.potion;
+
+import java.util.function.Predicate;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.RecipeChoice;
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.checkerframework.framework.qual.DefaultQualifier;
+import org.jetbrains.annotations.ApiStatus;
+import org.jspecify.annotations.NullMarked;
+
+@ApiStatus.Internal
+@DefaultQualifier(NonNull.class)
+@NullMarked
+record PredicateRecipeChoice(Predicate<? super ItemStack> itemStackPredicate) implements RecipeChoice, Cloneable {
+
+ @Override
@ -155,7 +152,7 @@ index 0000000000000000000000000000000000000000..3ede1e8f7bf0436fdc5bf395c0f9eaf1
+ }
+}
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index aa1795b9640a5e39cc5063dd3c389f6d5815ed36..30cb0f2c4d53a7ad473812810c4f50173b7d7391 100644
index e2d3e42b403dce454988c3ae3e44bcd89337b1cf..22021582b2f490ea2db87f2d3fe8a99b44d4f457 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -2641,6 +2641,15 @@ public final class Bukkit {
@ -175,7 +172,7 @@ index aa1795b9640a5e39cc5063dd3c389f6d5815ed36..30cb0f2c4d53a7ad473812810c4f5017
@NotNull
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index 65060c06c1e5521656bd88547b8d0df5975c1d29..7c33c9489e0f3c4429e9bc30d87a3f4c29ca010f 100644
index 5dd7ce5c008c852dbeb0474a70e9357230406318..178e91f3ad918c1a5600d6e9a14a21d478f7e1df 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -2304,5 +2304,12 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi