Improve Registry

Adds Registry#getKey(Object) which should be the
primary way people get the key for an object. Registry
items need to exist without having a key and so
getKey() methods on Keyed objects that have a registry
are marked as Deprecated or Obsolete.
This commit is contained in:
Jake Potrebic
2023-12-20 02:03:10 -08:00
parent 9a78d17d8e
commit d513222b59
8 changed files with 214 additions and 0 deletions

View File

@@ -61,4 +61,24 @@ public abstract class Structure implements Keyed {
*/
@NotNull
public abstract StructureType getStructureType();
// Paper start - deprecate 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 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
}