From b207266c7df3489fcf9743fd5b959dcece66d9fa Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Thu, 28 Nov 2024 13:51:48 -0800 Subject: [PATCH] deprecate adventure key() methods where applicable --- ...-removal-all-OldEnum-related-methods.patch | 22 +++++ patches/api/Expanded-Art-API.patch | 2 +- patches/api/Improve-Registry.patch | 83 ++++++++++++++++++- 3 files changed, 102 insertions(+), 5 deletions(-) diff --git a/patches/api/Deprecate-for-removal-all-OldEnum-related-methods.patch b/patches/api/Deprecate-for-removal-all-OldEnum-related-methods.patch index 0608437a67..d5dfe921be 100644 --- a/patches/api/Deprecate-for-removal-all-OldEnum-related-methods.patch +++ b/patches/api/Deprecate-for-removal-all-OldEnum-related-methods.patch @@ -4,6 +4,28 @@ Date: Sat, 7 Sep 2024 11:14:31 -0700 Subject: [PATCH] Deprecate for removal all OldEnum-related methods +diff --git a/src/main/java/org/bukkit/Art.java b/src/main/java/org/bukkit/Art.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/Art.java ++++ b/src/main/java/org/bukkit/Art.java +@@ -0,0 +0,0 @@ public interface Art extends OldEnum, Keyed { + * @deprecated only for backwards compatibility, use {@link Registry#get(NamespacedKey)} instead. + */ + @NotNull +- @Deprecated(since = "1.21.3") ++ @Deprecated(since = "1.21.3", forRemoval = true) @org.jetbrains.annotations.ApiStatus.ScheduledForRemoval(inVersion = "1.22") // Paper - will be removed via asm-utils + static Art valueOf(@NotNull String name) { + Art art = Bukkit.getUnsafe().get(Registry.ART, NamespacedKey.fromString(name.toLowerCase(Locale.ROOT))); + Preconditions.checkArgument(art != null, "No art found with the name %s", name); +@@ -0,0 +0,0 @@ public interface Art extends OldEnum, Keyed { + * @deprecated use {@link Registry#iterator()}. + */ + @NotNull +- @Deprecated(since = "1.21.3") ++ @Deprecated(since = "1.21.3", forRemoval = true) @org.jetbrains.annotations.ApiStatus.ScheduledForRemoval(inVersion = "1.22") // Paper - will be removed via asm-utils + static Art[] values() { + return Lists.newArrayList(Registry.ART).toArray(new Art[0]); + } diff --git a/src/main/java/org/bukkit/Fluid.java b/src/main/java/org/bukkit/Fluid.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/Fluid.java diff --git a/patches/api/Expanded-Art-API.patch b/patches/api/Expanded-Art-API.patch index 39625adfbf..a38ea862af 100644 --- a/patches/api/Expanded-Art-API.patch +++ b/patches/api/Expanded-Art-API.patch @@ -9,7 +9,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/Art.java +++ b/src/main/java/org/bukkit/Art.java @@ -0,0 +0,0 @@ public interface Art extends OldEnum, Keyed { - @NotNull NamespacedKey getKey(); + } // Paper end - deprecate getKey + // Paper start - name and author components, assetId key diff --git a/patches/api/Improve-Registry.patch b/patches/api/Improve-Registry.patch index a26a1f0162..96fe1e88a9 100644 --- a/patches/api/Improve-Registry.patch +++ b/patches/api/Improve-Registry.patch @@ -22,9 +22,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @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#PAINTING_VARIANT}. Painting variants can exist without a key. + */ -+ @Deprecated(since = "1.21") ++ @Deprecated(since = "1.21", forRemoval = true) + @Override + @NotNull NamespacedKey getKey(); ++ ++ /** ++ * @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#PAINTING_VARIANT}. Painting variants can exist without a key. ++ */ ++ @Deprecated(since = "1.21", forRemoval = true) ++ @Override ++ default net.kyori.adventure.key.@org.jetbrains.annotations.NotNull Key key() { ++ return Keyed.super.key(); ++ } + // Paper end - deprecate getKey + /** @@ -46,6 +56,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @Deprecated(forRemoval = true, since = "1.20.5") + @Override + public abstract @NotNull NamespacedKey getKey(); ++ ++ /** ++ * @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 net.kyori.adventure.key.@org.jetbrains.annotations.NotNull Key key() { ++ return Keyed.super.key(); ++ } ++ + // Paper end - deprecate getKey + // Paper start - mark translation key as deprecated @@ -161,7 +182,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @deprecated use {@link Registry#getKey(Keyed)} and {@link Registry#SOUNDS}. Sounds + * can exist without a key. + */ -+ @Deprecated(since = "1.20.5") ++ @Deprecated(since = "1.20.5", forRemoval = true) + @Override + @NotNull NamespacedKey getKey(); + // Paper end - deprecate getKey @@ -169,6 +190,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 /** * @return an array of all known sounds. * @deprecated use {@link Registry#iterator()}. +@@ -0,0 +0,0 @@ public interface Sound extends OldEnum, Keyed, net.kyori.adventure.sound. + } + + // Paper start ++ /** ++ * @deprecated use {@link Registry#getKey(Keyed)} and {@link Registry#SOUNDS}. Sounds ++ * can exist without a key. ++ */ ++ @Deprecated(since = "1.20.5", forRemoval = true) + @Override + default net.kyori.adventure.key.@NotNull Key key() { + return this.getKey(); diff --git a/src/main/java/org/bukkit/block/banner/PatternType.java b/src/main/java/org/bukkit/block/banner/PatternType.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/block/banner/PatternType.java @@ -182,7 +215,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @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#BANNER_PATTERN}. PatternTypes can exist without a key. + */ -+ @Deprecated(since = "1.20.5") ++ @Deprecated(since = "1.20.5", forRemoval = true) ++ @Override ++ default net.kyori.adventure.key.@org.jetbrains.annotations.NotNull Key key() { ++ return org.bukkit.Keyed.super.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#BANNER_PATTERN}. PatternTypes can exist without a key. ++ */ ++ @Deprecated(since = "1.20.5", forRemoval = true) + // Paper end - deprecate getKey @Override @NotNull @@ -201,8 +244,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * and {@link io.papermc.paper.registry.RegistryKey#STRUCTURE}. Structures can exist without a key. + */ + @Override -+ @Deprecated(since = "1.20.4") ++ @Deprecated(since = "1.20.4", forRemoval = true) + public abstract @NotNull NamespacedKey getKey(); ++ ++ /** ++ * @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", forRemoval = true) ++ public net.kyori.adventure.key.@org.jetbrains.annotations.NotNull Key key() { ++ return org.bukkit.Keyed.super.key(); ++ } ++ + // Paper end - deprecate getKey } diff --git a/src/main/java/org/bukkit/inventory/meta/trim/TrimMaterial.java b/src/main/java/org/bukkit/inventory/meta/trim/TrimMaterial.java @@ -222,6 +276,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @Deprecated(forRemoval = true, since = "1.20.4") + @Override + org.bukkit.@org.jetbrains.annotations.NotNull NamespacedKey getKey(); ++ ++ /** ++ * @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#TRIM_MATERIAL}. TrimMaterials can exist without a key. ++ */ ++ @Deprecated(forRemoval = true, since = "1.20.4") ++ @Override ++ default net.kyori.adventure.key.@org.jetbrains.annotations.NotNull Key key() { ++ return org.bukkit.Keyed.super.key(); ++ } ++ + // Paper end - Registry#getKey } diff --git a/src/main/java/org/bukkit/inventory/meta/trim/TrimPattern.java b/src/main/java/org/bukkit/inventory/meta/trim/TrimPattern.java @@ -241,5 +306,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @Deprecated(forRemoval = true, since = "1.20.4") + @Override + org.bukkit.@org.jetbrains.annotations.NotNull NamespacedKey getKey(); ++ ++ /** ++ * @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#TRIM_PATTERN}. TrimPatterns can exist without a key. ++ */ ++ @Deprecated(forRemoval = true, since = "1.20.4") ++ @Override ++ default net.kyori.adventure.key.@org.jetbrains.annotations.NotNull Key key() { ++ return org.bukkit.Keyed.super.key(); ++ } + // Paper end - Registry#getKey }