From 16f8d0f98477072bf7936b83e4d962cfaf76bba9 Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Sat, 9 Nov 2024 23:26:01 +0100 Subject: [PATCH] Fix NPE with enchantable (#11557) --- .../paper/entity/ai/VanillaGoal.java | 6 ++-- .../paper/registry/keys/AttributeKeys.java | 5 ++-- .../registry/keys/BannerPatternKeys.java | 5 ++-- .../paper/registry/keys/BiomeKeys.java | 5 ++-- .../paper/registry/keys/BlockTypeKeys.java | 5 ++-- .../paper/registry/keys/CatVariantKeys.java | 5 ++-- .../paper/registry/keys/DamageTypeKeys.java | 5 ++-- .../paper/registry/keys/EnchantmentKeys.java | 12 ++++++-- .../paper/registry/keys/FluidKeys.java | 5 ++-- .../paper/registry/keys/FrogVariantKeys.java | 5 ++-- .../paper/registry/keys/GameEventKeys.java | 5 ++-- .../paper/registry/keys/InstrumentKeys.java | 12 ++++++-- .../paper/registry/keys/ItemTypeKeys.java | 5 ++-- .../paper/registry/keys/JukeboxSongKeys.java | 5 ++-- .../registry/keys/MapDecorationTypeKeys.java | 5 ++-- .../paper/registry/keys/MenuTypeKeys.java | 5 ++-- .../paper/registry/keys/MobEffectKeys.java | 5 ++-- .../registry/keys/PaintingVariantKeys.java | 5 ++-- .../paper/registry/keys/SoundEventKeys.java | 5 ++-- .../paper/registry/keys/StructureKeys.java | 5 ++-- .../registry/keys/StructureTypeKeys.java | 5 ++-- .../paper/registry/keys/TrimMaterialKeys.java | 5 ++-- .../paper/registry/keys/TrimPatternKeys.java | 5 ++-- .../registry/keys/VillagerProfessionKeys.java | 5 ++-- .../paper/registry/keys/VillagerTypeKeys.java | 5 ++-- .../paper/registry/keys/WolfVariantKeys.java | 5 ++-- .../keys/tags/EnchantmentTagKeys.java | 5 ++-- .../registry/keys/tags/ItemTypeTagKeys.java | 5 ++-- .../java/io/papermc/generator/Generators.java | 4 +-- .../generator/types/GeneratedKeyType.java | 5 ++-- .../generator/types/GeneratedTagKeyType.java | 5 ++-- .../types/goal/MobGoalGenerator.java | 8 ++--- .../papermc/generator/utils/Annotations.java | 7 +++-- ...gistryAccess-for-managing-registries.patch | 14 ++++----- .../Add-methods-to-get-translation-keys.patch | 13 ++++---- patches/api/Code-Generation.patch | 10 +++---- patches/api/Improve-Registry.patch | 14 ++++----- ...gistryAccess-for-managing-Registries.patch | 2 +- .../Add-methods-to-get-translation-keys.patch | 30 +++++++++++++------ .../Add-registry-entry-and-builders.patch | 2 +- patches/server/General-ItemMeta-fixes.patch | 2 +- 41 files changed, 161 insertions(+), 110 deletions(-) diff --git a/paper-api-generator/generated/com/destroystokyo/paper/entity/ai/VanillaGoal.java b/paper-api-generator/generated/com/destroystokyo/paper/entity/ai/VanillaGoal.java index e0aa5b925c..35dfd25f21 100644 --- a/paper-api-generator/generated/com/destroystokyo/paper/entity/ai/VanillaGoal.java +++ b/paper-api-generator/generated/com/destroystokyo/paper/entity/ai/VanillaGoal.java @@ -51,7 +51,7 @@ import org.bukkit.entity.WanderingTrader; import org.bukkit.entity.Wither; import org.bukkit.entity.Wolf; import org.bukkit.entity.Zombie; -import org.checkerframework.checker.nullness.qual.NonNull; +import org.jspecify.annotations.NullMarked; /** * Vanilla keys for Mob Goals. @@ -67,6 +67,7 @@ import org.checkerframework.checker.nullness.qual.NonNull; "SpellCheckingInspection" }) @GeneratedFrom("1.21.3") +@NullMarked public interface VanillaGoal extends Goal { GoalKey RANDOM_STAND = create("random_stand", AbstractHorse.class); @@ -440,8 +441,7 @@ public interface VanillaGoal extends Goal { GoalKey ZOMBIE_ATTACK_TURTLE_EGG = create("zombie_attack_turtle_egg", Zombie.class); - private static @NonNull GoalKey create(final @NonNull String key, - final @NonNull Class type) { + private static GoalKey create(final String key, final Class type) { return GoalKey.of(type, NamespacedKey.minecraft(key)); } } diff --git a/paper-api-generator/generated/io/papermc/paper/registry/keys/AttributeKeys.java b/paper-api-generator/generated/io/papermc/paper/registry/keys/AttributeKeys.java index 563ddf0af4..e6a1dd2072 100644 --- a/paper-api-generator/generated/io/papermc/paper/registry/keys/AttributeKeys.java +++ b/paper-api-generator/generated/io/papermc/paper/registry/keys/AttributeKeys.java @@ -7,8 +7,8 @@ import io.papermc.paper.registry.RegistryKey; import io.papermc.paper.registry.TypedKey; import net.kyori.adventure.key.Key; import org.bukkit.attribute.Attribute; -import org.checkerframework.checker.nullness.qual.NonNull; import org.jetbrains.annotations.ApiStatus; +import org.jspecify.annotations.NullMarked; /** * Vanilla keys for {@link RegistryKey#ATTRIBUTE}. @@ -24,6 +24,7 @@ import org.jetbrains.annotations.ApiStatus; "SpellCheckingInspection" }) @GeneratedFrom("1.21.3") +@NullMarked @ApiStatus.Experimental public final class AttributeKeys { /** @@ -253,7 +254,7 @@ public final class AttributeKeys { private AttributeKeys() { } - private static @NonNull TypedKey create(final @NonNull Key key) { + private static TypedKey create(final Key key) { return TypedKey.create(RegistryKey.ATTRIBUTE, key); } } diff --git a/paper-api-generator/generated/io/papermc/paper/registry/keys/BannerPatternKeys.java b/paper-api-generator/generated/io/papermc/paper/registry/keys/BannerPatternKeys.java index 33e501a6fa..33248c48ca 100644 --- a/paper-api-generator/generated/io/papermc/paper/registry/keys/BannerPatternKeys.java +++ b/paper-api-generator/generated/io/papermc/paper/registry/keys/BannerPatternKeys.java @@ -7,8 +7,8 @@ import io.papermc.paper.registry.RegistryKey; import io.papermc.paper.registry.TypedKey; import net.kyori.adventure.key.Key; import org.bukkit.block.banner.PatternType; -import org.checkerframework.checker.nullness.qual.NonNull; import org.jetbrains.annotations.ApiStatus; +import org.jspecify.annotations.NullMarked; /** * Vanilla keys for {@link RegistryKey#BANNER_PATTERN}. @@ -24,6 +24,7 @@ import org.jetbrains.annotations.ApiStatus; "SpellCheckingInspection" }) @GeneratedFrom("1.21.3") +@NullMarked @ApiStatus.Experimental public final class BannerPatternKeys { /** @@ -337,7 +338,7 @@ public final class BannerPatternKeys { * @return a new typed key */ @ApiStatus.Experimental - public static @NonNull TypedKey create(final @NonNull Key key) { + public static TypedKey create(final Key key) { return TypedKey.create(RegistryKey.BANNER_PATTERN, key); } } diff --git a/paper-api-generator/generated/io/papermc/paper/registry/keys/BiomeKeys.java b/paper-api-generator/generated/io/papermc/paper/registry/keys/BiomeKeys.java index 83a5d59ea0..1b8d414c6b 100644 --- a/paper-api-generator/generated/io/papermc/paper/registry/keys/BiomeKeys.java +++ b/paper-api-generator/generated/io/papermc/paper/registry/keys/BiomeKeys.java @@ -8,8 +8,8 @@ import io.papermc.paper.registry.TypedKey; import net.kyori.adventure.key.Key; import org.bukkit.MinecraftExperimental; import org.bukkit.block.Biome; -import org.checkerframework.checker.nullness.qual.NonNull; import org.jetbrains.annotations.ApiStatus; +import org.jspecify.annotations.NullMarked; /** * Vanilla keys for {@link RegistryKey#BIOME}. @@ -25,6 +25,7 @@ import org.jetbrains.annotations.ApiStatus; "SpellCheckingInspection" }) @GeneratedFrom("1.21.3") +@NullMarked @ApiStatus.Experimental public final class BiomeKeys { /** @@ -494,7 +495,7 @@ public final class BiomeKeys { * @return a new typed key */ @ApiStatus.Experimental - public static @NonNull TypedKey create(final @NonNull Key key) { + public static TypedKey create(final Key key) { return TypedKey.create(RegistryKey.BIOME, key); } } diff --git a/paper-api-generator/generated/io/papermc/paper/registry/keys/BlockTypeKeys.java b/paper-api-generator/generated/io/papermc/paper/registry/keys/BlockTypeKeys.java index d2b100a27a..682405c5ce 100644 --- a/paper-api-generator/generated/io/papermc/paper/registry/keys/BlockTypeKeys.java +++ b/paper-api-generator/generated/io/papermc/paper/registry/keys/BlockTypeKeys.java @@ -8,8 +8,8 @@ import io.papermc.paper.registry.TypedKey; import net.kyori.adventure.key.Key; import org.bukkit.MinecraftExperimental; import org.bukkit.block.BlockType; -import org.checkerframework.checker.nullness.qual.NonNull; import org.jetbrains.annotations.ApiStatus; +import org.jspecify.annotations.NullMarked; /** * Vanilla keys for {@link RegistryKey#BLOCK}. @@ -25,6 +25,7 @@ import org.jetbrains.annotations.ApiStatus; "SpellCheckingInspection" }) @GeneratedFrom("1.21.3") +@NullMarked @ApiStatus.Experimental public final class BlockTypeKeys { /** @@ -7666,7 +7667,7 @@ public final class BlockTypeKeys { private BlockTypeKeys() { } - private static @NonNull TypedKey create(final @NonNull Key key) { + private static TypedKey create(final Key key) { return TypedKey.create(RegistryKey.BLOCK, key); } } diff --git a/paper-api-generator/generated/io/papermc/paper/registry/keys/CatVariantKeys.java b/paper-api-generator/generated/io/papermc/paper/registry/keys/CatVariantKeys.java index 98acbdf858..058b207390 100644 --- a/paper-api-generator/generated/io/papermc/paper/registry/keys/CatVariantKeys.java +++ b/paper-api-generator/generated/io/papermc/paper/registry/keys/CatVariantKeys.java @@ -7,8 +7,8 @@ import io.papermc.paper.registry.RegistryKey; import io.papermc.paper.registry.TypedKey; import net.kyori.adventure.key.Key; import org.bukkit.entity.Cat; -import org.checkerframework.checker.nullness.qual.NonNull; import org.jetbrains.annotations.ApiStatus; +import org.jspecify.annotations.NullMarked; /** * Vanilla keys for {@link RegistryKey#CAT_VARIANT}. @@ -24,6 +24,7 @@ import org.jetbrains.annotations.ApiStatus; "SpellCheckingInspection" }) @GeneratedFrom("1.21.3") +@NullMarked @ApiStatus.Experimental public final class CatVariantKeys { /** @@ -106,7 +107,7 @@ public final class CatVariantKeys { private CatVariantKeys() { } - private static @NonNull TypedKey create(final @NonNull Key key) { + private static TypedKey create(final Key key) { return TypedKey.create(RegistryKey.CAT_VARIANT, key); } } diff --git a/paper-api-generator/generated/io/papermc/paper/registry/keys/DamageTypeKeys.java b/paper-api-generator/generated/io/papermc/paper/registry/keys/DamageTypeKeys.java index d89a584a1e..1673093d0d 100644 --- a/paper-api-generator/generated/io/papermc/paper/registry/keys/DamageTypeKeys.java +++ b/paper-api-generator/generated/io/papermc/paper/registry/keys/DamageTypeKeys.java @@ -7,8 +7,8 @@ import io.papermc.paper.registry.RegistryKey; import io.papermc.paper.registry.TypedKey; import net.kyori.adventure.key.Key; import org.bukkit.damage.DamageType; -import org.checkerframework.checker.nullness.qual.NonNull; import org.jetbrains.annotations.ApiStatus; +import org.jspecify.annotations.NullMarked; /** * Vanilla keys for {@link RegistryKey#DAMAGE_TYPE}. @@ -24,6 +24,7 @@ import org.jetbrains.annotations.ApiStatus; "SpellCheckingInspection" }) @GeneratedFrom("1.21.3") +@NullMarked @ApiStatus.Experimental public final class DamageTypeKeys { /** @@ -379,7 +380,7 @@ public final class DamageTypeKeys { * @return a new typed key */ @ApiStatus.Experimental - public static @NonNull TypedKey create(final @NonNull Key key) { + public static TypedKey create(final Key key) { return TypedKey.create(RegistryKey.DAMAGE_TYPE, key); } } diff --git a/paper-api-generator/generated/io/papermc/paper/registry/keys/EnchantmentKeys.java b/paper-api-generator/generated/io/papermc/paper/registry/keys/EnchantmentKeys.java index cf19e146cd..9f67994dbb 100644 --- a/paper-api-generator/generated/io/papermc/paper/registry/keys/EnchantmentKeys.java +++ b/paper-api-generator/generated/io/papermc/paper/registry/keys/EnchantmentKeys.java @@ -7,8 +7,8 @@ import io.papermc.paper.registry.RegistryKey; import io.papermc.paper.registry.TypedKey; import net.kyori.adventure.key.Key; import org.bukkit.enchantments.Enchantment; -import org.checkerframework.checker.nullness.qual.NonNull; import org.jetbrains.annotations.ApiStatus; +import org.jspecify.annotations.NullMarked; /** * Vanilla keys for {@link RegistryKey#ENCHANTMENT}. @@ -24,6 +24,7 @@ import org.jetbrains.annotations.ApiStatus; "SpellCheckingInspection" }) @GeneratedFrom("1.21.3") +@NullMarked @ApiStatus.Experimental public final class EnchantmentKeys { /** @@ -323,7 +324,14 @@ public final class EnchantmentKeys { private EnchantmentKeys() { } - private static @NonNull TypedKey create(final @NonNull Key key) { + /** + * Creates a key for {@link Enchantment} in the registry {@code minecraft:enchantment}. + * + * @param key the value's key in the registry + * @return a new typed key + */ + @ApiStatus.Experimental + public static TypedKey create(final Key key) { return TypedKey.create(RegistryKey.ENCHANTMENT, key); } } diff --git a/paper-api-generator/generated/io/papermc/paper/registry/keys/FluidKeys.java b/paper-api-generator/generated/io/papermc/paper/registry/keys/FluidKeys.java index 673b816854..478a9cc6db 100644 --- a/paper-api-generator/generated/io/papermc/paper/registry/keys/FluidKeys.java +++ b/paper-api-generator/generated/io/papermc/paper/registry/keys/FluidKeys.java @@ -7,8 +7,8 @@ import io.papermc.paper.registry.RegistryKey; import io.papermc.paper.registry.TypedKey; import net.kyori.adventure.key.Key; import org.bukkit.Fluid; -import org.checkerframework.checker.nullness.qual.NonNull; import org.jetbrains.annotations.ApiStatus; +import org.jspecify.annotations.NullMarked; /** * Vanilla keys for {@link RegistryKey#FLUID}. @@ -24,6 +24,7 @@ import org.jetbrains.annotations.ApiStatus; "SpellCheckingInspection" }) @GeneratedFrom("1.21.3") +@NullMarked @ApiStatus.Experimental public final class FluidKeys { /** @@ -64,7 +65,7 @@ public final class FluidKeys { private FluidKeys() { } - private static @NonNull TypedKey create(final @NonNull Key key) { + private static TypedKey create(final Key key) { return TypedKey.create(RegistryKey.FLUID, key); } } diff --git a/paper-api-generator/generated/io/papermc/paper/registry/keys/FrogVariantKeys.java b/paper-api-generator/generated/io/papermc/paper/registry/keys/FrogVariantKeys.java index 7cbe222657..b278c3c154 100644 --- a/paper-api-generator/generated/io/papermc/paper/registry/keys/FrogVariantKeys.java +++ b/paper-api-generator/generated/io/papermc/paper/registry/keys/FrogVariantKeys.java @@ -7,8 +7,8 @@ import io.papermc.paper.registry.RegistryKey; import io.papermc.paper.registry.TypedKey; import net.kyori.adventure.key.Key; import org.bukkit.entity.Frog; -import org.checkerframework.checker.nullness.qual.NonNull; import org.jetbrains.annotations.ApiStatus; +import org.jspecify.annotations.NullMarked; /** * Vanilla keys for {@link RegistryKey#FROG_VARIANT}. @@ -24,6 +24,7 @@ import org.jetbrains.annotations.ApiStatus; "SpellCheckingInspection" }) @GeneratedFrom("1.21.3") +@NullMarked @ApiStatus.Experimental public final class FrogVariantKeys { /** @@ -50,7 +51,7 @@ public final class FrogVariantKeys { private FrogVariantKeys() { } - private static @NonNull TypedKey create(final @NonNull Key key) { + private static TypedKey create(final Key key) { return TypedKey.create(RegistryKey.FROG_VARIANT, key); } } diff --git a/paper-api-generator/generated/io/papermc/paper/registry/keys/GameEventKeys.java b/paper-api-generator/generated/io/papermc/paper/registry/keys/GameEventKeys.java index 80beed3ca2..2092a300a3 100644 --- a/paper-api-generator/generated/io/papermc/paper/registry/keys/GameEventKeys.java +++ b/paper-api-generator/generated/io/papermc/paper/registry/keys/GameEventKeys.java @@ -7,8 +7,8 @@ import io.papermc.paper.registry.RegistryKey; import io.papermc.paper.registry.TypedKey; import net.kyori.adventure.key.Key; import org.bukkit.GameEvent; -import org.checkerframework.checker.nullness.qual.NonNull; import org.jetbrains.annotations.ApiStatus; +import org.jspecify.annotations.NullMarked; /** * Vanilla keys for {@link RegistryKey#GAME_EVENT}. @@ -24,6 +24,7 @@ import org.jetbrains.annotations.ApiStatus; "SpellCheckingInspection" }) @GeneratedFrom("1.21.3") +@NullMarked @ApiStatus.Experimental public final class GameEventKeys { /** @@ -456,7 +457,7 @@ public final class GameEventKeys { * @return a new typed key */ @ApiStatus.Experimental - public static @NonNull TypedKey create(final @NonNull Key key) { + public static TypedKey create(final Key key) { return TypedKey.create(RegistryKey.GAME_EVENT, key); } } diff --git a/paper-api-generator/generated/io/papermc/paper/registry/keys/InstrumentKeys.java b/paper-api-generator/generated/io/papermc/paper/registry/keys/InstrumentKeys.java index 98b44173be..8e340fbf55 100644 --- a/paper-api-generator/generated/io/papermc/paper/registry/keys/InstrumentKeys.java +++ b/paper-api-generator/generated/io/papermc/paper/registry/keys/InstrumentKeys.java @@ -7,8 +7,8 @@ import io.papermc.paper.registry.RegistryKey; import io.papermc.paper.registry.TypedKey; import net.kyori.adventure.key.Key; import org.bukkit.MusicInstrument; -import org.checkerframework.checker.nullness.qual.NonNull; import org.jetbrains.annotations.ApiStatus; +import org.jspecify.annotations.NullMarked; /** * Vanilla keys for {@link RegistryKey#INSTRUMENT}. @@ -24,6 +24,7 @@ import org.jetbrains.annotations.ApiStatus; "SpellCheckingInspection" }) @GeneratedFrom("1.21.3") +@NullMarked @ApiStatus.Experimental public final class InstrumentKeys { /** @@ -85,7 +86,14 @@ public final class InstrumentKeys { private InstrumentKeys() { } - private static @NonNull TypedKey create(final @NonNull Key key) { + /** + * Creates a key for {@link MusicInstrument} in the registry {@code minecraft:instrument}. + * + * @param key the value's key in the registry + * @return a new typed key + */ + @ApiStatus.Experimental + public static TypedKey create(final Key key) { return TypedKey.create(RegistryKey.INSTRUMENT, key); } } diff --git a/paper-api-generator/generated/io/papermc/paper/registry/keys/ItemTypeKeys.java b/paper-api-generator/generated/io/papermc/paper/registry/keys/ItemTypeKeys.java index 9750f7a201..34ad745726 100644 --- a/paper-api-generator/generated/io/papermc/paper/registry/keys/ItemTypeKeys.java +++ b/paper-api-generator/generated/io/papermc/paper/registry/keys/ItemTypeKeys.java @@ -8,8 +8,8 @@ import io.papermc.paper.registry.TypedKey; import net.kyori.adventure.key.Key; import org.bukkit.MinecraftExperimental; import org.bukkit.inventory.ItemType; -import org.checkerframework.checker.nullness.qual.NonNull; import org.jetbrains.annotations.ApiStatus; +import org.jspecify.annotations.NullMarked; /** * Vanilla keys for {@link RegistryKey#ITEM}. @@ -25,6 +25,7 @@ import org.jetbrains.annotations.ApiStatus; "SpellCheckingInspection" }) @GeneratedFrom("1.21.3") +@NullMarked @ApiStatus.Experimental public final class ItemTypeKeys { /** @@ -9703,7 +9704,7 @@ public final class ItemTypeKeys { private ItemTypeKeys() { } - private static @NonNull TypedKey create(final @NonNull Key key) { + private static TypedKey create(final Key key) { return TypedKey.create(RegistryKey.ITEM, key); } } diff --git a/paper-api-generator/generated/io/papermc/paper/registry/keys/JukeboxSongKeys.java b/paper-api-generator/generated/io/papermc/paper/registry/keys/JukeboxSongKeys.java index c001a5b46e..7a8a3a6418 100644 --- a/paper-api-generator/generated/io/papermc/paper/registry/keys/JukeboxSongKeys.java +++ b/paper-api-generator/generated/io/papermc/paper/registry/keys/JukeboxSongKeys.java @@ -7,8 +7,8 @@ import io.papermc.paper.registry.RegistryKey; import io.papermc.paper.registry.TypedKey; import net.kyori.adventure.key.Key; import org.bukkit.JukeboxSong; -import org.checkerframework.checker.nullness.qual.NonNull; import org.jetbrains.annotations.ApiStatus; +import org.jspecify.annotations.NullMarked; /** * Vanilla keys for {@link RegistryKey#JUKEBOX_SONG}. @@ -24,6 +24,7 @@ import org.jetbrains.annotations.ApiStatus; "SpellCheckingInspection" }) @GeneratedFrom("1.21.3") +@NullMarked @ApiStatus.Experimental public final class JukeboxSongKeys { /** @@ -169,7 +170,7 @@ public final class JukeboxSongKeys { * @return a new typed key */ @ApiStatus.Experimental - public static @NonNull TypedKey create(final @NonNull Key key) { + public static TypedKey create(final Key key) { return TypedKey.create(RegistryKey.JUKEBOX_SONG, key); } } diff --git a/paper-api-generator/generated/io/papermc/paper/registry/keys/MapDecorationTypeKeys.java b/paper-api-generator/generated/io/papermc/paper/registry/keys/MapDecorationTypeKeys.java index ac4d4b0c64..2c898404bc 100644 --- a/paper-api-generator/generated/io/papermc/paper/registry/keys/MapDecorationTypeKeys.java +++ b/paper-api-generator/generated/io/papermc/paper/registry/keys/MapDecorationTypeKeys.java @@ -7,8 +7,8 @@ import io.papermc.paper.registry.RegistryKey; import io.papermc.paper.registry.TypedKey; import net.kyori.adventure.key.Key; import org.bukkit.map.MapCursor; -import org.checkerframework.checker.nullness.qual.NonNull; import org.jetbrains.annotations.ApiStatus; +import org.jspecify.annotations.NullMarked; /** * Vanilla keys for {@link RegistryKey#MAP_DECORATION_TYPE}. @@ -24,6 +24,7 @@ import org.jetbrains.annotations.ApiStatus; "SpellCheckingInspection" }) @GeneratedFrom("1.21.3") +@NullMarked @ApiStatus.Experimental public final class MapDecorationTypeKeys { /** @@ -274,7 +275,7 @@ public final class MapDecorationTypeKeys { private MapDecorationTypeKeys() { } - private static @NonNull TypedKey create(final @NonNull Key key) { + private static TypedKey create(final Key key) { return TypedKey.create(RegistryKey.MAP_DECORATION_TYPE, key); } } diff --git a/paper-api-generator/generated/io/papermc/paper/registry/keys/MenuTypeKeys.java b/paper-api-generator/generated/io/papermc/paper/registry/keys/MenuTypeKeys.java index b2ad502cc9..c74a3c1a15 100644 --- a/paper-api-generator/generated/io/papermc/paper/registry/keys/MenuTypeKeys.java +++ b/paper-api-generator/generated/io/papermc/paper/registry/keys/MenuTypeKeys.java @@ -7,8 +7,8 @@ import io.papermc.paper.registry.RegistryKey; import io.papermc.paper.registry.TypedKey; import net.kyori.adventure.key.Key; import org.bukkit.inventory.MenuType; -import org.checkerframework.checker.nullness.qual.NonNull; import org.jetbrains.annotations.ApiStatus; +import org.jspecify.annotations.NullMarked; /** * Vanilla keys for {@link RegistryKey#MENU}. @@ -24,6 +24,7 @@ import org.jetbrains.annotations.ApiStatus; "SpellCheckingInspection" }) @GeneratedFrom("1.21.3") +@NullMarked @ApiStatus.Experimental public final class MenuTypeKeys { /** @@ -204,7 +205,7 @@ public final class MenuTypeKeys { private MenuTypeKeys() { } - private static @NonNull TypedKey create(final @NonNull Key key) { + private static TypedKey create(final Key key) { return TypedKey.create(RegistryKey.MENU, key); } } diff --git a/paper-api-generator/generated/io/papermc/paper/registry/keys/MobEffectKeys.java b/paper-api-generator/generated/io/papermc/paper/registry/keys/MobEffectKeys.java index d4f7f8372d..b9a82ca35b 100644 --- a/paper-api-generator/generated/io/papermc/paper/registry/keys/MobEffectKeys.java +++ b/paper-api-generator/generated/io/papermc/paper/registry/keys/MobEffectKeys.java @@ -7,8 +7,8 @@ import io.papermc.paper.registry.RegistryKey; import io.papermc.paper.registry.TypedKey; import net.kyori.adventure.key.Key; import org.bukkit.potion.PotionEffectType; -import org.checkerframework.checker.nullness.qual.NonNull; import org.jetbrains.annotations.ApiStatus; +import org.jspecify.annotations.NullMarked; /** * Vanilla keys for {@link RegistryKey#MOB_EFFECT}. @@ -24,6 +24,7 @@ import org.jetbrains.annotations.ApiStatus; "SpellCheckingInspection" }) @GeneratedFrom("1.21.3") +@NullMarked @ApiStatus.Experimental public final class MobEffectKeys { /** @@ -302,7 +303,7 @@ public final class MobEffectKeys { private MobEffectKeys() { } - private static @NonNull TypedKey create(final @NonNull Key key) { + private static TypedKey create(final Key key) { return TypedKey.create(RegistryKey.MOB_EFFECT, key); } } diff --git a/paper-api-generator/generated/io/papermc/paper/registry/keys/PaintingVariantKeys.java b/paper-api-generator/generated/io/papermc/paper/registry/keys/PaintingVariantKeys.java index cac7a2c76f..25b2ce3f2d 100644 --- a/paper-api-generator/generated/io/papermc/paper/registry/keys/PaintingVariantKeys.java +++ b/paper-api-generator/generated/io/papermc/paper/registry/keys/PaintingVariantKeys.java @@ -7,8 +7,8 @@ import io.papermc.paper.registry.RegistryKey; import io.papermc.paper.registry.TypedKey; import net.kyori.adventure.key.Key; import org.bukkit.Art; -import org.checkerframework.checker.nullness.qual.NonNull; import org.jetbrains.annotations.ApiStatus; +import org.jspecify.annotations.NullMarked; /** * Vanilla keys for {@link RegistryKey#PAINTING_VARIANT}. @@ -24,6 +24,7 @@ import org.jetbrains.annotations.ApiStatus; "SpellCheckingInspection" }) @GeneratedFrom("1.21.3") +@NullMarked @ApiStatus.Experimental public final class PaintingVariantKeys { /** @@ -386,7 +387,7 @@ public final class PaintingVariantKeys { * @return a new typed key */ @ApiStatus.Experimental - public static @NonNull TypedKey create(final @NonNull Key key) { + public static TypedKey create(final Key key) { return TypedKey.create(RegistryKey.PAINTING_VARIANT, key); } } diff --git a/paper-api-generator/generated/io/papermc/paper/registry/keys/SoundEventKeys.java b/paper-api-generator/generated/io/papermc/paper/registry/keys/SoundEventKeys.java index 037ee80836..74a5475571 100644 --- a/paper-api-generator/generated/io/papermc/paper/registry/keys/SoundEventKeys.java +++ b/paper-api-generator/generated/io/papermc/paper/registry/keys/SoundEventKeys.java @@ -7,8 +7,8 @@ import io.papermc.paper.registry.RegistryKey; import io.papermc.paper.registry.TypedKey; import net.kyori.adventure.key.Key; import org.bukkit.Sound; -import org.checkerframework.checker.nullness.qual.NonNull; import org.jetbrains.annotations.ApiStatus; +import org.jspecify.annotations.NullMarked; /** * Vanilla keys for {@link RegistryKey#SOUND_EVENT}. @@ -24,6 +24,7 @@ import org.jetbrains.annotations.ApiStatus; "SpellCheckingInspection" }) @GeneratedFrom("1.21.3") +@NullMarked @ApiStatus.Experimental public final class SoundEventKeys { /** @@ -11481,7 +11482,7 @@ public final class SoundEventKeys { private SoundEventKeys() { } - private static @NonNull TypedKey create(final @NonNull Key key) { + private static TypedKey create(final Key key) { return TypedKey.create(RegistryKey.SOUND_EVENT, key); } } diff --git a/paper-api-generator/generated/io/papermc/paper/registry/keys/StructureKeys.java b/paper-api-generator/generated/io/papermc/paper/registry/keys/StructureKeys.java index 902e04a8c9..3d9cb6d08d 100644 --- a/paper-api-generator/generated/io/papermc/paper/registry/keys/StructureKeys.java +++ b/paper-api-generator/generated/io/papermc/paper/registry/keys/StructureKeys.java @@ -7,8 +7,8 @@ import io.papermc.paper.registry.RegistryKey; import io.papermc.paper.registry.TypedKey; import net.kyori.adventure.key.Key; import org.bukkit.generator.structure.Structure; -import org.checkerframework.checker.nullness.qual.NonNull; import org.jetbrains.annotations.ApiStatus; +import org.jspecify.annotations.NullMarked; /** * Vanilla keys for {@link RegistryKey#STRUCTURE}. @@ -24,6 +24,7 @@ import org.jetbrains.annotations.ApiStatus; "SpellCheckingInspection" }) @GeneratedFrom("1.21.3") +@NullMarked @ApiStatus.Experimental public final class StructureKeys { /** @@ -274,7 +275,7 @@ public final class StructureKeys { * @return a new typed key */ @ApiStatus.Experimental - public static @NonNull TypedKey create(final @NonNull Key key) { + public static TypedKey create(final Key key) { return TypedKey.create(RegistryKey.STRUCTURE, key); } } diff --git a/paper-api-generator/generated/io/papermc/paper/registry/keys/StructureTypeKeys.java b/paper-api-generator/generated/io/papermc/paper/registry/keys/StructureTypeKeys.java index 5a2547a6a1..e4d23e76f8 100644 --- a/paper-api-generator/generated/io/papermc/paper/registry/keys/StructureTypeKeys.java +++ b/paper-api-generator/generated/io/papermc/paper/registry/keys/StructureTypeKeys.java @@ -7,8 +7,8 @@ import io.papermc.paper.registry.RegistryKey; import io.papermc.paper.registry.TypedKey; import net.kyori.adventure.key.Key; import org.bukkit.generator.structure.StructureType; -import org.checkerframework.checker.nullness.qual.NonNull; import org.jetbrains.annotations.ApiStatus; +import org.jspecify.annotations.NullMarked; /** * Vanilla keys for {@link RegistryKey#STRUCTURE_TYPE}. @@ -24,6 +24,7 @@ import org.jetbrains.annotations.ApiStatus; "SpellCheckingInspection" }) @GeneratedFrom("1.21.3") +@NullMarked @ApiStatus.Experimental public final class StructureTypeKeys { /** @@ -141,7 +142,7 @@ public final class StructureTypeKeys { private StructureTypeKeys() { } - private static @NonNull TypedKey create(final @NonNull Key key) { + private static TypedKey create(final Key key) { return TypedKey.create(RegistryKey.STRUCTURE_TYPE, key); } } diff --git a/paper-api-generator/generated/io/papermc/paper/registry/keys/TrimMaterialKeys.java b/paper-api-generator/generated/io/papermc/paper/registry/keys/TrimMaterialKeys.java index 775ee696bc..504c71575b 100644 --- a/paper-api-generator/generated/io/papermc/paper/registry/keys/TrimMaterialKeys.java +++ b/paper-api-generator/generated/io/papermc/paper/registry/keys/TrimMaterialKeys.java @@ -7,8 +7,8 @@ import io.papermc.paper.registry.RegistryKey; import io.papermc.paper.registry.TypedKey; import net.kyori.adventure.key.Key; import org.bukkit.inventory.meta.trim.TrimMaterial; -import org.checkerframework.checker.nullness.qual.NonNull; import org.jetbrains.annotations.ApiStatus; +import org.jspecify.annotations.NullMarked; /** * Vanilla keys for {@link RegistryKey#TRIM_MATERIAL}. @@ -24,6 +24,7 @@ import org.jetbrains.annotations.ApiStatus; "SpellCheckingInspection" }) @GeneratedFrom("1.21.3") +@NullMarked @ApiStatus.Experimental public final class TrimMaterialKeys { /** @@ -106,7 +107,7 @@ public final class TrimMaterialKeys { * @return a new typed key */ @ApiStatus.Experimental - public static @NonNull TypedKey create(final @NonNull Key key) { + public static TypedKey create(final Key key) { return TypedKey.create(RegistryKey.TRIM_MATERIAL, key); } } diff --git a/paper-api-generator/generated/io/papermc/paper/registry/keys/TrimPatternKeys.java b/paper-api-generator/generated/io/papermc/paper/registry/keys/TrimPatternKeys.java index f136c6079c..57667f5399 100644 --- a/paper-api-generator/generated/io/papermc/paper/registry/keys/TrimPatternKeys.java +++ b/paper-api-generator/generated/io/papermc/paper/registry/keys/TrimPatternKeys.java @@ -7,8 +7,8 @@ import io.papermc.paper.registry.RegistryKey; import io.papermc.paper.registry.TypedKey; import net.kyori.adventure.key.Key; import org.bukkit.inventory.meta.trim.TrimPattern; -import org.checkerframework.checker.nullness.qual.NonNull; import org.jetbrains.annotations.ApiStatus; +import org.jspecify.annotations.NullMarked; /** * Vanilla keys for {@link RegistryKey#TRIM_PATTERN}. @@ -24,6 +24,7 @@ import org.jetbrains.annotations.ApiStatus; "SpellCheckingInspection" }) @GeneratedFrom("1.21.3") +@NullMarked @ApiStatus.Experimental public final class TrimPatternKeys { /** @@ -162,7 +163,7 @@ public final class TrimPatternKeys { * @return a new typed key */ @ApiStatus.Experimental - public static @NonNull TypedKey create(final @NonNull Key key) { + public static TypedKey create(final Key key) { return TypedKey.create(RegistryKey.TRIM_PATTERN, key); } } diff --git a/paper-api-generator/generated/io/papermc/paper/registry/keys/VillagerProfessionKeys.java b/paper-api-generator/generated/io/papermc/paper/registry/keys/VillagerProfessionKeys.java index 9942699938..4490743220 100644 --- a/paper-api-generator/generated/io/papermc/paper/registry/keys/VillagerProfessionKeys.java +++ b/paper-api-generator/generated/io/papermc/paper/registry/keys/VillagerProfessionKeys.java @@ -7,8 +7,8 @@ import io.papermc.paper.registry.RegistryKey; import io.papermc.paper.registry.TypedKey; import net.kyori.adventure.key.Key; import org.bukkit.entity.Villager; -import org.checkerframework.checker.nullness.qual.NonNull; import org.jetbrains.annotations.ApiStatus; +import org.jspecify.annotations.NullMarked; /** * Vanilla keys for {@link RegistryKey#VILLAGER_PROFESSION}. @@ -24,6 +24,7 @@ import org.jetbrains.annotations.ApiStatus; "SpellCheckingInspection" }) @GeneratedFrom("1.21.3") +@NullMarked @ApiStatus.Experimental public final class VillagerProfessionKeys { /** @@ -134,7 +135,7 @@ public final class VillagerProfessionKeys { private VillagerProfessionKeys() { } - private static @NonNull TypedKey create(final @NonNull Key key) { + private static TypedKey create(final Key key) { return TypedKey.create(RegistryKey.VILLAGER_PROFESSION, key); } } diff --git a/paper-api-generator/generated/io/papermc/paper/registry/keys/VillagerTypeKeys.java b/paper-api-generator/generated/io/papermc/paper/registry/keys/VillagerTypeKeys.java index f2033c1164..d2e2372030 100644 --- a/paper-api-generator/generated/io/papermc/paper/registry/keys/VillagerTypeKeys.java +++ b/paper-api-generator/generated/io/papermc/paper/registry/keys/VillagerTypeKeys.java @@ -7,8 +7,8 @@ import io.papermc.paper.registry.RegistryKey; import io.papermc.paper.registry.TypedKey; import net.kyori.adventure.key.Key; import org.bukkit.entity.Villager; -import org.checkerframework.checker.nullness.qual.NonNull; import org.jetbrains.annotations.ApiStatus; +import org.jspecify.annotations.NullMarked; /** * Vanilla keys for {@link RegistryKey#VILLAGER_TYPE}. @@ -24,6 +24,7 @@ import org.jetbrains.annotations.ApiStatus; "SpellCheckingInspection" }) @GeneratedFrom("1.21.3") +@NullMarked @ApiStatus.Experimental public final class VillagerTypeKeys { /** @@ -78,7 +79,7 @@ public final class VillagerTypeKeys { private VillagerTypeKeys() { } - private static @NonNull TypedKey create(final @NonNull Key key) { + private static TypedKey create(final Key key) { return TypedKey.create(RegistryKey.VILLAGER_TYPE, key); } } diff --git a/paper-api-generator/generated/io/papermc/paper/registry/keys/WolfVariantKeys.java b/paper-api-generator/generated/io/papermc/paper/registry/keys/WolfVariantKeys.java index ab63580535..7329a23941 100644 --- a/paper-api-generator/generated/io/papermc/paper/registry/keys/WolfVariantKeys.java +++ b/paper-api-generator/generated/io/papermc/paper/registry/keys/WolfVariantKeys.java @@ -7,8 +7,8 @@ import io.papermc.paper.registry.RegistryKey; import io.papermc.paper.registry.TypedKey; import net.kyori.adventure.key.Key; import org.bukkit.entity.Wolf; -import org.checkerframework.checker.nullness.qual.NonNull; import org.jetbrains.annotations.ApiStatus; +import org.jspecify.annotations.NullMarked; /** * Vanilla keys for {@link RegistryKey#WOLF_VARIANT}. @@ -24,6 +24,7 @@ import org.jetbrains.annotations.ApiStatus; "SpellCheckingInspection" }) @GeneratedFrom("1.21.3") +@NullMarked @ApiStatus.Experimental public final class WolfVariantKeys { /** @@ -99,7 +100,7 @@ public final class WolfVariantKeys { * @return a new typed key */ @ApiStatus.Experimental - public static @NonNull TypedKey create(final @NonNull Key key) { + public static TypedKey create(final Key key) { return TypedKey.create(RegistryKey.WOLF_VARIANT, key); } } diff --git a/paper-api-generator/generated/io/papermc/paper/registry/keys/tags/EnchantmentTagKeys.java b/paper-api-generator/generated/io/papermc/paper/registry/keys/tags/EnchantmentTagKeys.java index e1f25062d4..a21a200ddd 100644 --- a/paper-api-generator/generated/io/papermc/paper/registry/keys/tags/EnchantmentTagKeys.java +++ b/paper-api-generator/generated/io/papermc/paper/registry/keys/tags/EnchantmentTagKeys.java @@ -8,8 +8,8 @@ import io.papermc.paper.registry.tag.TagKey; import net.kyori.adventure.key.Key; import org.bukkit.MinecraftExperimental; import org.bukkit.enchantments.Enchantment; -import org.checkerframework.checker.nullness.qual.NonNull; import org.jetbrains.annotations.ApiStatus; +import org.jspecify.annotations.NullMarked; /** * Vanilla keys for {@link RegistryKey#ENCHANTMENT}. @@ -25,6 +25,7 @@ import org.jetbrains.annotations.ApiStatus; "SpellCheckingInspection" }) @GeneratedFrom("1.21.3") +@NullMarked @ApiStatus.Experimental public final class EnchantmentTagKeys { /** @@ -317,7 +318,7 @@ public final class EnchantmentTagKeys { * @return a new tag key */ @ApiStatus.Experimental - public static @NonNull TagKey create(final @NonNull Key key) { + public static TagKey create(final Key key) { return TagKey.create(RegistryKey.ENCHANTMENT, key); } } diff --git a/paper-api-generator/generated/io/papermc/paper/registry/keys/tags/ItemTypeTagKeys.java b/paper-api-generator/generated/io/papermc/paper/registry/keys/tags/ItemTypeTagKeys.java index 8ec601a311..f37b9f659f 100644 --- a/paper-api-generator/generated/io/papermc/paper/registry/keys/tags/ItemTypeTagKeys.java +++ b/paper-api-generator/generated/io/papermc/paper/registry/keys/tags/ItemTypeTagKeys.java @@ -8,8 +8,8 @@ import io.papermc.paper.registry.tag.TagKey; import net.kyori.adventure.key.Key; import org.bukkit.MinecraftExperimental; import org.bukkit.inventory.ItemType; -import org.checkerframework.checker.nullness.qual.NonNull; import org.jetbrains.annotations.ApiStatus; +import org.jspecify.annotations.NullMarked; /** * Vanilla keys for {@link RegistryKey#ITEM}. @@ -25,6 +25,7 @@ import org.jetbrains.annotations.ApiStatus; "SpellCheckingInspection" }) @GeneratedFrom("1.21.3") +@NullMarked @ApiStatus.Experimental public final class ItemTypeTagKeys { /** @@ -1236,7 +1237,7 @@ public final class ItemTypeTagKeys { * @return a new tag key */ @ApiStatus.Experimental - public static @NonNull TagKey create(final @NonNull Key key) { + public static TagKey create(final Key key) { return TagKey.create(RegistryKey.ITEM, key); } } diff --git a/paper-api-generator/src/main/java/io/papermc/generator/Generators.java b/paper-api-generator/src/main/java/io/papermc/generator/Generators.java index d5ddc06fa9..a33d52a696 100644 --- a/paper-api-generator/src/main/java/io/papermc/generator/Generators.java +++ b/paper-api-generator/src/main/java/io/papermc/generator/Generators.java @@ -39,7 +39,6 @@ public interface Generators { // built-ins simpleKey("GameEventKeys", GameEvent.class, Registries.GAME_EVENT, RegistryKey.GAME_EVENT, true), simpleKey("StructureTypeKeys", StructureType.class, Registries.STRUCTURE_TYPE, RegistryKey.STRUCTURE_TYPE, false), - simpleKey("InstrumentKeys", MusicInstrument.class, Registries.INSTRUMENT, RegistryKey.INSTRUMENT, false), simpleKey("MobEffectKeys", PotionEffectType.class, Registries.MOB_EFFECT, RegistryKey.MOB_EFFECT, false), simpleKey("BlockTypeKeys", BlockType.class, Registries.BLOCK, RegistryKey.BLOCK, false), simpleKey("ItemTypeKeys", ItemType.class, Registries.ITEM, RegistryKey.ITEM, false), @@ -60,10 +59,11 @@ public interface Generators { simpleKey("TrimPatternKeys", TrimPattern.class, Registries.TRIM_PATTERN, RegistryKey.TRIM_PATTERN, true), simpleKey("DamageTypeKeys", DamageType.class, Registries.DAMAGE_TYPE, RegistryKey.DAMAGE_TYPE, true), simpleKey("WolfVariantKeys", Wolf.Variant.class, Registries.WOLF_VARIANT, RegistryKey.WOLF_VARIANT, true), - simpleKey("EnchantmentKeys", Enchantment.class, Registries.ENCHANTMENT, RegistryKey.ENCHANTMENT, false), + simpleKey("EnchantmentKeys", Enchantment.class, Registries.ENCHANTMENT, RegistryKey.ENCHANTMENT, true), simpleKey("JukeboxSongKeys", JukeboxSong.class, Registries.JUKEBOX_SONG, RegistryKey.JUKEBOX_SONG, true), simpleKey("BannerPatternKeys", PatternType.class, Registries.BANNER_PATTERN, RegistryKey.BANNER_PATTERN, true), simpleKey("PaintingVariantKeys", Art.class, Registries.PAINTING_VARIANT, RegistryKey.PAINTING_VARIANT, true), + simpleKey("InstrumentKeys", MusicInstrument.class, Registries.INSTRUMENT, RegistryKey.INSTRUMENT, true), // tags simpleTagKey("EnchantmentTagKeys", Enchantment.class, Registries.ENCHANTMENT, RegistryKey.ENCHANTMENT), diff --git a/paper-api-generator/src/main/java/io/papermc/generator/types/GeneratedKeyType.java b/paper-api-generator/src/main/java/io/papermc/generator/types/GeneratedKeyType.java index 54ed67b2b7..624ceae475 100644 --- a/paper-api-generator/src/main/java/io/papermc/generator/types/GeneratedKeyType.java +++ b/paper-api-generator/src/main/java/io/papermc/generator/types/GeneratedKeyType.java @@ -42,7 +42,6 @@ import org.checkerframework.framework.qual.DefaultQualifier; import static com.squareup.javapoet.TypeSpec.classBuilder; import static io.papermc.generator.utils.Annotations.EXPERIMENTAL_API_ANNOTATION; -import static io.papermc.generator.utils.Annotations.NOT_NULL; import static io.papermc.generator.utils.Annotations.experimentalAnnotations; import static java.util.Objects.requireNonNull; import static javax.lang.model.element.Modifier.FINAL; @@ -96,14 +95,14 @@ public class GeneratedKeyType extends SimpleGenerator { } private MethodSpec.Builder createMethod(final TypeName returnType) { - final TypeName keyType = TypeName.get(Key.class).annotated(NOT_NULL); + final TypeName keyType = TypeName.get(Key.class); final ParameterSpec keyParam = ParameterSpec.builder(keyType, "key", FINAL).build(); final MethodSpec.Builder create = MethodSpec.methodBuilder("create") .addModifiers(this.publicCreateKeyMethod ? PUBLIC : PRIVATE, STATIC) .addParameter(keyParam) .addCode("return $T.create($T.$L, $N);", TypedKey.class, RegistryKey.class, requireNonNull(REGISTRY_KEY_FIELD_NAMES.get(this.apiRegistryKey), "Missing field for " + this.apiRegistryKey), keyParam) - .returns(returnType.annotated(NOT_NULL)); + .returns(returnType); if (this.publicCreateKeyMethod) { create.addAnnotation(EXPERIMENTAL_API_ANNOTATION); // TODO remove once not experimental create.addJavadoc(CREATE_JAVADOC, this.apiType, this.registryKey.location().toString()); diff --git a/paper-api-generator/src/main/java/io/papermc/generator/types/GeneratedTagKeyType.java b/paper-api-generator/src/main/java/io/papermc/generator/types/GeneratedTagKeyType.java index 446611a45d..60e15ea64a 100644 --- a/paper-api-generator/src/main/java/io/papermc/generator/types/GeneratedTagKeyType.java +++ b/paper-api-generator/src/main/java/io/papermc/generator/types/GeneratedTagKeyType.java @@ -26,7 +26,6 @@ import org.bukkit.MinecraftExperimental; import static com.squareup.javapoet.TypeSpec.classBuilder; import static io.papermc.generator.utils.Annotations.EXPERIMENTAL_API_ANNOTATION; -import static io.papermc.generator.utils.Annotations.NOT_NULL; import static io.papermc.generator.utils.Annotations.experimentalAnnotations; import static java.util.Objects.requireNonNull; import static javax.lang.model.element.Modifier.FINAL; @@ -73,14 +72,14 @@ public class GeneratedTagKeyType extends SimpleGenerator { } private MethodSpec.Builder createMethod(final TypeName returnType) { - final TypeName keyType = TypeName.get(Key.class).annotated(NOT_NULL); + final TypeName keyType = TypeName.get(Key.class); final ParameterSpec keyParam = ParameterSpec.builder(keyType, "key", FINAL).build(); final MethodSpec.Builder create = MethodSpec.methodBuilder("create") .addModifiers(this.publicCreateKeyMethod ? PUBLIC : PRIVATE, STATIC) .addParameter(keyParam) .addCode("return $T.create($T.$L, $N);", TagKey.class, RegistryKey.class, requireNonNull(REGISTRY_KEY_FIELD_NAMES.get(this.apiRegistryKey), "Missing field for " + this.apiRegistryKey), keyParam) - .returns(returnType.annotated(NOT_NULL)); + .returns(returnType); if (this.publicCreateKeyMethod) { create.addAnnotation(EXPERIMENTAL_API_ANNOTATION); // TODO remove once not experimental create.addJavadoc(CREATE_JAVADOC, this.apiType, this.registryKey.location().toString()); diff --git a/paper-api-generator/src/main/java/io/papermc/generator/types/goal/MobGoalGenerator.java b/paper-api-generator/src/main/java/io/papermc/generator/types/goal/MobGoalGenerator.java index 86e2294ae7..abcc93e61a 100644 --- a/paper-api-generator/src/main/java/io/papermc/generator/types/goal/MobGoalGenerator.java +++ b/paper-api-generator/src/main/java/io/papermc/generator/types/goal/MobGoalGenerator.java @@ -50,10 +50,8 @@ public class MobGoalGenerator extends SimpleGenerator { .addAnnotations(Annotations.CLASS_HEADER) .addJavadoc(CLASS_HEADER); - TypeName mobType = ParameterizedTypeName.get(ClassName.get(Class.class), type) - .annotated(Annotations.NOT_NULL); - TypeName keyType = TypeName.get(String.class) - .annotated(Annotations.NOT_NULL); + TypeName mobType = ParameterizedTypeName.get(ClassName.get(Class.class), type); + TypeName keyType = TypeName.get(String.class); ParameterSpec keyParam = ParameterSpec.builder(keyType, "key", FINAL).build(); ParameterSpec typeParam = ParameterSpec.builder(mobType, "type", FINAL).build(); @@ -63,7 +61,7 @@ public class MobGoalGenerator extends SimpleGenerator { .addParameter(typeParam) .addCode("return $T.of($N, $T.minecraft($N));", GoalKey.class, typeParam, NamespacedKey.class, keyParam) .addTypeVariable(type) - .returns(ParameterizedTypeName.get(ClassName.get(GoalKey.class), type).annotated(Annotations.NOT_NULL)); + .returns(ParameterizedTypeName.get(ClassName.get(GoalKey.class), type)); List> classes; try (ScanResult scanResult = new ClassGraph().enableAllInfo().whitelistPackages("net.minecraft").scan()) { diff --git a/paper-api-generator/src/main/java/io/papermc/generator/utils/Annotations.java b/paper-api-generator/src/main/java/io/papermc/generator/utils/Annotations.java index f625c25a55..977e4a1334 100644 --- a/paper-api-generator/src/main/java/io/papermc/generator/utils/Annotations.java +++ b/paper-api-generator/src/main/java/io/papermc/generator/utils/Annotations.java @@ -7,9 +7,9 @@ import java.util.List; import io.papermc.paper.generated.GeneratedFrom; import net.minecraft.SharedConstants; import org.bukkit.MinecraftExperimental; -import org.checkerframework.checker.nullness.qual.NonNull; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; public final class Annotations { @@ -46,7 +46,7 @@ public final class Annotations { @ApiStatus.Experimental public static final AnnotationSpec EXPERIMENTAL_API_ANNOTATION = AnnotationSpec.builder(ApiStatus.Experimental.class).build(); - public static final AnnotationSpec NOT_NULL = AnnotationSpec.builder(NonNull.class).build(); + public static final AnnotationSpec NULL_MARKED = AnnotationSpec.builder(NullMarked.class).build(); private static final AnnotationSpec SUPPRESS_WARNINGS = AnnotationSpec.builder(SuppressWarnings.class) .addMember("value", "$S", "unused") .addMember("value", "$S", "SpellCheckingInspection") @@ -56,7 +56,8 @@ public final class Annotations { .build(); public static final Iterable CLASS_HEADER = List.of( SUPPRESS_WARNINGS, - GENERATED_FROM + GENERATED_FROM, + NULL_MARKED ); private Annotations() { diff --git a/patches/api/Add-RegistryAccess-for-managing-registries.patch b/patches/api/Add-RegistryAccess-for-managing-registries.patch index e0831fb551..7d74ff555f 100644 --- a/patches/api/Add-RegistryAccess-for-managing-registries.patch +++ b/patches/api/Add-RegistryAccess-for-managing-registries.patch @@ -223,11 +223,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 * Attribute. * * @see Attribute -+ * @deprecated use {@link io.papermc.paper.registry.RegistryAccess#getRegistry(io.papermc.paper.registry.RegistryKey)} with {@link io.papermc.paper.registry.RegistryKey#ATTRIBUTE} */ - Registry ATTRIBUTE = Objects.requireNonNull(Bukkit.getRegistry(Attribute.class), "No registry present for Attribute. This is a bug."); -+ @Deprecated(since = "1.21.3") // Paper -+ Registry ATTRIBUTE = Objects.requireNonNull(io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(Attribute.class), "No registry present for Attribute. This is a bug."); ++ Registry ATTRIBUTE = io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(io.papermc.paper.registry.RegistryKey.ATTRIBUTE); // Paper /** * Server banner patterns. * @@ -277,11 +275,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 * Server entity types. * @@ -0,0 +0,0 @@ public interface Registry extends Iterable { + * Server instruments. * * @see MusicInstrument ++ * @deprecated use {@link io.papermc.paper.registry.RegistryAccess#getRegistry(io.papermc.paper.registry.RegistryKey)} with {@link io.papermc.paper.registry.RegistryKey#INSTRUMENT} */ - Registry INSTRUMENT = Objects.requireNonNull(Bukkit.getRegistry(MusicInstrument.class), "No registry present for MusicInstrument. This is a bug."); -+ Registry INSTRUMENT = io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(io.papermc.paper.registry.RegistryKey.INSTRUMENT); // Paper ++ @Deprecated(since = "1.21.2") ++ Registry INSTRUMENT = Objects.requireNonNull(io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(MusicInstrument.class), "No registry present for Instruments. This is a bug."); // Paper /** * Server item types. * @@ -389,14 +390,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 * Memory Keys. * @@ -0,0 +0,0 @@ public interface Registry extends Iterable { - * Server fluids. * * @see Fluid -+ * @deprecated use {@link io.papermc.paper.registry.RegistryAccess#getRegistry(io.papermc.paper.registry.RegistryKey)} with {@link io.papermc.paper.registry.RegistryKey#FLUID} */ - Registry FLUID = Objects.requireNonNull(Bukkit.getRegistry(Fluid.class), "No registry present for Fluid. This is a bug."); -+ @Deprecated(since = "1.21.3") -+ Registry FLUID = Objects.requireNonNull(io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(Fluid.class), "No registry present for Fluid. This is a bug."); ++ Registry FLUID = io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(io.papermc.paper.registry.RegistryKey.FLUID); // Paper /** * Frog variants. * diff --git a/patches/api/Add-methods-to-get-translation-keys.patch b/patches/api/Add-methods-to-get-translation-keys.patch index 0a3a6ab4e9..6bc4ccf795 100644 --- a/patches/api/Add-methods-to-get-translation-keys.patch +++ b/patches/api/Add-methods-to-get-translation-keys.patch @@ -204,12 +204,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 return Registry.INSTRUMENT.getOrThrow(NamespacedKey.minecraft(key)); } + -+ // Paper start - translation key ++ // Paper start - mark translation key as deprecated ++ /** ++ * @deprecated this method assumes that the instrument description ++ * always be a translatable component which is not guaranteed. ++ */ + @Override -+ public @NotNull String translationKey() { -+ return "instrument.minecraft." + this.getKey().value(); -+ } -+ // Paper end - translation key ++ @Deprecated(forRemoval = true) ++ public abstract @NotNull String translationKey(); ++ // Paper end - mark translation key as deprecated } diff --git a/src/main/java/org/bukkit/Translatable.java b/src/main/java/org/bukkit/Translatable.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 diff --git a/patches/api/Code-Generation.patch b/patches/api/Code-Generation.patch index 230ac5df18..c359cb00c2 100644 --- a/patches/api/Code-Generation.patch +++ b/patches/api/Code-Generation.patch @@ -155,11 +155,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + RegistryKey STRUCTURE_TYPE = create("worldgen/structure_type"); + /** -+ * Built-in registry for instruments. -+ * @see io.papermc.paper.registry.keys.InstrumentKeys -+ */ -+ RegistryKey INSTRUMENT = create("instrument"); -+ /** + * Built-in registry for potion effect types (mob effects). + * @see io.papermc.paper.registry.keys.MobEffectKeys + */ @@ -275,6 +270,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @see io.papermc.paper.registry.keys.PaintingVariantKeys + */ + RegistryKey PAINTING_VARIANT = create("painting_variant"); ++ /** ++ * Data-driven registry for instruments. ++ * @see io.papermc.paper.registry.keys.InstrumentKeys ++ */ ++ RegistryKey INSTRUMENT = create("instrument"); + + + /* ******************* * diff --git a/patches/api/Improve-Registry.patch b/patches/api/Improve-Registry.patch index 30a8ca69f8..a26a1f0162 100644 --- a/patches/api/Improve-Registry.patch +++ b/patches/api/Improve-Registry.patch @@ -40,17 +40,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start - deprecate getKey + /** -+ * @deprecated use {@link Registry#getKey(Keyed)} and {@link Registry#INSTRUMENT}. MusicInstruments -+ * can exist without a key. ++ * @deprecated use {@link Registry#getKey(Keyed)}, {@link io.papermc.paper.registry.RegistryAccess#getRegistry(io.papermc.paper.registry.RegistryKey)}, ++ * and {@link io.papermc.paper.registry.RegistryKey#INSTRUMENT}. MusicInstruments can exist without a key. + */ + @Deprecated(forRemoval = true, since = "1.20.5") + @Override + public abstract @NotNull NamespacedKey getKey(); + // Paper end - deprecate getKey + - // Paper start - translation key - @Override - public @NotNull String translationKey() { + // Paper start - mark translation key as deprecated + /** + * @deprecated this method assumes that the instrument description diff --git a/src/main/java/org/bukkit/Registry.java b/src/main/java/org/bukkit/Registry.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/Registry.java @@ -197,8 +197,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public abstract StructureType getStructureType(); + // Paper start - deprecate getKey + /** -+ * @deprecated use {@link Registry#getKey(Keyed)} and {@link Registry#STRUCTURE}. Structures -+ * can exist without a key. ++ * @deprecated use {@link Registry#getKey(Keyed)}, {@link io.papermc.paper.registry.RegistryAccess#getRegistry(io.papermc.paper.registry.RegistryKey)}, ++ * and {@link io.papermc.paper.registry.RegistryKey#STRUCTURE}. Structures can exist without a key. + */ + @Override + @Deprecated(since = "1.20.4") diff --git a/patches/server/Add-RegistryAccess-for-managing-Registries.patch b/patches/server/Add-RegistryAccess-for-managing-Registries.patch index 67d55a8b42..015cf5d030 100644 --- a/patches/server/Add-RegistryAccess-for-managing-Registries.patch +++ b/patches/server/Add-RegistryAccess-for-managing-Registries.patch @@ -98,7 +98,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // built-ins + entry(Registries.GAME_EVENT, RegistryKey.GAME_EVENT, GameEvent.class, CraftGameEvent::new), + entry(Registries.STRUCTURE_TYPE, RegistryKey.STRUCTURE_TYPE, StructureType.class, CraftStructureType::new), -+ entry(Registries.INSTRUMENT, RegistryKey.INSTRUMENT, MusicInstrument.class, CraftMusicInstrument::new), + entry(Registries.MOB_EFFECT, RegistryKey.MOB_EFFECT, PotionEffectType.class, CraftPotionEffectType::new), + entry(Registries.BLOCK, RegistryKey.BLOCK, BlockType.class, CraftBlockType::new), + entry(Registries.ITEM, RegistryKey.ITEM, ItemType.class, CraftItemType::new), @@ -123,6 +122,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + entry(Registries.JUKEBOX_SONG, RegistryKey.JUKEBOX_SONG, JukeboxSong.class, CraftJukeboxSong::new).delayed(), + entry(Registries.BANNER_PATTERN, RegistryKey.BANNER_PATTERN, PatternType.class, CraftPatternType::new).delayed(), + entry(Registries.PAINTING_VARIANT, RegistryKey.PAINTING_VARIANT, Art.class, CraftArt::new).delayed(), ++ entry(Registries.INSTRUMENT, RegistryKey.INSTRUMENT, MusicInstrument.class, CraftMusicInstrument::new).delayed(), + + // api-only + apiOnly(Registries.ENTITY_TYPE, RegistryKey.ENTITY_TYPE, () -> org.bukkit.Registry.ENTITY_TYPE), diff --git a/patches/server/Add-methods-to-get-translation-keys.patch b/patches/server/Add-methods-to-get-translation-keys.patch index f29e4836e1..28bd0adfaf 100644 --- a/patches/server/Add-methods-to-get-translation-keys.patch +++ b/patches/server/Add-methods-to-get-translation-keys.patch @@ -10,6 +10,27 @@ public org.bukkit.craftbukkit.inventory.CraftMetaFirework getNBT(Lorg/bukkit/Fir Co-authored-by: MeFisto94 +diff --git a/src/main/java/org/bukkit/craftbukkit/CraftMusicInstrument.java b/src/main/java/org/bukkit/craftbukkit/CraftMusicInstrument.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/CraftMusicInstrument.java ++++ b/src/main/java/org/bukkit/craftbukkit/CraftMusicInstrument.java +@@ -0,0 +0,0 @@ public class CraftMusicInstrument extends MusicInstrument implements Handleable< + return this.key; + } + ++ // Paper start - add translationKey methods ++ @Override ++ public @NotNull String translationKey() { ++ if (!(this.getHandle().description().getContents() instanceof final net.minecraft.network.chat.contents.TranslatableContents translatableContents)) { ++ throw new UnsupportedOperationException("Description isn't translatable!"); // Paper ++ } ++ return translatableContents.getKey(); ++ } ++ // Paper end - add translationKey methods ++ + @Override + public boolean equals(Object other) { + if (this == other) { diff --git a/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttribute.java b/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttribute.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttribute.java @@ -205,14 +226,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + org.bukkit.block.Biome bukkit = org.bukkit.block.Biome.valueOf(nms.getKey().location().getPath().toUpperCase(Locale.ROOT)); + Assertions.assertEquals(nms.getKey().location().toLanguageKey("biome"), bukkit.translationKey(), "translation key mismatch for " + bukkit); + } -+ } -+ -+ @Test -+ public void testMusicInstrument() { -+ for (final ResourceLocation nms : RegistryHelper.getRegistry().lookupOrThrow(Registries.INSTRUMENT).keySet()) { -+ final MusicInstrument bukkit = MusicInstrument.getByKey(CraftNamespacedKey.fromMinecraft(nms)); -+ Assertions.assertNotNull(bukkit, "Missing bukkit instrument for " + nms); -+ Assertions.assertEquals(nms.toLanguageKey("instrument"), bukkit.translationKey(), "translation key mismatch for " + bukkit); -+ } + } } diff --git a/patches/server/Add-registry-entry-and-builders.patch b/patches/server/Add-registry-entry-and-builders.patch index 7f7d7e4607..b54392743e 100644 --- a/patches/server/Add-registry-entry-and-builders.patch +++ b/patches/server/Add-registry-entry-and-builders.patch @@ -25,8 +25,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - entry(Registries.GAME_EVENT, RegistryKey.GAME_EVENT, GameEvent.class, CraftGameEvent::new), + writable(Registries.GAME_EVENT, RegistryKey.GAME_EVENT, GameEvent.class, CraftGameEvent::new, PaperGameEventRegistryEntry.PaperBuilder::new), entry(Registries.STRUCTURE_TYPE, RegistryKey.STRUCTURE_TYPE, StructureType.class, CraftStructureType::new), - entry(Registries.INSTRUMENT, RegistryKey.INSTRUMENT, MusicInstrument.class, CraftMusicInstrument::new), entry(Registries.MOB_EFFECT, RegistryKey.MOB_EFFECT, PotionEffectType.class, CraftPotionEffectType::new), + entry(Registries.BLOCK, RegistryKey.BLOCK, BlockType.class, CraftBlockType::new), @@ -0,0 +0,0 @@ public final class PaperRegistries { entry(Registries.TRIM_PATTERN, RegistryKey.TRIM_PATTERN, TrimPattern.class, CraftTrimPattern::new).delayed(), entry(Registries.DAMAGE_TYPE, RegistryKey.DAMAGE_TYPE, DamageType.class, CraftDamageType::new).delayed(), diff --git a/patches/server/General-ItemMeta-fixes.patch b/patches/server/General-ItemMeta-fixes.patch index 8b46d9d274..e858bdc8f3 100644 --- a/patches/server/General-ItemMeta-fixes.patch +++ b/patches/server/General-ItemMeta-fixes.patch @@ -1181,7 +1181,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override public void setEnchantable(Integer data) { -+ Preconditions.checkArgument(data > 0, "Enchantability must be > 0"); ++ Preconditions.checkArgument(data == null || data > 0, "Enchantability must be positive"); // Paper this.enchantableValue = data; }