mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 12:27:59 +01:00
[ci skip] use more jspecify in server
This commit is contained in:
parent
ebd2dc259d
commit
b52fea44fe
@ -81,14 +81,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+import org.bukkit.inventory.meta.trim.TrimPattern;
|
||||
+import org.bukkit.map.MapCursor;
|
||||
+import org.bukkit.potion.PotionEffectType;
|
||||
+import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
+import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
+import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
+import org.jspecify.annotations.Nullable;
|
||||
+
|
||||
+import static io.papermc.paper.registry.entry.RegistryEntry.apiOnly;
|
||||
+import static io.papermc.paper.registry.entry.RegistryEntry.entry;
|
||||
+
|
||||
+@DefaultQualifier(NonNull.class)
|
||||
+public final class PaperRegistries {
|
||||
+
|
||||
+ static final List<RegistryEntry<?, ?>> REGISTRY_ENTRIES;
|
||||
@ -194,14 +191,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+import net.minecraft.resources.ResourceKey;
|
||||
+import org.bukkit.Keyed;
|
||||
+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.jspecify.annotations.Nullable;
|
||||
+
|
||||
+import static java.util.Objects.requireNonNull;
|
||||
+
|
||||
+@DefaultQualifier(NonNull.class)
|
||||
+public class PaperRegistryAccess implements RegistryAccess {
|
||||
+
|
||||
+ // We store the API registries in a memoized supplier, so they can be created on-demand.
|
||||
@ -224,14 +216,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ @Deprecated(forRemoval = true)
|
||||
+ @Override
|
||||
+ 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
|
||||
+ // 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.
|
||||
+ if (registryKey == null) return null;
|
||||
+
|
||||
+ final @Nullable RegistryEntry<?, T> entry = PaperRegistries.getEntry(registryKey);
|
||||
+ final @Nullable RegistryHolder<T> registry = (RegistryHolder<T>) this.registries.get(registryKey);
|
||||
+ final RegistryEntry<?, T> entry = PaperRegistries.getEntry(registryKey);
|
||||
+ final RegistryHolder<T> registry = (RegistryHolder<T>) this.registries.get(registryKey);
|
||||
+ if (registry != null) {
|
||||
+ // 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.
|
||||
@ -364,10 +356,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+import java.util.function.Supplier;
|
||||
+import org.bukkit.Keyed;
|
||||
+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> {
|
||||
+
|
||||
+ Registry<B> get();
|
||||
@ -487,10 +476,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+import org.bukkit.NamespacedKey;
|
||||
+import org.bukkit.craftbukkit.CraftRegistry;
|
||||
+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
|
||||
+
|
||||
+ private static final BiFunction<NamespacedKey, ApiVersion, NamespacedKey> EMPTY = (namespacedKey, apiVersion) -> namespacedKey;
|
||||
@ -544,10 +530,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+import org.bukkit.Keyed;
|
||||
+import org.bukkit.NamespacedKey;
|
||||
+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
|
||||
+
|
||||
+ RegistryHolder<B> createRegistryHolder(Registry<M> nmsRegistry);
|
||||
@ -607,11 +590,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/registry/entry/package-info.java
|
||||
@@ -0,0 +0,0 @@
|
||||
+@DefaultQualifier(NonNull.class)
|
||||
+@NullMarked
|
||||
+package io.papermc.paper.registry.entry;
|
||||
+
|
||||
+import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
+import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
+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
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
||||
@ -623,14 +605,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+import java.util.Iterator;
|
||||
+import java.util.function.Supplier;
|
||||
+import java.util.stream.Stream;
|
||||
+import net.kyori.adventure.key.Key;
|
||||
+import org.bukkit.Keyed;
|
||||
+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;
|
||||
+import org.jspecify.annotations.Nullable;
|
||||
+
|
||||
+/**
|
||||
+ * This is to support the now-deprecated fields in {@link Registry} for
|
||||
@ -638,7 +616,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ */
|
||||
+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) {
|
||||
+ if (this.delegate != null) {
|
||||
@ -660,7 +638,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public @NotNull T getOrThrow(@NotNull final NamespacedKey key) {
|
||||
+ public T getOrThrow(final NamespacedKey key) {
|
||||
+ return this.delegate().getOrThrow(key);
|
||||
+ }
|
||||
+
|
||||
@ -675,7 +653,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public NamespacedKey getKey(final T value) {
|
||||
+ public @Nullable NamespacedKey getKey(final T value) {
|
||||
+ return this.delegate().getKey(value);
|
||||
+ }
|
||||
+}
|
||||
@ -756,11 +734,20 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/registry/legacy/package-info.java
|
||||
@@ -0,0 +0,0 @@
|
||||
+@DefaultQualifier(NonNull.class)
|
||||
+@NullMarked
|
||||
+package io.papermc.paper.registry.legacy;
|
||||
+
|
||||
+import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
+import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
+import org.jspecify.annotations.NullMarked;
|
||||
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..0000000000000000000000000000000000000000
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/registry/package-info.java
|
||||
@@ -0,0 +0,0 @@
|
||||
+@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
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/core/registries/BuiltInRegistries.java
|
||||
|
@ -72,31 +72,27 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+import net.minecraft.world.item.enchantment.Enchantment;
|
||||
+import org.bukkit.craftbukkit.CraftEquipmentSlot;
|
||||
+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.jspecify.annotations.Nullable;
|
||||
+
|
||||
+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.asConfigured;
|
||||
+
|
||||
+@DefaultQualifier(NonNull.class)
|
||||
+public class PaperEnchantmentRegistryEntry implements EnchantmentRegistryEntry {
|
||||
+
|
||||
+ // Top level
|
||||
+ protected @MonotonicNonNull Component description;
|
||||
+ protected @Nullable Component description;
|
||||
+
|
||||
+ // Definition
|
||||
+ protected @MonotonicNonNull HolderSet<Item> supportedItems;
|
||||
+ protected @Nullable HolderSet<Item> supportedItems;
|
||||
+ protected @Nullable HolderSet<Item> primaryItems;
|
||||
+ protected OptionalInt weight = OptionalInt.empty();
|
||||
+ protected OptionalInt maxLevel = OptionalInt.empty();
|
||||
+ protected Enchantment.@MonotonicNonNull Cost minimumCost;
|
||||
+ protected Enchantment.@MonotonicNonNull Cost maximumCost;
|
||||
+ protected Enchantment.@Nullable Cost minimumCost;
|
||||
+ protected Enchantment.@Nullable Cost maximumCost;
|
||||
+ protected OptionalInt anvilCost = OptionalInt.empty();
|
||||
+ protected @MonotonicNonNull List<EquipmentSlotGroup> activeSlots;
|
||||
+ protected @Nullable List<EquipmentSlotGroup> activeSlots;
|
||||
+
|
||||
+ // Exclusive
|
||||
+ protected HolderSet<Enchantment> exclusiveWith = HolderSet.empty(); // Paper added default to empty.
|
||||
@ -165,13 +161,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+
|
||||
+ @Override
|
||||
+ 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());
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ 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());
|
||||
+ }
|
||||
+
|
||||
@ -293,15 +289,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+import io.papermc.paper.registry.data.util.Conversions;
|
||||
+import java.util.OptionalInt;
|
||||
+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.jspecify.annotations.Nullable;
|
||||
+
|
||||
+import static io.papermc.paper.registry.data.util.Checks.asArgumentMin;
|
||||
+import static io.papermc.paper.registry.data.util.Checks.asConfigured;
|
||||
+
|
||||
+@DefaultQualifier(NonNull.class)
|
||||
+public class PaperGameEventRegistryEntry implements GameEventRegistryEntry {
|
||||
+
|
||||
+ protected OptionalInt range = OptionalInt.empty();
|
||||
@ -470,6 +463,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
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..0000000000000000000000000000000000000000
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/registry/data/package-info.java
|
||||
@@ -0,0 +0,0 @@
|
||||
+@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
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
||||
@ -479,11 +482,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+package io.papermc.paper.registry.data.util;
|
||||
+
|
||||
+import java.util.OptionalInt;
|
||||
+import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
+import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
+import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
+import org.jspecify.annotations.Nullable;
|
||||
+
|
||||
+@DefaultQualifier(NonNull.class)
|
||||
+public final class Checks {
|
||||
+
|
||||
+ public static <T> T asConfigured(final @Nullable T value, final String field) {
|
||||
|
@ -22,14 +22,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
import java.util.Collections;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.List;
|
||||
@@ -0,0 +0,0 @@ import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
@@ -0,0 +0,0 @@ import org.jspecify.annotations.Nullable;
|
||||
|
||||
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.writable;
|
||||
|
||||
@DefaultQualifier(NonNull.class)
|
||||
public final class PaperRegistries {
|
||||
|
||||
@@ -0,0 +0,0 @@ public final class PaperRegistries {
|
||||
return ResourceKey.create((ResourceKey<? extends Registry<M>>) PaperRegistries.registryToNms(typedKey.registryKey()), PaperAdventure.asVanilla(typedKey.key()));
|
||||
}
|
||||
@ -74,8 +74,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+package io.papermc.paper.registry;
|
||||
+
|
||||
+import io.papermc.paper.registry.data.util.Conversions;
|
||||
+import net.minecraft.resources.RegistryOps;
|
||||
+import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
+import org.jspecify.annotations.Nullable;
|
||||
+
|
||||
+public interface PaperRegistryBuilder<M, T> extends RegistryBuilder<T> {
|
||||
+
|
||||
@ -133,8 +132,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+import net.minecraft.core.registries.BuiltInRegistries;
|
||||
+import net.minecraft.resources.ResourceKey;
|
||||
+import net.minecraft.resources.ResourceLocation;
|
||||
+import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
+import org.intellij.lang.annotations.Subst;
|
||||
+import org.jspecify.annotations.Nullable;
|
||||
+
|
||||
+public class PaperRegistryListenerManager {
|
||||
+
|
||||
@ -201,7 +200,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ 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
|
||||
+ 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())) {
|
||||
+ return registerMethod.register((WritableRegistry<M>) registry, key, nms, registrationInfo);
|
||||
+ }
|
||||
@ -262,7 +261,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ }
|
||||
+
|
||||
+ 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())) {
|
||||
+ return;
|
||||
+ }
|
||||
@ -341,7 +340,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+import org.bukkit.NamespacedKey;
|
||||
+import org.bukkit.craftbukkit.CraftRegistry;
|
||||
+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> {
|
||||
+
|
||||
@ -428,12 +427,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+import io.papermc.paper.adventure.WrapperAwareSerializer;
|
||||
+import net.kyori.adventure.text.Component;
|
||||
+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.jspecify.annotations.Nullable;
|
||||
+
|
||||
+@DefaultQualifier(NonNull.class)
|
||||
+public class Conversions {
|
||||
+
|
||||
+ private final RegistryOps.RegistryInfoLookup lookup;
|
||||
@ -458,6 +454,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ 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..0000000000000000000000000000000000000000
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/registry/data/util/package-info.java
|
||||
@@ -0,0 +0,0 @@
|
||||
+@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
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
||||
@ -564,14 +570,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
import io.papermc.paper.registry.legacy.DelayedRegistryEntry;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Supplier;
|
||||
@@ -0,0 +0,0 @@ import org.bukkit.Keyed;
|
||||
@@ -0,0 +0,0 @@ import net.minecraft.resources.ResourceKey;
|
||||
import org.bukkit.Keyed;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.craftbukkit.util.ApiVersion;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
+import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
+import org.jspecify.annotations.Nullable;
|
||||
|
||||
public interface RegistryEntry<M, B extends Keyed> extends RegistryEntryInfo<M, B> { // TODO remove Keyed
|
||||
|
||||
@DefaultQualifier(NonNull.class)
|
||||
@@ -0,0 +0,0 @@ public interface RegistryEntry<M, B extends Keyed> extends RegistryEntryInfo<M,
|
||||
return new DelayedRegistryEntry<>(this);
|
||||
}
|
||||
@ -711,7 +717,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+import net.minecraft.core.HolderSet;
|
||||
+import net.minecraft.resources.RegistryOps;
|
||||
+import org.bukkit.Keyed;
|
||||
+import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
+
|
||||
+public record RegistryEntryAddEventImpl<T, B extends RegistryBuilder<T>>(
|
||||
+ TypedKey<T> key,
|
||||
@ -721,7 +726,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+) implements RegistryEntryAddEvent<T, B>, PaperLifecycleEvent {
|
||||
+
|
||||
+ @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 HolderSet.Named<?> tagSet = registryInfo.getter().getOrThrow(PaperRegistries.toNms(tagKey));
|
||||
+ return new NamedRegistryKeySetImpl<>(tagKey, tagSet);
|
||||
@ -827,7 +832,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+import net.minecraft.core.HolderSet;
|
||||
+import net.minecraft.resources.RegistryOps;
|
||||
+import org.bukkit.Keyed;
|
||||
+import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
+
|
||||
+public record RegistryFreezeEventImpl<T, B extends RegistryBuilder<T>>(
|
||||
+ RegistryKey<T> registryKey,
|
||||
@ -836,7 +840,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+) implements RegistryFreezeEvent<T, B>, PaperLifecycleEvent {
|
||||
+
|
||||
+ @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 HolderSet.Named<?> tagSet = registryInfo.getter().getOrThrow(PaperRegistries.toNms(tagKey));
|
||||
+ return new NamedRegistryKeySetImpl<>(tagKey, tagSet);
|
||||
@ -848,11 +852,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/registry/event/package-info.java
|
||||
@@ -0,0 +0,0 @@
|
||||
+@DefaultQualifier(NonNull.class)
|
||||
+@NullMarked
|
||||
+package io.papermc.paper.registry.event;
|
||||
+
|
||||
+import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
+import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
+import org.jspecify.annotations.NullMarked;
|
||||
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
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
||||
@ -912,8 +915,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+import io.papermc.paper.registry.TypedKey;
|
||||
+import io.papermc.paper.registry.event.RegistryEntryAddEvent;
|
||||
+import java.util.function.Predicate;
|
||||
+import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
+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> {
|
||||
+
|
||||
@ -968,6 +971,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ 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..0000000000000000000000000000000000000000
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/registry/event/type/package-info.java
|
||||
@@ -0,0 +0,0 @@
|
||||
+@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
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/io/papermc/paper/registry/legacy/DelayedRegistry.java
|
||||
@ -980,16 +993,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
import java.util.Iterator;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Stream;
|
||||
@@ -0,0 +0,0 @@ import net.kyori.adventure.key.Key;
|
||||
import org.bukkit.Keyed;
|
||||
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;
|
||||
@@ -0,0 +0,0 @@ public final class DelayedRegistry<T extends Keyed, R extends Registry<T>> imple
|
||||
public NamespacedKey getKey(final T value) {
|
||||
public @Nullable NamespacedKey getKey(final T value) {
|
||||
return this.delegate().getKey(value);
|
||||
}
|
||||
+
|
||||
@ -1003,17 +1008,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ 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..0000000000000000000000000000000000000000
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/registry/package-info.java
|
||||
@@ -0,0 +0,0 @@
|
||||
+@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
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
||||
@ -1039,12 +1033,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+import org.bukkit.NamespacedKey;
|
||||
+import org.bukkit.Registry;
|
||||
+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.jspecify.annotations.NullMarked;
|
||||
+
|
||||
+@DefaultQualifier(NonNull.class)
|
||||
+@NullMarked
|
||||
+public record NamedRegistryKeySetImpl<T extends Keyed, M>( // TODO remove Keyed
|
||||
+ TagKey<T> tagKey,
|
||||
+ HolderSet.Named<M> namedSet
|
||||
@ -1091,7 +1083,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public @NotNull NamespacedKey getKey() {
|
||||
+ public NamespacedKey getKey() {
|
||||
+ final Key key = this.tagKey().key();
|
||||
+ return new NamespacedKey(key.namespace(), key.value());
|
||||
+ }
|
||||
@ -1115,10 +1107,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+import net.minecraft.resources.RegistryOps;
|
||||
+import net.minecraft.resources.ResourceKey;
|
||||
+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 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..00000000000000000000000000000000
|
||||
+ 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..0000000000000000000000000000000000000000
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/registry/set/package-info.java
|
||||
@@ -0,0 +0,0 @@
|
||||
+@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
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/core/MappedRegistry.java
|
||||
|
Loading…
Reference in New Issue
Block a user