deprecate adventure key() methods where applicable

This commit is contained in:
Jake Potrebic 2024-11-28 13:51:48 -08:00
parent 57ab68f4ee
commit b207266c7d
3 changed files with 102 additions and 5 deletions

View file

@ -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<Art>, 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<Art>, 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

View file

@ -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<Art>, Keyed {
@NotNull NamespacedKey getKey();
}
// Paper end - deprecate getKey
+ // Paper start - name and author components, assetId key

View file

@ -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<Sound>, 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
}