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 29a25df60e
commit 0adf5876db
45 changed files with 782 additions and 718 deletions

View File

@@ -14,12 +14,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+
+import org.bukkit.entity.Player;
+import org.jetbrains.annotations.Contract;
+import org.jetbrains.annotations.NotNull;
+import org.jspecify.annotations.NullMarked;
+
+/**
+ * Context for computing itemstack tooltips via
+ * {@link org.bukkit.inventory.ItemStack#computeTooltipLines(TooltipContext, Player)}
+ */
+@NullMarked
+public interface TooltipContext {
+
+ /**
@@ -31,7 +32,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @return a new context
+ */
+ @Contract("_, _ -> new")
+ static @NotNull TooltipContext create(final boolean advanced, final boolean creative) {
+ static TooltipContext create(final boolean advanced, final boolean creative) {
+ return new TooltipContextImpl(advanced, creative);
+ }
+
@@ -41,7 +42,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @return a new context
+ */
+ @Contract("-> new")
+ static @NotNull TooltipContext create() {
+ static TooltipContext create() {
+ return new TooltipContextImpl(false, false);
+ }
+
@@ -74,7 +75,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @return a new context
+ */
+ @Contract("-> new")
+ @NotNull TooltipContext asAdvanced();
+ TooltipContext asAdvanced();
+
+ /**
+ * Returns a new context with {@link #isCreative()}
@@ -83,7 +84,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @return a new context
+ */
+ @Contract("-> new")
+ @NotNull TooltipContext asCreative();
+ TooltipContext asCreative();
+}
diff --git a/src/main/java/io/papermc/paper/inventory/tooltip/TooltipContextImpl.java b/src/main/java/io/papermc/paper/inventory/tooltip/TooltipContextImpl.java
new file mode 100644
@@ -93,17 +94,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@
+package io.papermc.paper.inventory.tooltip;
+
+import org.jetbrains.annotations.NotNull;
+import org.jspecify.annotations.NullMarked;
+
+@NullMarked
+record TooltipContextImpl(boolean isAdvanced, boolean isCreative) implements TooltipContext {
+
+ @Override
+ public @NotNull TooltipContext asCreative() {
+ public TooltipContext asCreative() {
+ return new TooltipContextImpl(this.isAdvanced, true);
+ }
+
+ @Override
+ public @NotNull TooltipContext asAdvanced() {
+ public TooltipContext asAdvanced() {
+ return new TooltipContextImpl(true, this.isCreative);
+ }
+}