From 857931f5cc8f36f5fad9fed5578b59af7d4d1449 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke <nassim@njahnke.dev> Date: Sat, 23 Nov 2024 20:21:24 +0100 Subject: [PATCH] Make TypedKey an actual Key (#11641) --- patches/api/Code-Generation.patch | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/patches/api/Code-Generation.patch b/patches/api/Code-Generation.patch index c359cb00c2..5217548235 100644 --- a/patches/api/Code-Generation.patch +++ b/patches/api/Code-Generation.patch @@ -337,7 +337,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ +@ApiStatus.Experimental +@NullMarked -+public sealed interface TypedKey<T> extends Keyed permits TypedKeyImpl { ++public sealed interface TypedKey<T> extends Key permits TypedKeyImpl { + + /** + * Gets the key for the value in the registry. @@ -381,6 +381,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + +@NullMarked +record TypedKeyImpl<T>(Key key, RegistryKey<T> registryKey) implements TypedKey<T> { ++ // Wrap key methods to make this easier to use ++ @Override ++ public String namespace() { ++ return this.key.namespace(); ++ } ++ ++ @Override ++ public String value() { ++ return this.key.value(); ++ } ++ ++ @Override ++ public String asString() { ++ return this.key.asString(); ++ } +} diff --git a/src/main/java/org/bukkit/MinecraftExperimental.java b/src/main/java/org/bukkit/MinecraftExperimental.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644