mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-03 21:52:05 -07:00
Finish converting most of the undeprecated api to jspecify
This commit is contained in:
@@ -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);
|
||||
+ }
|
||||
+}
|
||||
|
Reference in New Issue
Block a user