Finish converting most of the undeprecated api to jspecify
This commit is contained in:
parent
ba3c29b92e
commit
e7e1ab56ca
45 changed files with 1046 additions and 982 deletions
|
@ -96,23 +96,24 @@ index 0000000000000000000000000000000000000000..f29e76a6b66ddfec12ddf8db6dcb2df6
|
|||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/registry/RegistryAccess.java b/src/main/java/io/papermc/paper/registry/RegistryAccess.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..86ab67ff5023bf6adea80b02648b6f67476e30e5
|
||||
index 0000000000000000000000000000000000000000..00a3a4a196808b4b5c84ecccbfb1ea0e3825146a
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/registry/RegistryAccess.java
|
||||
@@ -0,0 +1,49 @@
|
||||
@@ -0,0 +1,50 @@
|
||||
+package io.papermc.paper.registry;
|
||||
+
|
||||
+import org.bukkit.Keyed;
|
||||
+import org.bukkit.Registry;
|
||||
+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;
|
||||
+
|
||||
+/**
|
||||
+ * Used for accessing different {@link Registry} instances
|
||||
+ * by a {@link RegistryKey}. Get the main instance of {@link RegistryAccess}
|
||||
+ * with {@link RegistryAccess#registryAccess()}.
|
||||
+ */
|
||||
+@NullMarked
|
||||
+@ApiStatus.NonExtendable
|
||||
+public interface RegistryAccess {
|
||||
+
|
||||
|
@ -121,7 +122,7 @@ index 0000000000000000000000000000000000000000..86ab67ff5023bf6adea80b02648b6f67
|
|||
+ *
|
||||
+ * @return the RegistryAccess instance
|
||||
+ */
|
||||
+ static @NotNull RegistryAccess registryAccess() {
|
||||
+ static RegistryAccess registryAccess() {
|
||||
+ return RegistryAccessHolder.INSTANCE.orElseThrow(() -> new IllegalStateException("No RegistryAccess implementation found"));
|
||||
+ }
|
||||
+
|
||||
|
@ -134,7 +135,7 @@ index 0000000000000000000000000000000000000000..86ab67ff5023bf6adea80b02648b6f67
|
|||
+ * @deprecated use {@link #getRegistry(RegistryKey)} with keys from {@link RegistryKey}
|
||||
+ */
|
||||
+ @Deprecated(since = "1.20.6", forRemoval = true)
|
||||
+ <T extends Keyed> @Nullable Registry<T> getRegistry(@NotNull Class<T> type);
|
||||
+ <T extends Keyed> @Nullable Registry<T> getRegistry(Class<T> type);
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the registry with the specified key.
|
||||
|
@ -147,7 +148,7 @@ index 0000000000000000000000000000000000000000..86ab67ff5023bf6adea80b02648b6f67
|
|||
+ */
|
||||
+ // Future note: We should have no trouble removing this generic qualifier when
|
||||
+ // registry types no longer have to be "keyed" as it shouldn't break ABI or API.
|
||||
+ <T extends Keyed> @NotNull Registry<T> getRegistry(@NotNull RegistryKey<T> registryKey);
|
||||
+ <T extends Keyed> Registry<T> getRegistry(RegistryKey<T> registryKey);
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/registry/RegistryAccessHolder.java b/src/main/java/io/papermc/paper/registry/RegistryAccessHolder.java
|
||||
new file mode 100644
|
||||
|
@ -168,16 +169,16 @@ index 0000000000000000000000000000000000000000..b89e19c070f97c9662f1e16309446494
|
|||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/registry/RegistryKeyImpl.java b/src/main/java/io/papermc/paper/registry/RegistryKeyImpl.java
|
||||
index 791813220b2504214b1adecc69093cd600fb0f8c..47fe5b0d5d031110c27210a0a256c260b35d9ba1 100644
|
||||
index 80e3e64f47ac55a4978c9e5b430e2f2d1c871d1b..ac68dfce754dc7e014bb31bba32d9b246ffd411c 100644
|
||||
--- a/src/main/java/io/papermc/paper/registry/RegistryKeyImpl.java
|
||||
+++ b/src/main/java/io/papermc/paper/registry/RegistryKeyImpl.java
|
||||
@@ -10,6 +10,17 @@ record RegistryKeyImpl<T>(@NotNull Key key) implements RegistryKey<T> {
|
||||
@@ -12,6 +12,17 @@ record RegistryKeyImpl<T>(Key key) implements RegistryKey<T> {
|
||||
|
||||
static final Set<RegistryKey<?>> REGISTRY_KEYS = Sets.newIdentityHashSet();
|
||||
|
||||
+ // override equals and hashCode to this can be used to simulate an "identity" hashmap
|
||||
+ @Override
|
||||
+ public boolean equals(final Object obj) {
|
||||
+ public boolean equals(final @Nullable Object obj) {
|
||||
+ return obj == this;
|
||||
+ }
|
||||
+
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue