Record Class JavaRegistryKey<T>
java.lang.Object
java.lang.Record
org.geysermc.geyser.session.cache.registry.JavaRegistryKey<T>
- Type Parameters:
T- the object type this registry holds.- Record Components:
registryKey- the registry key, as it appears on Java.lookup- an implementation ofJavaRegistryKey.RegistryLookupthat converts an object in this registry to its respective network ID or key, and back.
public record JavaRegistryKey<T>(net.kyori.adventure.key.Key registryKey, JavaRegistryKey.RegistryLookup<T> lookup)
extends Record
Defines a Java registry, which can be hardcoded or data-driven. This class doesn't store registry contents itself, that is handled by
RegistryCache in the case of
data-driven registries and other classes in the case of hardcoded registries.
This class is used when, for a Java registry, data-driven objects and/or tags need to be loaded. Only one instance of this class should be created for each Java registry. Instances of this
class are kept in JavaRegistries, which also has useful methods for creating instances of this class.
This class has a few handy utility methods to convert between the various representations of an object in a registry (network ID, resource location/key, value).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceImplementations should look up an element in the given registry by its value, network ID, or registered key. -
Constructor Summary
ConstructorsConstructorDescriptionJavaRegistryKey(net.kyori.adventure.key.Key registryKey, JavaRegistryKey.RegistryLookup<T> lookup) Creates an instance of aJavaRegistryKeyrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.@Nullable net.kyori.adventure.key.Keykey(JavaRegistryProvider registries, int networkId) Converts a network ID to its registered key, or null if it is not registered.@Nullable net.kyori.adventure.key.Keykey(JavaRegistryProvider registries, T object) Converts an object to its registered key, or null if it is not registered.@Nullable net.kyori.adventure.key.Keykey(GeyserSession session, int networkId) Converts a network ID to its registered key, or null if it is not registered.@Nullable net.kyori.adventure.key.Keykey(GeyserSession session, T object) Converts an object to its registered key, or null if it is not registered.lookup()Returns the value of thelookuprecord component.intnetworkId(JavaRegistryProvider registries, net.kyori.adventure.key.Key key) Converts a registered key to its network ID, or -1 if it is not registered.intnetworkId(JavaRegistryProvider registries, T object) Converts an object to its network ID, or -1 if it is not registered.intnetworkId(GeyserSession session, net.kyori.adventure.key.Key key) Converts a registered key to its network ID, or -1 if it is not registered.intnetworkId(GeyserSession session, T object) Converts an object to its network ID, or -1 if it is not registered.net.kyori.adventure.key.KeyReturns the value of theregistryKeyrecord component.@NonNull StringtoString()Returns a string representation of this record class.@Nullable Tvalue(JavaRegistryProvider registries, int networkId) Converts a network ID to an object in this registry, or null if it is not registered.@Nullable Tvalue(JavaRegistryProvider registries, net.kyori.adventure.key.Key key) Converts a key to an object in this registry, or null if it is not registered.@Nullable Tvalue(GeyserSession session, int networkId) Converts a network ID to an object in this registry, or null if it is not registered.@Nullable Tvalue(GeyserSession session, net.kyori.adventure.key.Key key) Converts a key to an object in this registry, or null if it is not registered.
-
Constructor Details
-
JavaRegistryKey
public JavaRegistryKey(net.kyori.adventure.key.Key registryKey, JavaRegistryKey.RegistryLookup<T> lookup) Creates an instance of aJavaRegistryKeyrecord class.- Parameters:
registryKey- the value for theregistryKeyrecord componentlookup- the value for thelookuprecord component
-
-
Method Details
-
networkId
Converts an object to its network ID, or -1 if it is not registered. -
networkId
Converts an object to its network ID, or -1 if it is not registered. -
networkId
Converts a registered key to its network ID, or -1 if it is not registered. -
networkId
Converts a registered key to its network ID, or -1 if it is not registered. -
key
Converts an object to its registered key, or null if it is not registered. -
key
Converts an object to its registered key, or null if it is not registered. -
key
Converts a network ID to its registered key, or null if it is not registered. -
key
Converts a network ID to its registered key, or null if it is not registered. -
value
Converts a network ID to an object in this registry, or null if it is not registered. -
value
Converts a network ID to an object in this registry, or null if it is not registered. -
value
Converts a key to an object in this registry, or null if it is not registered. -
value
Converts a key to an object in this registry, or null if it is not registered. -
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
registryKey
public net.kyori.adventure.key.Key registryKey()Returns the value of theregistryKeyrecord component.- Returns:
- the value of the
registryKeyrecord component
-
lookup
Returns the value of thelookuprecord component.- Returns:
- the value of the
lookuprecord component
-