aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNassim Jahnke <[email protected]>2024-11-21 17:47:55 +0100
committerNassim Jahnke <[email protected]>2024-11-21 17:47:55 +0100
commite86fb07cc728d3ec9d1e3f8e5b1ebf6481294ea2 (patch)
tree11ae78b846d413a3c29a548ce5dc535eb7f59794
parentc28d89d625c60243c52857e0c7e6398b73602156 (diff)
downloadPaper-typedkey-is-a-key.tar.gz
Paper-typedkey-is-a-key.zip
Make TypedKey an actual Keytypedkey-is-a-key
-rw-r--r--patches/api/0004-Code-Generation.patch23
1 files changed, 19 insertions, 4 deletions
diff --git a/patches/api/0004-Code-Generation.patch b/patches/api/0004-Code-Generation.patch
index 93ed7b062d..b5b2313958 100644
--- a/patches/api/0004-Code-Generation.patch
+++ b/patches/api/0004-Code-Generation.patch
@@ -319,7 +319,7 @@ index 0000000000000000000000000000000000000000..80e3e64f47ac55a4978c9e5b430e2f2d
+}
diff --git a/src/main/java/io/papermc/paper/registry/TypedKey.java b/src/main/java/io/papermc/paper/registry/TypedKey.java
new file mode 100644
-index 0000000000000000000000000000000000000000..cb2e1a4a6d583787573eeefab24e3188c43d148f
+index 0000000000000000000000000000000000000000..81bee5224196008662ddda528b5dcb8dd7cb9f21
--- /dev/null
+++ b/src/main/java/io/papermc/paper/registry/TypedKey.java
@@ -0,0 +1,45 @@
@@ -337,7 +337,7 @@ index 0000000000000000000000000000000000000000..cb2e1a4a6d583787573eeefab24e3188
+ */
+@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.
@@ -370,10 +370,10 @@ index 0000000000000000000000000000000000000000..cb2e1a4a6d583787573eeefab24e3188
+}
diff --git a/src/main/java/io/papermc/paper/registry/TypedKeyImpl.java b/src/main/java/io/papermc/paper/registry/TypedKeyImpl.java
new file mode 100644
-index 0000000000000000000000000000000000000000..99375deaa6b90b33cd6a77e0df651236d304874e
+index 0000000000000000000000000000000000000000..3e29f7007500582cdc3f84b91f11ebeb58f68bbf
--- /dev/null
+++ b/src/main/java/io/papermc/paper/registry/TypedKeyImpl.java
-@@ -0,0 +1,8 @@
+@@ -0,0 +1,23 @@
+package io.papermc.paper.registry;
+
+import net.kyori.adventure.key.Key;
@@ -381,6 +381,21 @@ index 0000000000000000000000000000000000000000..99375deaa6b90b33cd6a77e0df651236
+
+@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 b7845523e8587e13b86516c0012fe097d904846c..d92a75f610cb2a95203b3f22dc67bdbfb5c3405a 100644