1
0
Fork 0
mirror of https://github.com/PaperMC/Paper.git synced 2025-01-31 03:50:36 +01:00

Make TypedKey an actual Key ()

This commit is contained in:
Nassim Jahnke 2024-11-23 20:21:24 +01:00
parent 00e253fdf9
commit 857931f5cc

View file

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