mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-18 12:48:53 +01:00
[ci skip] use more jspecify in server
This commit is contained in:
parent
cf956ac8d2
commit
5b53cb404d
4 changed files with 148 additions and 162 deletions
|
@ -12,10 +12,10 @@ public net.minecraft.server.RegistryLayer STATIC_ACCESS
|
||||||
|
|
||||||
diff --git a/src/main/java/io/papermc/paper/registry/PaperRegistries.java b/src/main/java/io/papermc/paper/registry/PaperRegistries.java
|
diff --git a/src/main/java/io/papermc/paper/registry/PaperRegistries.java b/src/main/java/io/papermc/paper/registry/PaperRegistries.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..2f22f46f80b80be43a2cc1cd8afb51f4d1fd0e91
|
index 0000000000000000000000000000000000000000..cd8a6a4c2a63029f8f859765088c227bbd456813
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/io/papermc/paper/registry/PaperRegistries.java
|
+++ b/src/main/java/io/papermc/paper/registry/PaperRegistries.java
|
||||||
@@ -0,0 +1,157 @@
|
@@ -0,0 +1,154 @@
|
||||||
+package io.papermc.paper.registry;
|
+package io.papermc.paper.registry;
|
||||||
+
|
+
|
||||||
+import com.google.common.base.Preconditions;
|
+import com.google.common.base.Preconditions;
|
||||||
|
@ -81,14 +81,11 @@ index 0000000000000000000000000000000000000000..2f22f46f80b80be43a2cc1cd8afb51f4
|
||||||
+import org.bukkit.inventory.meta.trim.TrimPattern;
|
+import org.bukkit.inventory.meta.trim.TrimPattern;
|
||||||
+import org.bukkit.map.MapCursor;
|
+import org.bukkit.map.MapCursor;
|
||||||
+import org.bukkit.potion.PotionEffectType;
|
+import org.bukkit.potion.PotionEffectType;
|
||||||
+import org.checkerframework.checker.nullness.qual.NonNull;
|
+import org.jspecify.annotations.Nullable;
|
||||||
+import org.checkerframework.checker.nullness.qual.Nullable;
|
|
||||||
+import org.checkerframework.framework.qual.DefaultQualifier;
|
|
||||||
+
|
+
|
||||||
+import static io.papermc.paper.registry.entry.RegistryEntry.apiOnly;
|
+import static io.papermc.paper.registry.entry.RegistryEntry.apiOnly;
|
||||||
+import static io.papermc.paper.registry.entry.RegistryEntry.entry;
|
+import static io.papermc.paper.registry.entry.RegistryEntry.entry;
|
||||||
+
|
+
|
||||||
+@DefaultQualifier(NonNull.class)
|
|
||||||
+public final class PaperRegistries {
|
+public final class PaperRegistries {
|
||||||
+
|
+
|
||||||
+ static final List<RegistryEntry<?, ?>> REGISTRY_ENTRIES;
|
+ static final List<RegistryEntry<?, ?>> REGISTRY_ENTRIES;
|
||||||
|
@ -175,10 +172,10 @@ index 0000000000000000000000000000000000000000..2f22f46f80b80be43a2cc1cd8afb51f4
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/io/papermc/paper/registry/PaperRegistryAccess.java b/src/main/java/io/papermc/paper/registry/PaperRegistryAccess.java
|
diff --git a/src/main/java/io/papermc/paper/registry/PaperRegistryAccess.java b/src/main/java/io/papermc/paper/registry/PaperRegistryAccess.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..35b6a7c5bac9640332a833bd3627f2bcb1bbf2f3
|
index 0000000000000000000000000000000000000000..4bf7915867dbe762ef0b070d67d5f7b7d1ee4f03
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/io/papermc/paper/registry/PaperRegistryAccess.java
|
+++ b/src/main/java/io/papermc/paper/registry/PaperRegistryAccess.java
|
||||||
@@ -0,0 +1,127 @@
|
@@ -0,0 +1,122 @@
|
||||||
+package io.papermc.paper.registry;
|
+package io.papermc.paper.registry;
|
||||||
+
|
+
|
||||||
+import io.papermc.paper.registry.entry.ApiRegistryEntry;
|
+import io.papermc.paper.registry.entry.ApiRegistryEntry;
|
||||||
|
@ -194,14 +191,9 @@ index 0000000000000000000000000000000000000000..35b6a7c5bac9640332a833bd3627f2bc
|
||||||
+import net.minecraft.resources.ResourceKey;
|
+import net.minecraft.resources.ResourceKey;
|
||||||
+import org.bukkit.Keyed;
|
+import org.bukkit.Keyed;
|
||||||
+import org.bukkit.Registry;
|
+import org.bukkit.Registry;
|
||||||
+import org.checkerframework.checker.nullness.qual.NonNull;
|
|
||||||
+import org.checkerframework.checker.nullness.qual.Nullable;
|
|
||||||
+import org.checkerframework.framework.qual.DefaultQualifier;
|
|
||||||
+import org.jetbrains.annotations.VisibleForTesting;
|
+import org.jetbrains.annotations.VisibleForTesting;
|
||||||
|
+import org.jspecify.annotations.Nullable;
|
||||||
+
|
+
|
||||||
+import static java.util.Objects.requireNonNull;
|
|
||||||
+
|
|
||||||
+@DefaultQualifier(NonNull.class)
|
|
||||||
+public class PaperRegistryAccess implements RegistryAccess {
|
+public class PaperRegistryAccess implements RegistryAccess {
|
||||||
+
|
+
|
||||||
+ // We store the API registries in a memoized supplier, so they can be created on-demand.
|
+ // We store the API registries in a memoized supplier, so they can be created on-demand.
|
||||||
|
@ -224,14 +216,14 @@ index 0000000000000000000000000000000000000000..35b6a7c5bac9640332a833bd3627f2bc
|
||||||
+ @Deprecated(forRemoval = true)
|
+ @Deprecated(forRemoval = true)
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public <T extends Keyed> @Nullable Registry<T> getRegistry(final Class<T> type) {
|
+ public <T extends Keyed> @Nullable Registry<T> getRegistry(final Class<T> type) {
|
||||||
+ final @Nullable RegistryKey<T> registryKey = byType(type);
|
+ final RegistryKey<T> registryKey = byType(type);
|
||||||
+ // If our mapping from Class -> RegistryKey did not contain the passed type it was either a completely invalid type or a registry
|
+ // If our mapping from Class -> RegistryKey did not contain the passed type it was either a completely invalid type or a registry
|
||||||
+ // that merely exists as a SimpleRegistry in the org.bukkit.Registry type. We cannot return a registry for these, return null
|
+ // that merely exists as a SimpleRegistry in the org.bukkit.Registry type. We cannot return a registry for these, return null
|
||||||
+ // as per method contract in Bukkit#getRegistry.
|
+ // as per method contract in Bukkit#getRegistry.
|
||||||
+ if (registryKey == null) return null;
|
+ if (registryKey == null) return null;
|
||||||
+
|
+
|
||||||
+ final @Nullable RegistryEntry<?, T> entry = PaperRegistries.getEntry(registryKey);
|
+ final RegistryEntry<?, T> entry = PaperRegistries.getEntry(registryKey);
|
||||||
+ final @Nullable RegistryHolder<T> registry = (RegistryHolder<T>) this.registries.get(registryKey);
|
+ final RegistryHolder<T> registry = (RegistryHolder<T>) this.registries.get(registryKey);
|
||||||
+ if (registry != null) {
|
+ if (registry != null) {
|
||||||
+ // if the registry exists, return right away. Since this is the "legacy" method, we return DelayedRegistry
|
+ // if the registry exists, return right away. Since this is the "legacy" method, we return DelayedRegistry
|
||||||
+ // for the non-builtin Registry instances stored as fields in Registry.
|
+ // for the non-builtin Registry instances stored as fields in Registry.
|
||||||
|
@ -352,10 +344,10 @@ index 0000000000000000000000000000000000000000..6d134ace042758da722960cbcb48e525
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/io/papermc/paper/registry/RegistryHolder.java b/src/main/java/io/papermc/paper/registry/RegistryHolder.java
|
diff --git a/src/main/java/io/papermc/paper/registry/RegistryHolder.java b/src/main/java/io/papermc/paper/registry/RegistryHolder.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..a31bdd9f02fe75a87fceb2ebe8c36b3232a561cc
|
index 0000000000000000000000000000000000000000..1b52d4bc868e1e5f84c8416301e193bb9cd315b2
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/io/papermc/paper/registry/RegistryHolder.java
|
+++ b/src/main/java/io/papermc/paper/registry/RegistryHolder.java
|
||||||
@@ -0,0 +1,47 @@
|
@@ -0,0 +1,44 @@
|
||||||
+package io.papermc.paper.registry;
|
+package io.papermc.paper.registry;
|
||||||
+
|
+
|
||||||
+import com.google.common.base.Suppliers;
|
+import com.google.common.base.Suppliers;
|
||||||
|
@ -364,10 +356,7 @@ index 0000000000000000000000000000000000000000..a31bdd9f02fe75a87fceb2ebe8c36b32
|
||||||
+import java.util.function.Supplier;
|
+import java.util.function.Supplier;
|
||||||
+import org.bukkit.Keyed;
|
+import org.bukkit.Keyed;
|
||||||
+import org.bukkit.Registry;
|
+import org.bukkit.Registry;
|
||||||
+import org.checkerframework.checker.nullness.qual.NonNull;
|
|
||||||
+import org.checkerframework.framework.qual.DefaultQualifier;
|
|
||||||
+
|
+
|
||||||
+@DefaultQualifier(NonNull.class)
|
|
||||||
+public interface RegistryHolder<B extends Keyed> {
|
+public interface RegistryHolder<B extends Keyed> {
|
||||||
+
|
+
|
||||||
+ Registry<B> get();
|
+ Registry<B> get();
|
||||||
|
@ -471,10 +460,10 @@ index 0000000000000000000000000000000000000000..ceb217dbbb84e8bd51365dd47bf91971
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/io/papermc/paper/registry/entry/CraftRegistryEntry.java b/src/main/java/io/papermc/paper/registry/entry/CraftRegistryEntry.java
|
diff --git a/src/main/java/io/papermc/paper/registry/entry/CraftRegistryEntry.java b/src/main/java/io/papermc/paper/registry/entry/CraftRegistryEntry.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..9bb4aa926978f117901c9f99c45a6862a1d5ce30
|
index 0000000000000000000000000000000000000000..45cbc425da64f0bd3290600869ad425d9e6e912b
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/io/papermc/paper/registry/entry/CraftRegistryEntry.java
|
+++ b/src/main/java/io/papermc/paper/registry/entry/CraftRegistryEntry.java
|
||||||
@@ -0,0 +1,51 @@
|
@@ -0,0 +1,48 @@
|
||||||
+package io.papermc.paper.registry.entry;
|
+package io.papermc.paper.registry.entry;
|
||||||
+
|
+
|
||||||
+import com.google.common.base.Preconditions;
|
+import com.google.common.base.Preconditions;
|
||||||
|
@ -487,10 +476,7 @@ index 0000000000000000000000000000000000000000..9bb4aa926978f117901c9f99c45a6862
|
||||||
+import org.bukkit.NamespacedKey;
|
+import org.bukkit.NamespacedKey;
|
||||||
+import org.bukkit.craftbukkit.CraftRegistry;
|
+import org.bukkit.craftbukkit.CraftRegistry;
|
||||||
+import org.bukkit.craftbukkit.util.ApiVersion;
|
+import org.bukkit.craftbukkit.util.ApiVersion;
|
||||||
+import org.checkerframework.checker.nullness.qual.NonNull;
|
|
||||||
+import org.checkerframework.framework.qual.DefaultQualifier;
|
|
||||||
+
|
+
|
||||||
+@DefaultQualifier(NonNull.class)
|
|
||||||
+public class CraftRegistryEntry<M, B extends Keyed> extends BaseRegistryEntry<M, B> { // TODO remove Keyed
|
+public class CraftRegistryEntry<M, B extends Keyed> extends BaseRegistryEntry<M, B> { // TODO remove Keyed
|
||||||
+
|
+
|
||||||
+ private static final BiFunction<NamespacedKey, ApiVersion, NamespacedKey> EMPTY = (namespacedKey, apiVersion) -> namespacedKey;
|
+ private static final BiFunction<NamespacedKey, ApiVersion, NamespacedKey> EMPTY = (namespacedKey, apiVersion) -> namespacedKey;
|
||||||
|
@ -528,10 +514,10 @@ index 0000000000000000000000000000000000000000..9bb4aa926978f117901c9f99c45a6862
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/io/papermc/paper/registry/entry/RegistryEntry.java b/src/main/java/io/papermc/paper/registry/entry/RegistryEntry.java
|
diff --git a/src/main/java/io/papermc/paper/registry/entry/RegistryEntry.java b/src/main/java/io/papermc/paper/registry/entry/RegistryEntry.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..15991bf13894d850f360a520d1815711d25973ec
|
index 0000000000000000000000000000000000000000..2889d87f0989ae5744cd4c1e57240830aa574155
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/io/papermc/paper/registry/entry/RegistryEntry.java
|
+++ b/src/main/java/io/papermc/paper/registry/entry/RegistryEntry.java
|
||||||
@@ -0,0 +1,51 @@
|
@@ -0,0 +1,48 @@
|
||||||
+package io.papermc.paper.registry.entry;
|
+package io.papermc.paper.registry.entry;
|
||||||
+
|
+
|
||||||
+import io.papermc.paper.registry.RegistryHolder;
|
+import io.papermc.paper.registry.RegistryHolder;
|
||||||
|
@ -544,10 +530,7 @@ index 0000000000000000000000000000000000000000..15991bf13894d850f360a520d1815711
|
||||||
+import org.bukkit.Keyed;
|
+import org.bukkit.Keyed;
|
||||||
+import org.bukkit.NamespacedKey;
|
+import org.bukkit.NamespacedKey;
|
||||||
+import org.bukkit.craftbukkit.util.ApiVersion;
|
+import org.bukkit.craftbukkit.util.ApiVersion;
|
||||||
+import org.checkerframework.checker.nullness.qual.NonNull;
|
|
||||||
+import org.checkerframework.framework.qual.DefaultQualifier;
|
|
||||||
+
|
+
|
||||||
+@DefaultQualifier(NonNull.class)
|
|
||||||
+public interface RegistryEntry<M, B extends Keyed> extends RegistryEntryInfo<M, B> { // TODO remove Keyed
|
+public interface RegistryEntry<M, B extends Keyed> extends RegistryEntryInfo<M, B> { // TODO remove Keyed
|
||||||
+
|
+
|
||||||
+ RegistryHolder<B> createRegistryHolder(Registry<M> nmsRegistry);
|
+ RegistryHolder<B> createRegistryHolder(Registry<M> nmsRegistry);
|
||||||
|
@ -603,34 +586,29 @@ index 0000000000000000000000000000000000000000..0ae855e80fc9fddfc1feb33c7a974820
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/io/papermc/paper/registry/entry/package-info.java b/src/main/java/io/papermc/paper/registry/entry/package-info.java
|
diff --git a/src/main/java/io/papermc/paper/registry/entry/package-info.java b/src/main/java/io/papermc/paper/registry/entry/package-info.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..e4c94d6860e0f5b643cde1ded20b5503c02a4866
|
index 0000000000000000000000000000000000000000..f04e93aa5ca41ce1cf3b152f827911fdf0dd10cb
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/io/papermc/paper/registry/entry/package-info.java
|
+++ b/src/main/java/io/papermc/paper/registry/entry/package-info.java
|
||||||
@@ -0,0 +1,5 @@
|
@@ -0,0 +1,4 @@
|
||||||
+@DefaultQualifier(NonNull.class)
|
+@NullMarked
|
||||||
+package io.papermc.paper.registry.entry;
|
+package io.papermc.paper.registry.entry;
|
||||||
+
|
+
|
||||||
+import org.checkerframework.checker.nullness.qual.NonNull;
|
+import org.jspecify.annotations.NullMarked;
|
||||||
+import org.checkerframework.framework.qual.DefaultQualifier;
|
|
||||||
diff --git a/src/main/java/io/papermc/paper/registry/legacy/DelayedRegistry.java b/src/main/java/io/papermc/paper/registry/legacy/DelayedRegistry.java
|
diff --git a/src/main/java/io/papermc/paper/registry/legacy/DelayedRegistry.java b/src/main/java/io/papermc/paper/registry/legacy/DelayedRegistry.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..9400fed345344a0a8e4fb301cca6a1867adf625b
|
index 0000000000000000000000000000000000000000..ca829b162d4369f845e59b62bb8779fd83fe2ef3
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/io/papermc/paper/registry/legacy/DelayedRegistry.java
|
+++ b/src/main/java/io/papermc/paper/registry/legacy/DelayedRegistry.java
|
||||||
@@ -0,0 +1,61 @@
|
@@ -0,0 +1,57 @@
|
||||||
+package io.papermc.paper.registry.legacy;
|
+package io.papermc.paper.registry.legacy;
|
||||||
+
|
+
|
||||||
+import java.util.Iterator;
|
+import java.util.Iterator;
|
||||||
+import java.util.function.Supplier;
|
+import java.util.function.Supplier;
|
||||||
+import java.util.stream.Stream;
|
+import java.util.stream.Stream;
|
||||||
+import net.kyori.adventure.key.Key;
|
|
||||||
+import org.bukkit.Keyed;
|
+import org.bukkit.Keyed;
|
||||||
+import org.bukkit.NamespacedKey;
|
+import org.bukkit.NamespacedKey;
|
||||||
+import org.bukkit.Registry;
|
+import org.bukkit.Registry;
|
||||||
+import org.bukkit.craftbukkit.CraftRegistry;
|
+import org.jspecify.annotations.Nullable;
|
||||||
+import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|
||||||
+import org.checkerframework.checker.nullness.qual.Nullable;
|
|
||||||
+import org.jetbrains.annotations.NotNull;
|
|
||||||
+
|
+
|
||||||
+/**
|
+/**
|
||||||
+ * This is to support the now-deprecated fields in {@link Registry} for
|
+ * This is to support the now-deprecated fields in {@link Registry} for
|
||||||
|
@ -638,7 +616,7 @@ index 0000000000000000000000000000000000000000..9400fed345344a0a8e4fb301cca6a186
|
||||||
+ */
|
+ */
|
||||||
+public final class DelayedRegistry<T extends Keyed, R extends Registry<T>> implements Registry<T> {
|
+public final class DelayedRegistry<T extends Keyed, R extends Registry<T>> implements Registry<T> {
|
||||||
+
|
+
|
||||||
+ private @MonotonicNonNull Supplier<? extends R> delegate;
|
+ private @Nullable Supplier<? extends R> delegate;
|
||||||
+
|
+
|
||||||
+ public void load(final Supplier<? extends R> registry) {
|
+ public void load(final Supplier<? extends R> registry) {
|
||||||
+ if (this.delegate != null) {
|
+ if (this.delegate != null) {
|
||||||
|
@ -660,7 +638,7 @@ index 0000000000000000000000000000000000000000..9400fed345344a0a8e4fb301cca6a186
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public @NotNull T getOrThrow(@NotNull final NamespacedKey key) {
|
+ public T getOrThrow(final NamespacedKey key) {
|
||||||
+ return this.delegate().getOrThrow(key);
|
+ return this.delegate().getOrThrow(key);
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
|
@ -675,7 +653,7 @@ index 0000000000000000000000000000000000000000..9400fed345344a0a8e4fb301cca6a186
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public NamespacedKey getKey(final T value) {
|
+ public @Nullable NamespacedKey getKey(final T value) {
|
||||||
+ return this.delegate().getKey(value);
|
+ return this.delegate().getKey(value);
|
||||||
+ }
|
+ }
|
||||||
+}
|
+}
|
||||||
|
@ -752,15 +730,24 @@ index 0000000000000000000000000000000000000000..83870816cd4c54f94a3c603ffe41c11e
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/io/papermc/paper/registry/legacy/package-info.java b/src/main/java/io/papermc/paper/registry/legacy/package-info.java
|
diff --git a/src/main/java/io/papermc/paper/registry/legacy/package-info.java b/src/main/java/io/papermc/paper/registry/legacy/package-info.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..4396982af55872fafbfeaf8161ad6f392726c773
|
index 0000000000000000000000000000000000000000..063a8d7a7313d5d685d51df54d9502d72266da49
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/io/papermc/paper/registry/legacy/package-info.java
|
+++ b/src/main/java/io/papermc/paper/registry/legacy/package-info.java
|
||||||
@@ -0,0 +1,5 @@
|
@@ -0,0 +1,4 @@
|
||||||
+@DefaultQualifier(NonNull.class)
|
+@NullMarked
|
||||||
+package io.papermc.paper.registry.legacy;
|
+package io.papermc.paper.registry.legacy;
|
||||||
+
|
+
|
||||||
+import org.checkerframework.checker.nullness.qual.NonNull;
|
+import org.jspecify.annotations.NullMarked;
|
||||||
+import org.checkerframework.framework.qual.DefaultQualifier;
|
diff --git a/src/main/java/io/papermc/paper/registry/package-info.java b/src/main/java/io/papermc/paper/registry/package-info.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..ca07ef31161e938d48214992b34cafb712a51513
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/io/papermc/paper/registry/package-info.java
|
||||||
|
@@ -0,0 +1,4 @@
|
||||||
|
+@NullMarked
|
||||||
|
+package io.papermc.paper.registry;
|
||||||
|
+
|
||||||
|
+import org.jspecify.annotations.NullMarked;
|
||||||
diff --git a/src/main/java/net/minecraft/core/registries/BuiltInRegistries.java b/src/main/java/net/minecraft/core/registries/BuiltInRegistries.java
|
diff --git a/src/main/java/net/minecraft/core/registries/BuiltInRegistries.java b/src/main/java/net/minecraft/core/registries/BuiltInRegistries.java
|
||||||
index 3f72e30b57fb2a4231e22a2234729408c1240af4..4638ba98dbbdb0f880337347be85a6e0fbed2191 100644
|
index 3f72e30b57fb2a4231e22a2234729408c1240af4..4638ba98dbbdb0f880337347be85a6e0fbed2191 100644
|
||||||
--- a/src/main/java/net/minecraft/core/registries/BuiltInRegistries.java
|
--- a/src/main/java/net/minecraft/core/registries/BuiltInRegistries.java
|
||||||
|
|
|
@ -11,7 +11,7 @@ public net.minecraft.resources.RegistryOps lookupProvider
|
||||||
public net.minecraft.resources.RegistryOps$HolderLookupAdapter
|
public net.minecraft.resources.RegistryOps$HolderLookupAdapter
|
||||||
|
|
||||||
diff --git a/src/main/java/io/papermc/paper/registry/PaperRegistries.java b/src/main/java/io/papermc/paper/registry/PaperRegistries.java
|
diff --git a/src/main/java/io/papermc/paper/registry/PaperRegistries.java b/src/main/java/io/papermc/paper/registry/PaperRegistries.java
|
||||||
index 2f22f46f80b80be43a2cc1cd8afb51f4d1fd0e91..3ec2aa5da045b62809afd2c13fc9ae74189dbdad 100644
|
index cd8a6a4c2a63029f8f859765088c227bbd456813..86c9f87cdb41c0d1ccc2a61b501f969cfaae47bc 100644
|
||||||
--- a/src/main/java/io/papermc/paper/registry/PaperRegistries.java
|
--- a/src/main/java/io/papermc/paper/registry/PaperRegistries.java
|
||||||
+++ b/src/main/java/io/papermc/paper/registry/PaperRegistries.java
|
+++ b/src/main/java/io/papermc/paper/registry/PaperRegistries.java
|
||||||
@@ -3,6 +3,7 @@ package io.papermc.paper.registry;
|
@@ -3,6 +3,7 @@ package io.papermc.paper.registry;
|
||||||
|
@ -22,15 +22,15 @@ index 2f22f46f80b80be43a2cc1cd8afb51f4d1fd0e91..3ec2aa5da045b62809afd2c13fc9ae74
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.IdentityHashMap;
|
import java.util.IdentityHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -69,6 +70,7 @@ import org.checkerframework.framework.qual.DefaultQualifier;
|
@@ -67,6 +68,7 @@ import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import static io.papermc.paper.registry.entry.RegistryEntry.apiOnly;
|
import static io.papermc.paper.registry.entry.RegistryEntry.apiOnly;
|
||||||
import static io.papermc.paper.registry.entry.RegistryEntry.entry;
|
import static io.papermc.paper.registry.entry.RegistryEntry.entry;
|
||||||
+import static io.papermc.paper.registry.entry.RegistryEntry.writable;
|
+import static io.papermc.paper.registry.entry.RegistryEntry.writable;
|
||||||
|
|
||||||
@DefaultQualifier(NonNull.class)
|
|
||||||
public final class PaperRegistries {
|
public final class PaperRegistries {
|
||||||
@@ -152,6 +154,15 @@ public final class PaperRegistries {
|
|
||||||
|
@@ -149,6 +151,15 @@ public final class PaperRegistries {
|
||||||
return ResourceKey.create((ResourceKey<? extends Registry<M>>) PaperRegistries.registryToNms(typedKey.registryKey()), PaperAdventure.asVanilla(typedKey.key()));
|
return ResourceKey.create((ResourceKey<? extends Registry<M>>) PaperRegistries.registryToNms(typedKey.registryKey()), PaperAdventure.asVanilla(typedKey.key()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,10 +47,10 @@ index 2f22f46f80b80be43a2cc1cd8afb51f4d1fd0e91..3ec2aa5da045b62809afd2c13fc9ae74
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
diff --git a/src/main/java/io/papermc/paper/registry/PaperRegistryAccess.java b/src/main/java/io/papermc/paper/registry/PaperRegistryAccess.java
|
diff --git a/src/main/java/io/papermc/paper/registry/PaperRegistryAccess.java b/src/main/java/io/papermc/paper/registry/PaperRegistryAccess.java
|
||||||
index 35b6a7c5bac9640332a833bd3627f2bcb1bbf2f3..1026b9c04f94ed73049b980822a2eafdbacea7fd 100644
|
index 4bf7915867dbe762ef0b070d67d5f7b7d1ee4f03..ed071ed34e16812f133102b0d66a5201a94639f2 100644
|
||||||
--- a/src/main/java/io/papermc/paper/registry/PaperRegistryAccess.java
|
--- a/src/main/java/io/papermc/paper/registry/PaperRegistryAccess.java
|
||||||
+++ b/src/main/java/io/papermc/paper/registry/PaperRegistryAccess.java
|
+++ b/src/main/java/io/papermc/paper/registry/PaperRegistryAccess.java
|
||||||
@@ -83,6 +83,14 @@ public class PaperRegistryAccess implements RegistryAccess {
|
@@ -78,6 +78,14 @@ public class PaperRegistryAccess implements RegistryAccess {
|
||||||
return possiblyUnwrap(registryHolder.get());
|
return possiblyUnwrap(registryHolder.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,15 +67,14 @@ index 35b6a7c5bac9640332a833bd3627f2bcb1bbf2f3..1026b9c04f94ed73049b980822a2eafd
|
||||||
return delayedRegistry.delegate();
|
return delayedRegistry.delegate();
|
||||||
diff --git a/src/main/java/io/papermc/paper/registry/PaperRegistryBuilder.java b/src/main/java/io/papermc/paper/registry/PaperRegistryBuilder.java
|
diff --git a/src/main/java/io/papermc/paper/registry/PaperRegistryBuilder.java b/src/main/java/io/papermc/paper/registry/PaperRegistryBuilder.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..528c6ee1739d92f766f3904acd7fc5734c93388a
|
index 0000000000000000000000000000000000000000..69e63689083207de2f409557d4a9a17f8ad7ae3e
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/io/papermc/paper/registry/PaperRegistryBuilder.java
|
+++ b/src/main/java/io/papermc/paper/registry/PaperRegistryBuilder.java
|
||||||
@@ -0,0 +1,26 @@
|
@@ -0,0 +1,25 @@
|
||||||
+package io.papermc.paper.registry;
|
+package io.papermc.paper.registry;
|
||||||
+
|
+
|
||||||
+import io.papermc.paper.registry.data.util.Conversions;
|
+import io.papermc.paper.registry.data.util.Conversions;
|
||||||
+import net.minecraft.resources.RegistryOps;
|
+import org.jspecify.annotations.Nullable;
|
||||||
+import org.checkerframework.checker.nullness.qual.Nullable;
|
|
||||||
+
|
+
|
||||||
+public interface PaperRegistryBuilder<M, T> extends RegistryBuilder<T> {
|
+public interface PaperRegistryBuilder<M, T> extends RegistryBuilder<T> {
|
||||||
+
|
+
|
||||||
|
@ -99,7 +98,7 @@ index 0000000000000000000000000000000000000000..528c6ee1739d92f766f3904acd7fc573
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/io/papermc/paper/registry/PaperRegistryListenerManager.java b/src/main/java/io/papermc/paper/registry/PaperRegistryListenerManager.java
|
diff --git a/src/main/java/io/papermc/paper/registry/PaperRegistryListenerManager.java b/src/main/java/io/papermc/paper/registry/PaperRegistryListenerManager.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..69e946173407eb05b18a2b19b0d45cbb3213570b
|
index 0000000000000000000000000000000000000000..60d9b806a09bb103e36ce1f932a5a34ef408770a
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/io/papermc/paper/registry/PaperRegistryListenerManager.java
|
+++ b/src/main/java/io/papermc/paper/registry/PaperRegistryListenerManager.java
|
||||||
@@ -0,0 +1,183 @@
|
@@ -0,0 +1,183 @@
|
||||||
|
@ -133,8 +132,8 @@ index 0000000000000000000000000000000000000000..69e946173407eb05b18a2b19b0d45cbb
|
||||||
+import net.minecraft.core.registries.BuiltInRegistries;
|
+import net.minecraft.core.registries.BuiltInRegistries;
|
||||||
+import net.minecraft.resources.ResourceKey;
|
+import net.minecraft.resources.ResourceKey;
|
||||||
+import net.minecraft.resources.ResourceLocation;
|
+import net.minecraft.resources.ResourceLocation;
|
||||||
+import org.checkerframework.checker.nullness.qual.Nullable;
|
|
||||||
+import org.intellij.lang.annotations.Subst;
|
+import org.intellij.lang.annotations.Subst;
|
||||||
|
+import org.jspecify.annotations.Nullable;
|
||||||
+
|
+
|
||||||
+public class PaperRegistryListenerManager {
|
+public class PaperRegistryListenerManager {
|
||||||
+
|
+
|
||||||
|
@ -201,7 +200,7 @@ index 0000000000000000000000000000000000000000..69e946173407eb05b18a2b19b0d45cbb
|
||||||
+ final Conversions conversions
|
+ final Conversions conversions
|
||||||
+ ) {
|
+ ) {
|
||||||
+ Preconditions.checkState(LaunchEntryPointHandler.INSTANCE.hasEntered(Entrypoint.BOOTSTRAPPER), registry.key() + " tried to run modification listeners before bootstrappers have been called"); // verify that bootstrappers have been called
|
+ Preconditions.checkState(LaunchEntryPointHandler.INSTANCE.hasEntered(Entrypoint.BOOTSTRAPPER), registry.key() + " tried to run modification listeners before bootstrappers have been called"); // verify that bootstrappers have been called
|
||||||
+ final @Nullable RegistryEntryInfo<M, T> entry = PaperRegistries.getEntry(registry.key());
|
+ final RegistryEntryInfo<M, T> entry = PaperRegistries.getEntry(registry.key());
|
||||||
+ if (!RegistryEntry.Modifiable.isModifiable(entry) || !this.valueAddEventTypes.hasHandlers(entry.apiKey())) {
|
+ if (!RegistryEntry.Modifiable.isModifiable(entry) || !this.valueAddEventTypes.hasHandlers(entry.apiKey())) {
|
||||||
+ return registerMethod.register((WritableRegistry<M>) registry, key, nms, registrationInfo);
|
+ return registerMethod.register((WritableRegistry<M>) registry, key, nms, registrationInfo);
|
||||||
+ }
|
+ }
|
||||||
|
@ -262,7 +261,7 @@ index 0000000000000000000000000000000000000000..69e946173407eb05b18a2b19b0d45cbb
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ public <M, T extends org.bukkit.Keyed, B extends PaperRegistryBuilder<M, T>> void runFreezeListeners(final ResourceKey<? extends Registry<M>> resourceKey, final Conversions conversions) {
|
+ public <M, T extends org.bukkit.Keyed, B extends PaperRegistryBuilder<M, T>> void runFreezeListeners(final ResourceKey<? extends Registry<M>> resourceKey, final Conversions conversions) {
|
||||||
+ final @Nullable RegistryEntryInfo<M, T> entry = PaperRegistries.getEntry(resourceKey);
|
+ final RegistryEntryInfo<M, T> entry = PaperRegistries.getEntry(resourceKey);
|
||||||
+ if (!RegistryEntry.Addable.isAddable(entry) || !this.freezeEventTypes.hasHandlers(entry.apiKey())) {
|
+ if (!RegistryEntry.Addable.isAddable(entry) || !this.freezeEventTypes.hasHandlers(entry.apiKey())) {
|
||||||
+ return;
|
+ return;
|
||||||
+ }
|
+ }
|
||||||
|
@ -320,7 +319,7 @@ index 6d134ace042758da722960cbcb48e52508dafd61..cc39bc68d29055ef6429f08f975412bd
|
||||||
}
|
}
|
||||||
diff --git a/src/main/java/io/papermc/paper/registry/WritableCraftRegistry.java b/src/main/java/io/papermc/paper/registry/WritableCraftRegistry.java
|
diff --git a/src/main/java/io/papermc/paper/registry/WritableCraftRegistry.java b/src/main/java/io/papermc/paper/registry/WritableCraftRegistry.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..78317c7ab42a666f19634593a8f3b696700764c8
|
index 0000000000000000000000000000000000000000..ef91352d442d9ddd666af6bde9a186ce15e5aa04
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/io/papermc/paper/registry/WritableCraftRegistry.java
|
+++ b/src/main/java/io/papermc/paper/registry/WritableCraftRegistry.java
|
||||||
@@ -0,0 +1,92 @@
|
@@ -0,0 +1,92 @@
|
||||||
|
@ -341,7 +340,7 @@ index 0000000000000000000000000000000000000000..78317c7ab42a666f19634593a8f3b696
|
||||||
+import org.bukkit.NamespacedKey;
|
+import org.bukkit.NamespacedKey;
|
||||||
+import org.bukkit.craftbukkit.CraftRegistry;
|
+import org.bukkit.craftbukkit.CraftRegistry;
|
||||||
+import org.bukkit.craftbukkit.util.ApiVersion;
|
+import org.bukkit.craftbukkit.util.ApiVersion;
|
||||||
+import org.checkerframework.checker.nullness.qual.Nullable;
|
+import org.jspecify.annotations.Nullable;
|
||||||
+
|
+
|
||||||
+public class WritableCraftRegistry<M, T extends Keyed, B extends PaperRegistryBuilder<M, T>> extends CraftRegistry<T, M> {
|
+public class WritableCraftRegistry<M, T extends Keyed, B extends PaperRegistryBuilder<M, T>> extends CraftRegistry<T, M> {
|
||||||
+
|
+
|
||||||
|
@ -418,22 +417,19 @@ index 0000000000000000000000000000000000000000..78317c7ab42a666f19634593a8f3b696
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/io/papermc/paper/registry/data/util/Conversions.java b/src/main/java/io/papermc/paper/registry/data/util/Conversions.java
|
diff --git a/src/main/java/io/papermc/paper/registry/data/util/Conversions.java b/src/main/java/io/papermc/paper/registry/data/util/Conversions.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..eda5cc7d45ef59ccc1c9c7e027c1f044f1dcc86b
|
index 0000000000000000000000000000000000000000..1e9a0143bc3b70dfc5e129a0fe849ff3e01447ab
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/io/papermc/paper/registry/data/util/Conversions.java
|
+++ b/src/main/java/io/papermc/paper/registry/data/util/Conversions.java
|
||||||
@@ -0,0 +1,36 @@
|
@@ -0,0 +1,33 @@
|
||||||
+package io.papermc.paper.registry.data.util;
|
+package io.papermc.paper.registry.data.util;
|
||||||
+
|
+
|
||||||
+import com.mojang.serialization.JavaOps;
|
+import com.mojang.serialization.JavaOps;
|
||||||
+import io.papermc.paper.adventure.WrapperAwareSerializer;
|
+import io.papermc.paper.adventure.WrapperAwareSerializer;
|
||||||
+import net.kyori.adventure.text.Component;
|
+import net.kyori.adventure.text.Component;
|
||||||
+import net.minecraft.resources.RegistryOps;
|
+import net.minecraft.resources.RegistryOps;
|
||||||
+import org.checkerframework.checker.nullness.qual.NonNull;
|
|
||||||
+import org.checkerframework.checker.nullness.qual.Nullable;
|
|
||||||
+import org.checkerframework.framework.qual.DefaultQualifier;
|
|
||||||
+import org.jetbrains.annotations.Contract;
|
+import org.jetbrains.annotations.Contract;
|
||||||
|
+import org.jspecify.annotations.Nullable;
|
||||||
+
|
+
|
||||||
+@DefaultQualifier(NonNull.class)
|
|
||||||
+public class Conversions {
|
+public class Conversions {
|
||||||
+
|
+
|
||||||
+ private final RegistryOps.RegistryInfoLookup lookup;
|
+ private final RegistryOps.RegistryInfoLookup lookup;
|
||||||
|
@ -458,6 +454,16 @@ index 0000000000000000000000000000000000000000..eda5cc7d45ef59ccc1c9c7e027c1f044
|
||||||
+ return vanilla == null ? Component.empty() : this.serializer.deserialize(vanilla);
|
+ return vanilla == null ? Component.empty() : this.serializer.deserialize(vanilla);
|
||||||
+ }
|
+ }
|
||||||
+}
|
+}
|
||||||
|
diff --git a/src/main/java/io/papermc/paper/registry/data/util/package-info.java b/src/main/java/io/papermc/paper/registry/data/util/package-info.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..5b88be976c7773459ce1b6daf58d7ea7c806f21b
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/io/papermc/paper/registry/data/util/package-info.java
|
||||||
|
@@ -0,0 +1,4 @@
|
||||||
|
+@NullMarked
|
||||||
|
+package io.papermc.paper.registry.data.util;
|
||||||
|
+
|
||||||
|
+import org.jspecify.annotations.NullMarked;
|
||||||
diff --git a/src/main/java/io/papermc/paper/registry/entry/AddableRegistryEntry.java b/src/main/java/io/papermc/paper/registry/entry/AddableRegistryEntry.java
|
diff --git a/src/main/java/io/papermc/paper/registry/entry/AddableRegistryEntry.java b/src/main/java/io/papermc/paper/registry/entry/AddableRegistryEntry.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..aeec9b3ae2911f041d000b3db72f37974020ba60
|
index 0000000000000000000000000000000000000000..aeec9b3ae2911f041d000b3db72f37974020ba60
|
||||||
|
@ -547,7 +553,7 @@ index 0000000000000000000000000000000000000000..515a995e3862f8e7cb93d149315ea32e
|
||||||
+ }
|
+ }
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/io/papermc/paper/registry/entry/RegistryEntry.java b/src/main/java/io/papermc/paper/registry/entry/RegistryEntry.java
|
diff --git a/src/main/java/io/papermc/paper/registry/entry/RegistryEntry.java b/src/main/java/io/papermc/paper/registry/entry/RegistryEntry.java
|
||||||
index 15991bf13894d850f360a520d1815711d25973ec..f2e919705301cb23ed1938ca3c1976378249172c 100644
|
index 2889d87f0989ae5744cd4c1e57240830aa574155..9494bcf82101340e04559d850570698947b7a9ff 100644
|
||||||
--- a/src/main/java/io/papermc/paper/registry/entry/RegistryEntry.java
|
--- a/src/main/java/io/papermc/paper/registry/entry/RegistryEntry.java
|
||||||
+++ b/src/main/java/io/papermc/paper/registry/entry/RegistryEntry.java
|
+++ b/src/main/java/io/papermc/paper/registry/entry/RegistryEntry.java
|
||||||
@@ -1,7 +1,13 @@
|
@@ -1,7 +1,13 @@
|
||||||
|
@ -564,15 +570,15 @@ index 15991bf13894d850f360a520d1815711d25973ec..f2e919705301cb23ed1938ca3c197637
|
||||||
import io.papermc.paper.registry.legacy.DelayedRegistryEntry;
|
import io.papermc.paper.registry.legacy.DelayedRegistryEntry;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
@@ -11,6 +17,7 @@ import org.bukkit.Keyed;
|
@@ -10,6 +16,7 @@ import net.minecraft.resources.ResourceKey;
|
||||||
|
import org.bukkit.Keyed;
|
||||||
import org.bukkit.NamespacedKey;
|
import org.bukkit.NamespacedKey;
|
||||||
import org.bukkit.craftbukkit.util.ApiVersion;
|
import org.bukkit.craftbukkit.util.ApiVersion;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
+import org.jspecify.annotations.Nullable;
|
||||||
+import org.checkerframework.checker.nullness.qual.Nullable;
|
|
||||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
|
||||||
|
|
||||||
@DefaultQualifier(NonNull.class)
|
public interface RegistryEntry<M, B extends Keyed> extends RegistryEntryInfo<M, B> { // TODO remove Keyed
|
||||||
@@ -32,6 +39,65 @@ public interface RegistryEntry<M, B extends Keyed> extends RegistryEntryInfo<M,
|
|
||||||
|
@@ -29,6 +36,65 @@ public interface RegistryEntry<M, B extends Keyed> extends RegistryEntryInfo<M,
|
||||||
return new DelayedRegistryEntry<>(this);
|
return new DelayedRegistryEntry<>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -638,7 +644,7 @@ index 15991bf13894d850f360a520d1815711d25973ec..f2e919705301cb23ed1938ca3c197637
|
||||||
static <M, B extends Keyed> RegistryEntry<M, B> entry(
|
static <M, B extends Keyed> RegistryEntry<M, B> entry(
|
||||||
final ResourceKey<? extends Registry<M>> mcKey,
|
final ResourceKey<? extends Registry<M>> mcKey,
|
||||||
final RegistryKey<B> apiKey,
|
final RegistryKey<B> apiKey,
|
||||||
@@ -48,4 +114,24 @@ public interface RegistryEntry<M, B extends Keyed> extends RegistryEntryInfo<M,
|
@@ -45,4 +111,24 @@ public interface RegistryEntry<M, B extends Keyed> extends RegistryEntryInfo<M,
|
||||||
) {
|
) {
|
||||||
return new ApiRegistryEntry<>(mcKey, apiKey, apiRegistrySupplier);
|
return new ApiRegistryEntry<>(mcKey, apiKey, apiRegistrySupplier);
|
||||||
}
|
}
|
||||||
|
@ -693,10 +699,10 @@ index 0000000000000000000000000000000000000000..562accce731630327d116afd1c9d559d
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/io/papermc/paper/registry/event/RegistryEntryAddEventImpl.java b/src/main/java/io/papermc/paper/registry/event/RegistryEntryAddEventImpl.java
|
diff --git a/src/main/java/io/papermc/paper/registry/event/RegistryEntryAddEventImpl.java b/src/main/java/io/papermc/paper/registry/event/RegistryEntryAddEventImpl.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..cc9c8fd313f530777af80ad79e03903f3f8f9829
|
index 0000000000000000000000000000000000000000..332829c65ef45966dffcf5f1c59422a801179759
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/io/papermc/paper/registry/event/RegistryEntryAddEventImpl.java
|
+++ b/src/main/java/io/papermc/paper/registry/event/RegistryEntryAddEventImpl.java
|
||||||
@@ -0,0 +1,30 @@
|
@@ -0,0 +1,29 @@
|
||||||
+package io.papermc.paper.registry.event;
|
+package io.papermc.paper.registry.event;
|
||||||
+
|
+
|
||||||
+import io.papermc.paper.plugin.lifecycle.event.PaperLifecycleEvent;
|
+import io.papermc.paper.plugin.lifecycle.event.PaperLifecycleEvent;
|
||||||
|
@ -711,7 +717,6 @@ index 0000000000000000000000000000000000000000..cc9c8fd313f530777af80ad79e03903f
|
||||||
+import net.minecraft.core.HolderSet;
|
+import net.minecraft.core.HolderSet;
|
||||||
+import net.minecraft.resources.RegistryOps;
|
+import net.minecraft.resources.RegistryOps;
|
||||||
+import org.bukkit.Keyed;
|
+import org.bukkit.Keyed;
|
||||||
+import org.checkerframework.checker.nullness.qual.NonNull;
|
|
||||||
+
|
+
|
||||||
+public record RegistryEntryAddEventImpl<T, B extends RegistryBuilder<T>>(
|
+public record RegistryEntryAddEventImpl<T, B extends RegistryBuilder<T>>(
|
||||||
+ TypedKey<T> key,
|
+ TypedKey<T> key,
|
||||||
|
@ -721,7 +726,7 @@ index 0000000000000000000000000000000000000000..cc9c8fd313f530777af80ad79e03903f
|
||||||
+) implements RegistryEntryAddEvent<T, B>, PaperLifecycleEvent {
|
+) implements RegistryEntryAddEvent<T, B>, PaperLifecycleEvent {
|
||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public @NonNull <V extends Keyed> Tag<V> getOrCreateTag(final TagKey<V> tagKey) {
|
+ public <V extends Keyed> Tag<V> getOrCreateTag(final TagKey<V> tagKey) {
|
||||||
+ final RegistryOps.RegistryInfo<Object> registryInfo = this.conversions.lookup().lookup(PaperRegistries.registryToNms(tagKey.registryKey())).orElseThrow();
|
+ final RegistryOps.RegistryInfo<Object> registryInfo = this.conversions.lookup().lookup(PaperRegistries.registryToNms(tagKey.registryKey())).orElseThrow();
|
||||||
+ final HolderSet.Named<?> tagSet = registryInfo.getter().getOrThrow(PaperRegistries.toNms(tagKey));
|
+ final HolderSet.Named<?> tagSet = registryInfo.getter().getOrThrow(PaperRegistries.toNms(tagKey));
|
||||||
+ return new NamedRegistryKeySetImpl<>(tagKey, tagSet);
|
+ return new NamedRegistryKeySetImpl<>(tagKey, tagSet);
|
||||||
|
@ -810,10 +815,10 @@ index 0000000000000000000000000000000000000000..34c842ffa355e3c8001dd7b8551bcb49
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/io/papermc/paper/registry/event/RegistryFreezeEventImpl.java b/src/main/java/io/papermc/paper/registry/event/RegistryFreezeEventImpl.java
|
diff --git a/src/main/java/io/papermc/paper/registry/event/RegistryFreezeEventImpl.java b/src/main/java/io/papermc/paper/registry/event/RegistryFreezeEventImpl.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..63957d2509e68ccc6eb2fd9ecaa35bfad7b71b81
|
index 0000000000000000000000000000000000000000..1b45802f9afc97fd59c6dc77964dedea1016cd6c
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/io/papermc/paper/registry/event/RegistryFreezeEventImpl.java
|
+++ b/src/main/java/io/papermc/paper/registry/event/RegistryFreezeEventImpl.java
|
||||||
@@ -0,0 +1,28 @@
|
@@ -0,0 +1,27 @@
|
||||||
+package io.papermc.paper.registry.event;
|
+package io.papermc.paper.registry.event;
|
||||||
+
|
+
|
||||||
+import io.papermc.paper.plugin.lifecycle.event.PaperLifecycleEvent;
|
+import io.papermc.paper.plugin.lifecycle.event.PaperLifecycleEvent;
|
||||||
|
@ -827,7 +832,6 @@ index 0000000000000000000000000000000000000000..63957d2509e68ccc6eb2fd9ecaa35bfa
|
||||||
+import net.minecraft.core.HolderSet;
|
+import net.minecraft.core.HolderSet;
|
||||||
+import net.minecraft.resources.RegistryOps;
|
+import net.minecraft.resources.RegistryOps;
|
||||||
+import org.bukkit.Keyed;
|
+import org.bukkit.Keyed;
|
||||||
+import org.checkerframework.checker.nullness.qual.NonNull;
|
|
||||||
+
|
+
|
||||||
+public record RegistryFreezeEventImpl<T, B extends RegistryBuilder<T>>(
|
+public record RegistryFreezeEventImpl<T, B extends RegistryBuilder<T>>(
|
||||||
+ RegistryKey<T> registryKey,
|
+ RegistryKey<T> registryKey,
|
||||||
|
@ -836,7 +840,7 @@ index 0000000000000000000000000000000000000000..63957d2509e68ccc6eb2fd9ecaa35bfa
|
||||||
+) implements RegistryFreezeEvent<T, B>, PaperLifecycleEvent {
|
+) implements RegistryFreezeEvent<T, B>, PaperLifecycleEvent {
|
||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public @NonNull <V extends Keyed> Tag<V> getOrCreateTag(final TagKey<V> tagKey) {
|
+ public <V extends Keyed> Tag<V> getOrCreateTag(final TagKey<V> tagKey) {
|
||||||
+ final RegistryOps.RegistryInfo<Object> registryInfo = this.conversions.lookup().lookup(PaperRegistries.registryToNms(tagKey.registryKey())).orElseThrow();
|
+ final RegistryOps.RegistryInfo<Object> registryInfo = this.conversions.lookup().lookup(PaperRegistries.registryToNms(tagKey.registryKey())).orElseThrow();
|
||||||
+ final HolderSet.Named<?> tagSet = registryInfo.getter().getOrThrow(PaperRegistries.toNms(tagKey));
|
+ final HolderSet.Named<?> tagSet = registryInfo.getter().getOrThrow(PaperRegistries.toNms(tagKey));
|
||||||
+ return new NamedRegistryKeySetImpl<>(tagKey, tagSet);
|
+ return new NamedRegistryKeySetImpl<>(tagKey, tagSet);
|
||||||
|
@ -844,15 +848,14 @@ index 0000000000000000000000000000000000000000..63957d2509e68ccc6eb2fd9ecaa35bfa
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/io/papermc/paper/registry/event/package-info.java b/src/main/java/io/papermc/paper/registry/event/package-info.java
|
diff --git a/src/main/java/io/papermc/paper/registry/event/package-info.java b/src/main/java/io/papermc/paper/registry/event/package-info.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..14d2d9766b8dee763f220c397aba3ad432d02aaa
|
index 0000000000000000000000000000000000000000..1d20e0d940ae498b96fe33f6176c140f816921f1
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/io/papermc/paper/registry/event/package-info.java
|
+++ b/src/main/java/io/papermc/paper/registry/event/package-info.java
|
||||||
@@ -0,0 +1,5 @@
|
@@ -0,0 +1,4 @@
|
||||||
+@DefaultQualifier(NonNull.class)
|
+@NullMarked
|
||||||
+package io.papermc.paper.registry.event;
|
+package io.papermc.paper.registry.event;
|
||||||
+
|
+
|
||||||
+import org.checkerframework.checker.nullness.qual.NonNull;
|
+import org.jspecify.annotations.NullMarked;
|
||||||
+import org.checkerframework.framework.qual.DefaultQualifier;
|
|
||||||
diff --git a/src/main/java/io/papermc/paper/registry/event/type/RegistryEntryAddEventTypeImpl.java b/src/main/java/io/papermc/paper/registry/event/type/RegistryEntryAddEventTypeImpl.java
|
diff --git a/src/main/java/io/papermc/paper/registry/event/type/RegistryEntryAddEventTypeImpl.java b/src/main/java/io/papermc/paper/registry/event/type/RegistryEntryAddEventTypeImpl.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..fbf853bf1cbb3c7bbef531afe185818b9454299b
|
index 0000000000000000000000000000000000000000..fbf853bf1cbb3c7bbef531afe185818b9454299b
|
||||||
|
@ -898,7 +901,7 @@ index 0000000000000000000000000000000000000000..fbf853bf1cbb3c7bbef531afe185818b
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/io/papermc/paper/registry/event/type/RegistryEntryAddHandlerConfiguration.java b/src/main/java/io/papermc/paper/registry/event/type/RegistryEntryAddHandlerConfiguration.java
|
diff --git a/src/main/java/io/papermc/paper/registry/event/type/RegistryEntryAddHandlerConfiguration.java b/src/main/java/io/papermc/paper/registry/event/type/RegistryEntryAddHandlerConfiguration.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..548f5bf979e88708e98d04dfe22ccaa300c91ddd
|
index 0000000000000000000000000000000000000000..3cc0f7688f61c5fdbd98d0134741c98a8b9748b9
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/io/papermc/paper/registry/event/type/RegistryEntryAddHandlerConfiguration.java
|
+++ b/src/main/java/io/papermc/paper/registry/event/type/RegistryEntryAddHandlerConfiguration.java
|
||||||
@@ -0,0 +1,42 @@
|
@@ -0,0 +1,42 @@
|
||||||
|
@ -912,8 +915,8 @@ index 0000000000000000000000000000000000000000..548f5bf979e88708e98d04dfe22ccaa3
|
||||||
+import io.papermc.paper.registry.TypedKey;
|
+import io.papermc.paper.registry.TypedKey;
|
||||||
+import io.papermc.paper.registry.event.RegistryEntryAddEvent;
|
+import io.papermc.paper.registry.event.RegistryEntryAddEvent;
|
||||||
+import java.util.function.Predicate;
|
+import java.util.function.Predicate;
|
||||||
+import org.checkerframework.checker.nullness.qual.Nullable;
|
|
||||||
+import org.jetbrains.annotations.Contract;
|
+import org.jetbrains.annotations.Contract;
|
||||||
|
+import org.jspecify.annotations.Nullable;
|
||||||
+
|
+
|
||||||
+public class RegistryEntryAddHandlerConfiguration<T, B extends RegistryBuilder<T>> extends PrioritizedLifecycleEventHandlerConfigurationImpl<BootstrapContext, RegistryEntryAddEvent<T, B>> implements RegistryEntryAddConfiguration<T> {
|
+public class RegistryEntryAddHandlerConfiguration<T, B extends RegistryBuilder<T>> extends PrioritizedLifecycleEventHandlerConfigurationImpl<BootstrapContext, RegistryEntryAddEvent<T, B>> implements RegistryEntryAddConfiguration<T> {
|
||||||
+
|
+
|
||||||
|
@ -968,8 +971,18 @@ index 0000000000000000000000000000000000000000..7ee77022198bf5f9f88c6a1917a1da30
|
||||||
+ return false; // only runs once
|
+ return false; // only runs once
|
||||||
+ }
|
+ }
|
||||||
+}
|
+}
|
||||||
|
diff --git a/src/main/java/io/papermc/paper/registry/event/type/package-info.java b/src/main/java/io/papermc/paper/registry/event/type/package-info.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..f9f63926a5aaf84e0d23bac3422c5800683e37f9
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/io/papermc/paper/registry/event/type/package-info.java
|
||||||
|
@@ -0,0 +1,4 @@
|
||||||
|
+@NullMarked
|
||||||
|
+package io.papermc.paper.registry.event.type;
|
||||||
|
+
|
||||||
|
+import org.jspecify.annotations.NullMarked;
|
||||||
diff --git a/src/main/java/io/papermc/paper/registry/legacy/DelayedRegistry.java b/src/main/java/io/papermc/paper/registry/legacy/DelayedRegistry.java
|
diff --git a/src/main/java/io/papermc/paper/registry/legacy/DelayedRegistry.java b/src/main/java/io/papermc/paper/registry/legacy/DelayedRegistry.java
|
||||||
index 9400fed345344a0a8e4fb301cca6a1867adf625b..0cdc92acd3ebb6efb10e1b66419cc05618301581 100644
|
index ca829b162d4369f845e59b62bb8779fd83fe2ef3..2de5aa3f0f17b29a6cf9d81ebda81aed7295c1f1 100644
|
||||||
--- a/src/main/java/io/papermc/paper/registry/legacy/DelayedRegistry.java
|
--- a/src/main/java/io/papermc/paper/registry/legacy/DelayedRegistry.java
|
||||||
+++ b/src/main/java/io/papermc/paper/registry/legacy/DelayedRegistry.java
|
+++ b/src/main/java/io/papermc/paper/registry/legacy/DelayedRegistry.java
|
||||||
@@ -1,5 +1,7 @@
|
@@ -1,5 +1,7 @@
|
||||||
|
@ -980,16 +993,8 @@ index 9400fed345344a0a8e4fb301cca6a1867adf625b..0cdc92acd3ebb6efb10e1b66419cc056
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
@@ -7,7 +9,6 @@ import net.kyori.adventure.key.Key;
|
@@ -54,4 +56,14 @@ public final class DelayedRegistry<T extends Keyed, R extends Registry<T>> imple
|
||||||
import org.bukkit.Keyed;
|
public @Nullable NamespacedKey getKey(final T value) {
|
||||||
import org.bukkit.NamespacedKey;
|
|
||||||
import org.bukkit.Registry;
|
|
||||||
-import org.bukkit.craftbukkit.CraftRegistry;
|
|
||||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
@@ -58,4 +59,14 @@ public final class DelayedRegistry<T extends Keyed, R extends Registry<T>> imple
|
|
||||||
public NamespacedKey getKey(final T value) {
|
|
||||||
return this.delegate().getKey(value);
|
return this.delegate().getKey(value);
|
||||||
}
|
}
|
||||||
+
|
+
|
||||||
|
@ -1003,23 +1008,12 @@ index 9400fed345344a0a8e4fb301cca6a1867adf625b..0cdc92acd3ebb6efb10e1b66419cc056
|
||||||
+ return this.delegate().getTag(key);
|
+ return this.delegate().getTag(key);
|
||||||
+ }
|
+ }
|
||||||
}
|
}
|
||||||
diff --git a/src/main/java/io/papermc/paper/registry/package-info.java b/src/main/java/io/papermc/paper/registry/package-info.java
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000000000000000000000000000000000000..0b80179ff90e085568d7ceafd9b17511789dc99b
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/src/main/java/io/papermc/paper/registry/package-info.java
|
|
||||||
@@ -0,0 +1,5 @@
|
|
||||||
+@DefaultQualifier(NonNull.class)
|
|
||||||
+package io.papermc.paper.registry;
|
|
||||||
+
|
|
||||||
+import org.checkerframework.checker.nullness.qual.NonNull;
|
|
||||||
+import org.checkerframework.framework.qual.DefaultQualifier;
|
|
||||||
diff --git a/src/main/java/io/papermc/paper/registry/set/NamedRegistryKeySetImpl.java b/src/main/java/io/papermc/paper/registry/set/NamedRegistryKeySetImpl.java
|
diff --git a/src/main/java/io/papermc/paper/registry/set/NamedRegistryKeySetImpl.java b/src/main/java/io/papermc/paper/registry/set/NamedRegistryKeySetImpl.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..e8c2c18a1ed5cd587266bd415170610781531a12
|
index 0000000000000000000000000000000000000000..7b15640c2f10c72f2612ab2270adc5689dfd9e5a
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/io/papermc/paper/registry/set/NamedRegistryKeySetImpl.java
|
+++ b/src/main/java/io/papermc/paper/registry/set/NamedRegistryKeySetImpl.java
|
||||||
@@ -0,0 +1,76 @@
|
@@ -0,0 +1,74 @@
|
||||||
+package io.papermc.paper.registry.set;
|
+package io.papermc.paper.registry.set;
|
||||||
+
|
+
|
||||||
+import com.google.common.collect.ImmutableList;
|
+import com.google.common.collect.ImmutableList;
|
||||||
|
@ -1039,12 +1033,10 @@ index 0000000000000000000000000000000000000000..e8c2c18a1ed5cd587266bd4151706107
|
||||||
+import org.bukkit.NamespacedKey;
|
+import org.bukkit.NamespacedKey;
|
||||||
+import org.bukkit.Registry;
|
+import org.bukkit.Registry;
|
||||||
+import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
+import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||||
+import org.checkerframework.checker.nullness.qual.NonNull;
|
|
||||||
+import org.checkerframework.framework.qual.DefaultQualifier;
|
|
||||||
+import org.jetbrains.annotations.NotNull;
|
|
||||||
+import org.jetbrains.annotations.Unmodifiable;
|
+import org.jetbrains.annotations.Unmodifiable;
|
||||||
|
+import org.jspecify.annotations.NullMarked;
|
||||||
+
|
+
|
||||||
+@DefaultQualifier(NonNull.class)
|
+@NullMarked
|
||||||
+public record NamedRegistryKeySetImpl<T extends Keyed, M>( // TODO remove Keyed
|
+public record NamedRegistryKeySetImpl<T extends Keyed, M>( // TODO remove Keyed
|
||||||
+ TagKey<T> tagKey,
|
+ TagKey<T> tagKey,
|
||||||
+ HolderSet.Named<M> namedSet
|
+ HolderSet.Named<M> namedSet
|
||||||
|
@ -1091,17 +1083,17 @@ index 0000000000000000000000000000000000000000..e8c2c18a1ed5cd587266bd4151706107
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public @NotNull NamespacedKey getKey() {
|
+ public NamespacedKey getKey() {
|
||||||
+ final Key key = this.tagKey().key();
|
+ final Key key = this.tagKey().key();
|
||||||
+ return new NamespacedKey(key.namespace(), key.value());
|
+ return new NamespacedKey(key.namespace(), key.value());
|
||||||
+ }
|
+ }
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/io/papermc/paper/registry/set/PaperRegistrySets.java b/src/main/java/io/papermc/paper/registry/set/PaperRegistrySets.java
|
diff --git a/src/main/java/io/papermc/paper/registry/set/PaperRegistrySets.java b/src/main/java/io/papermc/paper/registry/set/PaperRegistrySets.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..f09ce9c8547ef05153847245746473dd9a8acbe6
|
index 0000000000000000000000000000000000000000..cb92f53cf9d139828acd016499470212a198b722
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/io/papermc/paper/registry/set/PaperRegistrySets.java
|
+++ b/src/main/java/io/papermc/paper/registry/set/PaperRegistrySets.java
|
||||||
@@ -0,0 +1,48 @@
|
@@ -0,0 +1,45 @@
|
||||||
+package io.papermc.paper.registry.set;
|
+package io.papermc.paper.registry.set;
|
||||||
+
|
+
|
||||||
+import io.papermc.paper.registry.PaperRegistries;
|
+import io.papermc.paper.registry.PaperRegistries;
|
||||||
|
@ -1115,10 +1107,7 @@ index 0000000000000000000000000000000000000000..f09ce9c8547ef05153847245746473dd
|
||||||
+import net.minecraft.resources.RegistryOps;
|
+import net.minecraft.resources.RegistryOps;
|
||||||
+import net.minecraft.resources.ResourceKey;
|
+import net.minecraft.resources.ResourceKey;
|
||||||
+import org.bukkit.Keyed;
|
+import org.bukkit.Keyed;
|
||||||
+import org.checkerframework.checker.nullness.qual.NonNull;
|
|
||||||
+import org.checkerframework.framework.qual.DefaultQualifier;
|
|
||||||
+
|
+
|
||||||
+@DefaultQualifier(NonNull.class)
|
|
||||||
+public final class PaperRegistrySets {
|
+public final class PaperRegistrySets {
|
||||||
+
|
+
|
||||||
+ public static <A extends Keyed, M> HolderSet<M> convertToNms(final ResourceKey<? extends Registry<M>> resourceKey, final RegistryOps.RegistryInfoLookup lookup, final RegistryKeySet<A> registryKeySet) { // TODO remove Keyed
|
+ public static <A extends Keyed, M> HolderSet<M> convertToNms(final ResourceKey<? extends Registry<M>> resourceKey, final RegistryOps.RegistryInfoLookup lookup, final RegistryKeySet<A> registryKeySet) { // TODO remove Keyed
|
||||||
|
@ -1150,6 +1139,16 @@ index 0000000000000000000000000000000000000000..f09ce9c8547ef05153847245746473dd
|
||||||
+ private PaperRegistrySets() {
|
+ private PaperRegistrySets() {
|
||||||
+ }
|
+ }
|
||||||
+}
|
+}
|
||||||
|
diff --git a/src/main/java/io/papermc/paper/registry/set/package-info.java b/src/main/java/io/papermc/paper/registry/set/package-info.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..516b072428dcc8a28d13bcc990493cf4c22ad948
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/io/papermc/paper/registry/set/package-info.java
|
||||||
|
@@ -0,0 +1,4 @@
|
||||||
|
+@NullMarked
|
||||||
|
+package io.papermc.paper.registry.set;
|
||||||
|
+
|
||||||
|
+import org.jspecify.annotations.NullMarked;
|
||||||
diff --git a/src/main/java/net/minecraft/core/MappedRegistry.java b/src/main/java/net/minecraft/core/MappedRegistry.java
|
diff --git a/src/main/java/net/minecraft/core/MappedRegistry.java b/src/main/java/net/minecraft/core/MappedRegistry.java
|
||||||
index 71e04e5c1bc0722abf8ca2e0738bd60b6d7ae21c..063630c1ffcce099139c59d598fc5a210e21f640 100644
|
index 71e04e5c1bc0722abf8ca2e0738bd60b6d7ae21c..063630c1ffcce099139c59d598fc5a210e21f640 100644
|
||||||
--- a/src/main/java/net/minecraft/core/MappedRegistry.java
|
--- a/src/main/java/net/minecraft/core/MappedRegistry.java
|
||||||
|
|
|
@ -6,7 +6,7 @@ Subject: [PATCH] Add registry entry and builders
|
||||||
Feature patch
|
Feature patch
|
||||||
|
|
||||||
diff --git a/src/main/java/io/papermc/paper/registry/PaperRegistries.java b/src/main/java/io/papermc/paper/registry/PaperRegistries.java
|
diff --git a/src/main/java/io/papermc/paper/registry/PaperRegistries.java b/src/main/java/io/papermc/paper/registry/PaperRegistries.java
|
||||||
index 3ec2aa5da045b62809afd2c13fc9ae74189dbdad..31d660bbbe62cd2c26715e8d90fef58b8e024e34 100644
|
index 86c9f87cdb41c0d1ccc2a61b501f969cfaae47bc..fd024576e70e0c121c1477a0b7777af18159b7c4 100644
|
||||||
--- a/src/main/java/io/papermc/paper/registry/PaperRegistries.java
|
--- a/src/main/java/io/papermc/paper/registry/PaperRegistries.java
|
||||||
+++ b/src/main/java/io/papermc/paper/registry/PaperRegistries.java
|
+++ b/src/main/java/io/papermc/paper/registry/PaperRegistries.java
|
||||||
@@ -2,6 +2,9 @@ package io.papermc.paper.registry;
|
@@ -2,6 +2,9 @@ package io.papermc.paper.registry;
|
||||||
|
@ -19,7 +19,7 @@ index 3ec2aa5da045b62809afd2c13fc9ae74189dbdad..31d660bbbe62cd2c26715e8d90fef58b
|
||||||
import io.papermc.paper.registry.entry.RegistryEntry;
|
import io.papermc.paper.registry.entry.RegistryEntry;
|
||||||
import io.papermc.paper.registry.tag.TagKey;
|
import io.papermc.paper.registry.tag.TagKey;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -81,7 +84,7 @@ public final class PaperRegistries {
|
@@ -78,7 +81,7 @@ public final class PaperRegistries {
|
||||||
static {
|
static {
|
||||||
REGISTRY_ENTRIES = List.of(
|
REGISTRY_ENTRIES = List.of(
|
||||||
// built-ins
|
// built-ins
|
||||||
|
@ -28,7 +28,7 @@ index 3ec2aa5da045b62809afd2c13fc9ae74189dbdad..31d660bbbe62cd2c26715e8d90fef58b
|
||||||
entry(Registries.STRUCTURE_TYPE, RegistryKey.STRUCTURE_TYPE, StructureType.class, CraftStructureType::new),
|
entry(Registries.STRUCTURE_TYPE, RegistryKey.STRUCTURE_TYPE, StructureType.class, CraftStructureType::new),
|
||||||
entry(Registries.MOB_EFFECT, RegistryKey.MOB_EFFECT, PotionEffectType.class, CraftPotionEffectType::new),
|
entry(Registries.MOB_EFFECT, RegistryKey.MOB_EFFECT, PotionEffectType.class, CraftPotionEffectType::new),
|
||||||
entry(Registries.BLOCK, RegistryKey.BLOCK, BlockType.class, CraftBlockType::new),
|
entry(Registries.BLOCK, RegistryKey.BLOCK, BlockType.class, CraftBlockType::new),
|
||||||
@@ -103,10 +106,10 @@ public final class PaperRegistries {
|
@@ -100,10 +103,10 @@ public final class PaperRegistries {
|
||||||
entry(Registries.TRIM_PATTERN, RegistryKey.TRIM_PATTERN, TrimPattern.class, CraftTrimPattern::new).delayed(),
|
entry(Registries.TRIM_PATTERN, RegistryKey.TRIM_PATTERN, TrimPattern.class, CraftTrimPattern::new).delayed(),
|
||||||
entry(Registries.DAMAGE_TYPE, RegistryKey.DAMAGE_TYPE, DamageType.class, CraftDamageType::new).delayed(),
|
entry(Registries.DAMAGE_TYPE, RegistryKey.DAMAGE_TYPE, DamageType.class, CraftDamageType::new).delayed(),
|
||||||
entry(Registries.WOLF_VARIANT, RegistryKey.WOLF_VARIANT, Wolf.Variant.class, CraftWolf.CraftVariant::new).delayed(),
|
entry(Registries.WOLF_VARIANT, RegistryKey.WOLF_VARIANT, Wolf.Variant.class, CraftWolf.CraftVariant::new).delayed(),
|
||||||
|
@ -43,10 +43,10 @@ index 3ec2aa5da045b62809afd2c13fc9ae74189dbdad..31d660bbbe62cd2c26715e8d90fef58b
|
||||||
// api-only
|
// api-only
|
||||||
diff --git a/src/main/java/io/papermc/paper/registry/data/PaperEnchantmentRegistryEntry.java b/src/main/java/io/papermc/paper/registry/data/PaperEnchantmentRegistryEntry.java
|
diff --git a/src/main/java/io/papermc/paper/registry/data/PaperEnchantmentRegistryEntry.java b/src/main/java/io/papermc/paper/registry/data/PaperEnchantmentRegistryEntry.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..481f5f0cfae1fada3bc3f873fb7e04c3086ea9bf
|
index 0000000000000000000000000000000000000000..1b1c6838452d3001070a5d43cc49e3a09de7153d
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/io/papermc/paper/registry/data/PaperEnchantmentRegistryEntry.java
|
+++ b/src/main/java/io/papermc/paper/registry/data/PaperEnchantmentRegistryEntry.java
|
||||||
@@ -0,0 +1,234 @@
|
@@ -0,0 +1,230 @@
|
||||||
+package io.papermc.paper.registry.data;
|
+package io.papermc.paper.registry.data;
|
||||||
+
|
+
|
||||||
+import com.google.common.base.Preconditions;
|
+import com.google.common.base.Preconditions;
|
||||||
|
@ -72,31 +72,27 @@ index 0000000000000000000000000000000000000000..481f5f0cfae1fada3bc3f873fb7e04c3
|
||||||
+import net.minecraft.world.item.enchantment.Enchantment;
|
+import net.minecraft.world.item.enchantment.Enchantment;
|
||||||
+import org.bukkit.craftbukkit.CraftEquipmentSlot;
|
+import org.bukkit.craftbukkit.CraftEquipmentSlot;
|
||||||
+import org.bukkit.inventory.ItemType;
|
+import org.bukkit.inventory.ItemType;
|
||||||
+import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|
||||||
+import org.checkerframework.checker.nullness.qual.NonNull;
|
|
||||||
+import org.checkerframework.checker.nullness.qual.Nullable;
|
|
||||||
+import org.checkerframework.framework.qual.DefaultQualifier;
|
|
||||||
+import org.jetbrains.annotations.Range;
|
+import org.jetbrains.annotations.Range;
|
||||||
|
+import org.jspecify.annotations.Nullable;
|
||||||
+
|
+
|
||||||
+import static io.papermc.paper.registry.data.util.Checks.asArgument;
|
+import static io.papermc.paper.registry.data.util.Checks.asArgument;
|
||||||
+import static io.papermc.paper.registry.data.util.Checks.asArgumentMin;
|
+import static io.papermc.paper.registry.data.util.Checks.asArgumentMin;
|
||||||
+import static io.papermc.paper.registry.data.util.Checks.asConfigured;
|
+import static io.papermc.paper.registry.data.util.Checks.asConfigured;
|
||||||
+
|
+
|
||||||
+@DefaultQualifier(NonNull.class)
|
|
||||||
+public class PaperEnchantmentRegistryEntry implements EnchantmentRegistryEntry {
|
+public class PaperEnchantmentRegistryEntry implements EnchantmentRegistryEntry {
|
||||||
+
|
+
|
||||||
+ // Top level
|
+ // Top level
|
||||||
+ protected @MonotonicNonNull Component description;
|
+ protected @Nullable Component description;
|
||||||
+
|
+
|
||||||
+ // Definition
|
+ // Definition
|
||||||
+ protected @MonotonicNonNull HolderSet<Item> supportedItems;
|
+ protected @Nullable HolderSet<Item> supportedItems;
|
||||||
+ protected @Nullable HolderSet<Item> primaryItems;
|
+ protected @Nullable HolderSet<Item> primaryItems;
|
||||||
+ protected OptionalInt weight = OptionalInt.empty();
|
+ protected OptionalInt weight = OptionalInt.empty();
|
||||||
+ protected OptionalInt maxLevel = OptionalInt.empty();
|
+ protected OptionalInt maxLevel = OptionalInt.empty();
|
||||||
+ protected Enchantment.@MonotonicNonNull Cost minimumCost;
|
+ protected Enchantment.@Nullable Cost minimumCost;
|
||||||
+ protected Enchantment.@MonotonicNonNull Cost maximumCost;
|
+ protected Enchantment.@Nullable Cost maximumCost;
|
||||||
+ protected OptionalInt anvilCost = OptionalInt.empty();
|
+ protected OptionalInt anvilCost = OptionalInt.empty();
|
||||||
+ protected @MonotonicNonNull List<EquipmentSlotGroup> activeSlots;
|
+ protected @Nullable List<EquipmentSlotGroup> activeSlots;
|
||||||
+
|
+
|
||||||
+ // Exclusive
|
+ // Exclusive
|
||||||
+ protected HolderSet<Enchantment> exclusiveWith = HolderSet.empty(); // Paper added default to empty.
|
+ protected HolderSet<Enchantment> exclusiveWith = HolderSet.empty(); // Paper added default to empty.
|
||||||
|
@ -165,13 +161,13 @@ index 0000000000000000000000000000000000000000..481f5f0cfae1fada3bc3f873fb7e04c3
|
||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public EnchantmentCost minimumCost() {
|
+ public EnchantmentCost minimumCost() {
|
||||||
+ final Enchantment.@MonotonicNonNull Cost cost = asConfigured(this.minimumCost, "minimumCost");
|
+ final Enchantment.Cost cost = asConfigured(this.minimumCost, "minimumCost");
|
||||||
+ return EnchantmentRegistryEntry.EnchantmentCost.of(cost.base(), cost.perLevelAboveFirst());
|
+ return EnchantmentRegistryEntry.EnchantmentCost.of(cost.base(), cost.perLevelAboveFirst());
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public EnchantmentCost maximumCost() {
|
+ public EnchantmentCost maximumCost() {
|
||||||
+ final Enchantment.@MonotonicNonNull Cost cost = asConfigured(this.maximumCost, "maximumCost");
|
+ final Enchantment.Cost cost = asConfigured(this.maximumCost, "maximumCost");
|
||||||
+ return EnchantmentRegistryEntry.EnchantmentCost.of(cost.base(), cost.perLevelAboveFirst());
|
+ return EnchantmentRegistryEntry.EnchantmentCost.of(cost.base(), cost.perLevelAboveFirst());
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
|
@ -283,25 +279,22 @@ index 0000000000000000000000000000000000000000..481f5f0cfae1fada3bc3f873fb7e04c3
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/io/papermc/paper/registry/data/PaperGameEventRegistryEntry.java b/src/main/java/io/papermc/paper/registry/data/PaperGameEventRegistryEntry.java
|
diff --git a/src/main/java/io/papermc/paper/registry/data/PaperGameEventRegistryEntry.java b/src/main/java/io/papermc/paper/registry/data/PaperGameEventRegistryEntry.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..a96609223ed1e0500f8a4b868e309c0fc82bbc31
|
index 0000000000000000000000000000000000000000..2100e8aca6f7ae7b90545bd3f4d4b800dba65daa
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/io/papermc/paper/registry/data/PaperGameEventRegistryEntry.java
|
+++ b/src/main/java/io/papermc/paper/registry/data/PaperGameEventRegistryEntry.java
|
||||||
@@ -0,0 +1,57 @@
|
@@ -0,0 +1,54 @@
|
||||||
+package io.papermc.paper.registry.data;
|
+package io.papermc.paper.registry.data;
|
||||||
+
|
+
|
||||||
+import io.papermc.paper.registry.PaperRegistryBuilder;
|
+import io.papermc.paper.registry.PaperRegistryBuilder;
|
||||||
+import io.papermc.paper.registry.data.util.Conversions;
|
+import io.papermc.paper.registry.data.util.Conversions;
|
||||||
+import java.util.OptionalInt;
|
+import java.util.OptionalInt;
|
||||||
+import net.minecraft.world.level.gameevent.GameEvent;
|
+import net.minecraft.world.level.gameevent.GameEvent;
|
||||||
+import org.checkerframework.checker.nullness.qual.NonNull;
|
|
||||||
+import org.checkerframework.checker.nullness.qual.Nullable;
|
|
||||||
+import org.checkerframework.framework.qual.DefaultQualifier;
|
|
||||||
+import org.jetbrains.annotations.Range;
|
+import org.jetbrains.annotations.Range;
|
||||||
|
+import org.jspecify.annotations.Nullable;
|
||||||
+
|
+
|
||||||
+import static io.papermc.paper.registry.data.util.Checks.asArgumentMin;
|
+import static io.papermc.paper.registry.data.util.Checks.asArgumentMin;
|
||||||
+import static io.papermc.paper.registry.data.util.Checks.asConfigured;
|
+import static io.papermc.paper.registry.data.util.Checks.asConfigured;
|
||||||
+
|
+
|
||||||
+@DefaultQualifier(NonNull.class)
|
|
||||||
+public class PaperGameEventRegistryEntry implements GameEventRegistryEntry {
|
+public class PaperGameEventRegistryEntry implements GameEventRegistryEntry {
|
||||||
+
|
+
|
||||||
+ protected OptionalInt range = OptionalInt.empty();
|
+ protected OptionalInt range = OptionalInt.empty();
|
||||||
|
@ -470,20 +463,27 @@ index 0000000000000000000000000000000000000000..68b3d747f759f615a3c942de3f4d7a0f
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+}
|
+}
|
||||||
|
diff --git a/src/main/java/io/papermc/paper/registry/data/package-info.java b/src/main/java/io/papermc/paper/registry/data/package-info.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..cfcf814eb527e6b82a2319f28df43b085ca5c168
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/io/papermc/paper/registry/data/package-info.java
|
||||||
|
@@ -0,0 +1,4 @@
|
||||||
|
+@NullMarked
|
||||||
|
+package io.papermc.paper.registry.data;
|
||||||
|
+
|
||||||
|
+import org.jspecify.annotations.NullMarked;
|
||||||
diff --git a/src/main/java/io/papermc/paper/registry/data/util/Checks.java b/src/main/java/io/papermc/paper/registry/data/util/Checks.java
|
diff --git a/src/main/java/io/papermc/paper/registry/data/util/Checks.java b/src/main/java/io/papermc/paper/registry/data/util/Checks.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..3241a94731fe8163876614efdcf30f8b551535af
|
index 0000000000000000000000000000000000000000..9d61fad3989540b77734e57935104696e3c2b5b8
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/io/papermc/paper/registry/data/util/Checks.java
|
+++ b/src/main/java/io/papermc/paper/registry/data/util/Checks.java
|
||||||
@@ -0,0 +1,48 @@
|
@@ -0,0 +1,45 @@
|
||||||
+package io.papermc.paper.registry.data.util;
|
+package io.papermc.paper.registry.data.util;
|
||||||
+
|
+
|
||||||
+import java.util.OptionalInt;
|
+import java.util.OptionalInt;
|
||||||
+import org.checkerframework.checker.nullness.qual.NonNull;
|
+import org.jspecify.annotations.Nullable;
|
||||||
+import org.checkerframework.checker.nullness.qual.Nullable;
|
|
||||||
+import org.checkerframework.framework.qual.DefaultQualifier;
|
|
||||||
+
|
+
|
||||||
+@DefaultQualifier(NonNull.class)
|
|
||||||
+public final class Checks {
|
+public final class Checks {
|
||||||
+
|
+
|
||||||
+ public static <T> T asConfigured(final @Nullable T value, final String field) {
|
+ public static <T> T asConfigured(final @Nullable T value, final String field) {
|
||||||
|
|
|
@ -3589,7 +3589,7 @@ index 0000000000000000000000000000000000000000..62aa1061c35d5358e6dec16a52574b42
|
||||||
+
|
+
|
||||||
+import org.jspecify.annotations.NullMarked;
|
+import org.jspecify.annotations.NullMarked;
|
||||||
diff --git a/src/main/java/io/papermc/paper/registry/PaperRegistries.java b/src/main/java/io/papermc/paper/registry/PaperRegistries.java
|
diff --git a/src/main/java/io/papermc/paper/registry/PaperRegistries.java b/src/main/java/io/papermc/paper/registry/PaperRegistries.java
|
||||||
index 31d660bbbe62cd2c26715e8d90fef58b8e024e34..7e5d1d4f563dfd4beef9cd73b3670714c96bacaf 100644
|
index fd024576e70e0c121c1477a0b7777af18159b7c4..b81d0d906789ef2ff3759395821316462aacf323 100644
|
||||||
--- a/src/main/java/io/papermc/paper/registry/PaperRegistries.java
|
--- a/src/main/java/io/papermc/paper/registry/PaperRegistries.java
|
||||||
+++ b/src/main/java/io/papermc/paper/registry/PaperRegistries.java
|
+++ b/src/main/java/io/papermc/paper/registry/PaperRegistries.java
|
||||||
@@ -2,6 +2,8 @@ package io.papermc.paper.registry;
|
@@ -2,6 +2,8 @@ package io.papermc.paper.registry;
|
||||||
|
@ -3601,7 +3601,7 @@ index 31d660bbbe62cd2c26715e8d90fef58b8e024e34..7e5d1d4f563dfd4beef9cd73b3670714
|
||||||
import io.papermc.paper.registry.data.PaperEnchantmentRegistryEntry;
|
import io.papermc.paper.registry.data.PaperEnchantmentRegistryEntry;
|
||||||
import io.papermc.paper.registry.data.PaperGameEventRegistryEntry;
|
import io.papermc.paper.registry.data.PaperGameEventRegistryEntry;
|
||||||
import io.papermc.paper.registry.data.PaperPaintingVariantRegistryEntry;
|
import io.papermc.paper.registry.data.PaperPaintingVariantRegistryEntry;
|
||||||
@@ -98,6 +100,7 @@ public final class PaperRegistries {
|
@@ -95,6 +97,7 @@ public final class PaperRegistries {
|
||||||
entry(Registries.ATTRIBUTE, RegistryKey.ATTRIBUTE, Attribute.class, CraftAttribute::new),
|
entry(Registries.ATTRIBUTE, RegistryKey.ATTRIBUTE, Attribute.class, CraftAttribute::new),
|
||||||
entry(Registries.FLUID, RegistryKey.FLUID, Fluid.class, CraftFluid::new),
|
entry(Registries.FLUID, RegistryKey.FLUID, Fluid.class, CraftFluid::new),
|
||||||
entry(Registries.SOUND_EVENT, RegistryKey.SOUND_EVENT, Sound.class, CraftSound::new),
|
entry(Registries.SOUND_EVENT, RegistryKey.SOUND_EVENT, Sound.class, CraftSound::new),
|
||||||
|
|
Loading…
Reference in a new issue