Package io.papermc.paper.registry.set
Interface RegistrySet<T>
- Type Parameters:
T
- registry value type
- All Known Subinterfaces:
RegistryKeySet<T>
,RegistryValueSet<T>
,Tag<T>
@Experimental
@NullMarked
public sealed interface RegistrySet<T>
permits RegistryKeySet<T>, RegistryValueSet<T>
Represents a collection tied to a registry.
There are 2 types of registry sets:
Tag
which is a tag from vanilla or a datapack. These are obtained viaRegistry.getTag(io.papermc.paper.registry.tag.TagKey)
.RegistryKeySet
which is a set of of keys linked to values that are present in the registry. These are created viakeySet(RegistryKey, Iterable)
orkeySetFromValues(RegistryKey, Iterable)
.
-
Method Summary
Modifier and TypeMethodDescriptiondefault boolean
isEmpty()
Checks if the registry set is empty.static <T extends Keyed>
RegistryKeySet<T> keySet
(RegistryKey<T> registryKey, TypedKey<T>... keys) Creates a directRegistrySet
fromTypedKeys
.static <T extends Keyed>
RegistryKeySet<T> keySet
(RegistryKey<T> registryKey, Iterable<TypedKey<T>> keys) Creates a directRegistrySet
fromTypedKeys
.static <T extends Keyed>
RegistryKeySet<T> keySetFromValues
(RegistryKey<T> registryKey, Iterable<? extends T> values) Creates aRegistryKeySet
from registry-backed values.Get the registry key for this set.int
size()
Get the size of this set.
-
Method Details
-
keySetFromValues
@Contract(value="_, _ -> new", pure=true) static <T extends Keyed> RegistryKeySet<T> keySetFromValues(RegistryKey<T> registryKey, Iterable<? extends T> values) Creates aRegistryKeySet
from registry-backed values.All values provided must have keys in the given registry.
If references to actual objects are not available yet, use
keySet(RegistryKey, Iterable)
to create an equivalentRegistryKeySet
using justTypedKeys
.- Type Parameters:
T
- the type of the values- Parameters:
registryKey
- the registry key for the owner of these valuesvalues
- the values- Returns:
- a new registry set
- Throws:
IllegalArgumentException
- if the registry isn't available yet or if any value doesn't have a key in that registry
-
keySet
@SafeVarargs static <T extends Keyed> RegistryKeySet<T> keySet(RegistryKey<T> registryKey, TypedKey<T>... keys) Creates a directRegistrySet
fromTypedKeys
.- Type Parameters:
T
- the type of the values- Parameters:
registryKey
- the registry key for the owner of these keyskeys
- the keys for the values- Returns:
- a new registry set
-
keySet
@Contract(value="_, _ -> new", pure=true) static <T extends Keyed> RegistryKeySet<T> keySet(RegistryKey<T> registryKey, Iterable<TypedKey<T>> keys) Creates a directRegistrySet
fromTypedKeys
.- Type Parameters:
T
- the type of the values- Parameters:
registryKey
- the registry key for the owner of these keyskeys
- the keys for the values- Returns:
- a new registry set
-
registryKey
RegistryKey<T> registryKey()Get the registry key for this set.- Returns:
- the registry key
-
size
int size()Get the size of this set.- Returns:
- the size
-
isEmpty
default boolean isEmpty()Checks if the registry set is empty.- Returns:
- true, if empty
-