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.networkSerializer- a method that converts an object in this registry to its network ID.networkDeserializer- a method that converts a network ID to an object in this registry.networkIdentifier- a method that converts a network ID to its respective key in this registry.
public record JavaRegistryKey<T>(net.kyori.adventure.key.Key registryKey, JavaRegistryKey.NetworkSerializer<T> networkSerializer, JavaRegistryKey.NetworkDeserializer<T> networkDeserializer, JavaRegistryKey.NetworkIdentifier<T> networkIdentifier)
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic interfacestatic interface -
Constructor Summary
ConstructorsConstructorDescriptionJavaRegistryKey(net.kyori.adventure.key.Key registryKey, JavaRegistryKey.NetworkSerializer<T> networkSerializer, JavaRegistryKey.NetworkDeserializer<T> networkDeserializer, JavaRegistryKey.NetworkIdentifier<T> networkIdentifier) Creates an instance of aJavaRegistryKeyrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.fromNetworkId(GeyserSession session, int networkId) Converts a network ID to an object in this registry.final inthashCode()Returns a hash code value for this object.net.kyori.adventure.key.KeykeyFromNetworkId(GeyserSession session, int networkId) Converts a network ID to the key it's registered under in this registry.Returns the value of thenetworkDeserializerrecord component.Returns the value of thenetworkIdentifierrecord component.Returns the value of thenetworkSerializerrecord component.net.kyori.adventure.key.KeyReturns the value of theregistryKeyrecord component.inttoNetworkId(GeyserSession session, T object) Converts an object in this registry to its network ID.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
JavaRegistryKey
public JavaRegistryKey(net.kyori.adventure.key.Key registryKey, JavaRegistryKey.NetworkSerializer<T> networkSerializer, JavaRegistryKey.NetworkDeserializer<T> networkDeserializer, JavaRegistryKey.NetworkIdentifier<T> networkIdentifier) Creates an instance of aJavaRegistryKeyrecord class.- Parameters:
registryKey- the value for theregistryKeyrecord componentnetworkSerializer- the value for thenetworkSerializerrecord componentnetworkDeserializer- the value for thenetworkDeserializerrecord componentnetworkIdentifier- the value for thenetworkIdentifierrecord component
-
-
Method Details
-
toNetworkId
Converts an object in this registry to its network ID. -
fromNetworkId
Converts a network ID to an object in this registry. -
keyFromNetworkId
Converts a network ID to the key it's registered under in this registry. -
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
-
networkSerializer
Returns the value of thenetworkSerializerrecord component.- Returns:
- the value of the
networkSerializerrecord component
-
networkDeserializer
Returns the value of thenetworkDeserializerrecord component.- Returns:
- the value of the
networkDeserializerrecord component
-
networkIdentifier
Returns the value of thenetworkIdentifierrecord component.- Returns:
- the value of the
networkIdentifierrecord component
-