mirror of
https://github.com/PaperMC/Paper.git
synced 2025-02-25 22:04:46 +01:00
Make TypedKey an actual Key (#11641)
This commit is contained in:
parent
00e253fdf9
commit
857931f5cc
1 changed files with 16 additions and 1 deletions
|
@ -337,7 +337,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ */
|
+ */
|
||||||
+@ApiStatus.Experimental
|
+@ApiStatus.Experimental
|
||||||
+@NullMarked
|
+@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.
|
+ * Gets the key for the value in the registry.
|
||||||
|
@ -381,6 +381,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+
|
+
|
||||||
+@NullMarked
|
+@NullMarked
|
||||||
+record TypedKeyImpl<T>(Key key, RegistryKey<T> registryKey) implements TypedKey<T> {
|
+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
|
diff --git a/src/main/java/org/bukkit/MinecraftExperimental.java b/src/main/java/org/bukkit/MinecraftExperimental.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
|
Loading…
Add table
Reference in a new issue