diff options
-rw-r--r-- | patches/api/0477-WIP-Tag-API.patch | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/patches/api/0477-WIP-Tag-API.patch b/patches/api/0477-WIP-Tag-API.patch new file mode 100644 index 0000000000..32ed16f1cf --- /dev/null +++ b/patches/api/0477-WIP-Tag-API.patch @@ -0,0 +1,62 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Owen1212055 <[email protected]> +Date: Sat, 15 Jun 2024 21:42:19 -0400 +Subject: [PATCH] WIP Tag API + + +diff --git a/src/main/java/io/papermc/paper/registry/tag/TagKey.java b/src/main/java/io/papermc/paper/registry/tag/TagKey.java +new file mode 100644 +index 0000000000000000000000000000000000000000..a49d328e95f7fda6567ee6c4f5f1878a2c187277 +--- /dev/null ++++ b/src/main/java/io/papermc/paper/registry/tag/TagKey.java +@@ -0,0 +1,32 @@ ++package io.papermc.paper.registry.tag; ++ ++import io.papermc.paper.registry.RegistryKey; ++import net.kyori.adventure.key.Key; ++import net.kyori.adventure.key.Keyed; ++import org.checkerframework.checker.nullness.qual.NonNull; ++import org.jetbrains.annotations.ApiStatus; ++import org.jetbrains.annotations.Contract; ++ ++public sealed interface TagKey<T> extends Keyed permits TagKeyImpl { ++ ++ /** ++ * Creates a new tag key for a registry. ++ * ++ * @param registryKey the registry for the tag ++ * @param key the specific key for the tag ++ * @return a new tag key ++ * @param <T> the registry value type ++ */ ++ @Contract(value = "_, _ -> new", pure = true) ++ static <T> @NonNull TagKey<T> create(final @NonNull RegistryKey<T> registryKey, final @NonNull Key key) { ++ return new TagKeyImpl<>(registryKey, key); ++ } ++ ++ /** ++ * Get the registry key for this tag key. ++ * ++ * @return the registry key ++ */ ++ @NonNull RegistryKey<T> registryKey(); ++} +diff --git a/src/main/java/io/papermc/paper/registry/tag/TagKeyImpl.java b/src/main/java/io/papermc/paper/registry/tag/TagKeyImpl.java +new file mode 100644 +index 0000000000000000000000000000000000000000..11d19e339c7c62f2eb4467277552c27e4e83069c +--- /dev/null ++++ b/src/main/java/io/papermc/paper/registry/tag/TagKeyImpl.java +@@ -0,0 +1,12 @@ ++package io.papermc.paper.registry.tag; ++ ++import io.papermc.paper.registry.RegistryKey; ++import net.kyori.adventure.key.Key; ++import org.checkerframework.checker.nullness.qual.NonNull; ++import org.checkerframework.framework.qual.DefaultQualifier; ++import org.jetbrains.annotations.ApiStatus; ++ ++@DefaultQualifier(NonNull.class) ++record TagKeyImpl<T>(RegistryKey<T> registryKey, Key key) implements TagKey<T> { ++} |