Add Registry#getTagValues (#12603)

This commit is contained in:
Strokkur24
2025-06-07 03:23:02 +02:00
committed by GitHub
parent 4eda045b15
commit 7ebc94c2a6
2 changed files with 19 additions and 0 deletions

View File

@@ -3,6 +3,7 @@ package io.papermc.paper.registry.set;
import io.papermc.paper.registry.TypedKey; import io.papermc.paper.registry.TypedKey;
import java.util.Collection; import java.util.Collection;
import java.util.Iterator; import java.util.Iterator;
import io.papermc.paper.registry.tag.TagKey;
import org.bukkit.Keyed; import org.bukkit.Keyed;
import org.bukkit.Registry; import org.bukkit.Registry;
import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.ApiStatus;
@@ -33,6 +34,7 @@ public non-sealed interface RegistryKeySet<T extends Keyed> extends Iterable<Typ
* @param registry the registry to resolve the values from (must match {@link #registryKey()}) * @param registry the registry to resolve the values from (must match {@link #registryKey()})
* @return the resolved values * @return the resolved values
* @see RegistryKeySet#values() * @see RegistryKeySet#values()
* @see Registry#getTagValues(TagKey)
*/ */
@Unmodifiable Collection<T> resolve(final Registry<T> registry); @Unmodifiable Collection<T> resolve(final Registry<T> registry);

View File

@@ -491,10 +491,27 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
* @throws NoSuchElementException if no tag with the given key is found * @throws NoSuchElementException if no tag with the given key is found
* @throws UnsupportedOperationException if this registry doesn't have or support tags * @throws UnsupportedOperationException if this registry doesn't have or support tags
* @see #hasTag(TagKey) * @see #hasTag(TagKey)
* @see #getTagValues(TagKey)
*/ */
@ApiStatus.Experimental @ApiStatus.Experimental
Tag<T> getTag(TagKey<T> key); Tag<T> getTag(TagKey<T> key);
/**
* Gets the named registry set (tag) for the given key and resolves it with this registry.
*
* @param key the key to get the tag for
* @return the resolved values
* @throws NoSuchElementException if no tag with the given key is found
* @throws UnsupportedOperationException if this registry doesn't have or support tags
* @see #getTag(TagKey)
* @see Tag#resolve(Registry)
*/
@ApiStatus.Experimental
default Collection<T> getTagValues(TagKey<T> key) {
Tag<T> tag = getTag(key);
return tag.resolve(this);
}
/** /**
* Gets all the tags in this registry. * Gets all the tags in this registry.
* *