Class ArrayRegistry<M>

java.lang.Object
org.geysermc.geyser.registry.Registry<M[]>
org.geysermc.geyser.registry.ArrayRegistry<M>
Type Parameters:
M - the mapping type

public class ArrayRegistry<M> extends Registry<M[]>
An array registry that stores mappings as an array defined by ArrayRegistry. The M represents the value that is to be stored as part of this array.
  • Constructor Details

    • ArrayRegistry

      protected ArrayRegistry(I input, RegistryLoader<I,​M[]> registryLoader)
      Creates a new array registry of this class with the given input and RegistryLoader. The input specified is what the registry loader needs to take in.
      Parameters:
      input - the input
      registryLoader - the registry loader
  • Method Details

    • get

      @Nullable public M get(int index)
      Returns the value registered by the given index.
      Parameters:
      index - the index
      Returns:
      the value registered by the given index.
    • getOrDefault

      public M getOrDefault(int index, M defaultValue)
      Returns the value registered by the given index or the default value specified if null.
      Parameters:
      index - the index
      defaultValue - the default value
      Returns:
      the value registered by the given key or the default value specified if null.
    • register

      public M register(int index, M value)
      Registers a new value into this registry with the given index.
      Parameters:
      index - the index
      value - the value
      Returns:
      a new value into this registry with the given index.
    • create

      public static <I,​ M> ArrayRegistry<M> create(Supplier<RegistryLoader<I,​M[]>> registryLoader)
      Creates a new array registry with the given RegistryLoader supplier. The input type is not specified here, meaning the loader return type is either predefined, or the registry is populated at a later point.
      Type Parameters:
      I - the input type
      M - the returned mappings type
      Parameters:
      registryLoader - the registry loader supplier
      Returns:
      a new registry with the given RegistryLoader supplier
    • create

      public static <I,​ M> ArrayRegistry<M> create(I input, Supplier<RegistryLoader<I,​M[]>> registryLoader)
      Creates a new array registry with the given RegistryLoader supplier and input.
      Type Parameters:
      I - the input type
      M - the returned mappings type
      Parameters:
      input - the input
      registryLoader - the registry loader supplier
      Returns:
      a new registry with the given RegistryLoader supplier
    • create

      public static <I,​ M> ArrayRegistry<M> create(RegistryLoader<I,​M[]> registryLoader)
      Creates a new array registry with the given RegistryLoader. The input type is not specified here, meaning the loader return type is either predefined, or the registry is populated at a later point.
      Type Parameters:
      I - the input type
      M - the returned mappings type
      Parameters:
      registryLoader - the registry loader
      Returns:
      a new registry with the given RegistryLoader supplier
    • create

      public static <I,​ M> ArrayRegistry<M> create(I input, RegistryLoader<I,​M[]> registryLoader)
      Creates a new array registry with the given RegistryLoader and input.
      Type Parameters:
      I - the input type
      M - the returned mappings type
      Parameters:
      input - the input
      registryLoader - the registry loader
      Returns:
      a new registry with the given RegistryLoader supplier