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

@@ -16,14 +16,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import java.util.Set;
+import net.kyori.adventure.text.Component;
+import org.bukkit.FeatureFlag;
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.jetbrains.annotations.Contract;
+import org.jetbrains.annotations.Unmodifiable;
+import org.jspecify.annotations.NullMarked;
+
+/**
+ * This is a snapshot of a datapack on the server. It
+ * won't be updated as datapacks are updated.
+ */
+@NullMarked
+public interface Datapack {
+
+ /**
@@ -32,21 +33,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @return the name of the pack
+ */
+ @Contract(pure = true)
+ @NonNull String getName();
+ String getName();
+
+ /**
+ * Gets the title component of this datapack.
+ *
+ * @return the title
+ */
+ @NonNull Component getTitle();
+ Component getTitle();
+
+ /**
+ * Gets the description component of this datapack.
+ *
+ * @return the description
+ */
+ @NonNull Component getDescription();
+ Component getDescription();
+
+ /**
+ * Gets if this datapack is required to be enabled.
@@ -60,14 +61,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ *
+ * @return the compatibility of the pack
+ */
+ @NonNull Compatibility getCompatibility();
+ Compatibility getCompatibility();
+
+ /**
+ * Gets the set of required features for this datapack.
+ *
+ * @return the set of required features
+ */
+ @NonNull @Unmodifiable Set<FeatureFlag> getRequiredFeatures();
+ @Unmodifiable Set<FeatureFlag> getRequiredFeatures();
+
+ /**
+ * Gets the enabled state of this pack.
@@ -91,7 +92,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ *
+ * @return the pack source
+ */
+ @NonNull DatapackSource getSource();
+ DatapackSource getSource();
+
+ /**
+ * Computes the component vanilla Minecraft uses
@@ -101,7 +102,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @return a new component
+ */
+ @Contract(pure = true, value = "-> new")
+ @NonNull Component computeDisplayName();
+ Component computeDisplayName();
+
+ enum Compatibility {
+ TOO_OLD,
@@ -117,12 +118,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@
+package io.papermc.paper.datapack;
+
+import org.checkerframework.checker.nullness.qual.NonNull;
+
+import java.util.Collection;
+import org.checkerframework.checker.nullness.qual.Nullable;
+import org.jetbrains.annotations.Unmodifiable;
+import org.jspecify.annotations.NullMarked;
+import org.jspecify.annotations.Nullable;
+
+@NullMarked
+public interface DatapackManager {
+
+ /**
@@ -140,7 +141,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param name the name/id of the datapack
+ * @return the datapack, or null if not found
+ */
+ @Nullable Datapack getPack(@NonNull String name);
+ @Nullable Datapack getPack(String name);
+
+ /**
+ * Gets the available datapacks. May require calling {@link #refreshPacks()} before
@@ -148,7 +149,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ *
+ * @return all the packs known to the server
+ */
+ @NonNull @Unmodifiable Collection<Datapack> getPacks();
+ @Unmodifiable Collection<Datapack> getPacks();
+
+ /**
+ * Gets the enabled datapacks. May require calling {@link #refreshPacks()} before
@@ -156,7 +157,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ *
+ * @return all the packs which are currently enabled
+ */
+ @NonNull @Unmodifiable Collection<Datapack> getEnabledPacks();
+ @Unmodifiable Collection<Datapack> getEnabledPacks();
+}
diff --git a/src/main/java/io/papermc/paper/datapack/DatapackSource.java b/src/main/java/io/papermc/paper/datapack/DatapackSource.java
new file mode 100644
@@ -166,9 +167,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@
+package io.papermc.paper.datapack;
+
+import org.jspecify.annotations.NullMarked;
+
+/**
+ * Source of a datapack.
+ */
+@NullMarked
+public sealed interface DatapackSource permits DatapackSourceImpl {
+
+ DatapackSource DEFAULT = create("default");
@@ -190,8 +194,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+package io.papermc.paper.datapack;
+
+import org.jetbrains.annotations.ApiStatus;
+import org.jspecify.annotations.NullMarked;
+
+@ApiStatus.Internal
+@NullMarked
+record DatapackSourceImpl(String name) implements DatapackSource {
+
+ @Override