Class JavaRegistryReaders

java.lang.Object
org.geysermc.geyser.registry.java.reader.JavaRegistryReaders

public final class JavaRegistryReaders extends Object
Defines JavaRegistryReaders for all networked JavaRegistryKeys. A "networked registry" is a Java registry that is synced with the client over network.

The server can add, modify, or remove entries from such a registry during the configuration phase. This will happen especially frequently on proxy servers.

For each networked registry defined in JavaRegistries, a JavaRegistryReader has to be defined here. This may be a KeyDependentJavaRegistryReader as well, however prefer to use JavaRegistryReader when possible (see the notes at KeyDependentJavaRegistryReader as to why).

Register readers in the static initialisation block below, using register(JavaRegistryKey, JavaRegistryReader) or registerKeyDependent(JavaRegistryKey, KeyDependentJavaRegistryReader). Please maintain the same order as in JavaRegistries.

See Also:
  • Method Details

    • networkRegistries

      public static Collection<JavaRegistryKey<?>> networkRegistries()
      Returns:
      a collection of JavaRegistryKeys for all networked registries
    • getReader

      public static <T> Optional<KeyDependentJavaRegistryReader<T>> getReader(JavaRegistryKey<T> key)
      Tries to get the reader for the given key. This will be an empty optional when the registry is built-in.
      Type Parameters:
      T - the type of the registry
      Parameters:
      key - the JavaRegistryKey to get the reader for
      Returns:
      the reader, or an empty optional when the registry is built-in (no reader was defined)
    • getInlineSuitableReader

      public static <T> Optional<JavaRegistryReader<T>> getInlineSuitableReader(JavaRegistryKey<T> key)
      Tries to get the reader for the given key. This will be an empty optional when the registry is built-in.

      This method ensures the reader is a JavaRegistryReader, which supports reading inline entries (without a Key).

      Type Parameters:
      T - the type of the registry
      Parameters:
      key - the JavaRegistryKey to get the reader for
      Returns:
      the reader, or an empty optional when the registry is built-in (no reader was defined), or the registry reader does not support reading inline entries
    • bootstrap

      public static void bootstrap()