Class ListRegistry<M>

java.lang.Object
org.geysermc.geyser.registry.Registry<List<M>>
org.geysermc.geyser.registry.ListRegistry<M>

public class ListRegistry<M> extends Registry<List<M>>
  • Constructor Details

    • ListRegistry

      protected ListRegistry(I input, RegistryLoader<I,List<M>> registryLoader)
      Creates a new instance 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

      public @Nullable 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.
    • registerWithAnyIndex

      public M registerWithAnyIndex(int index, M value, M defaultValue)
      Registers a new value into this registry with the given index, even if this value would normally be outside the range of a list.
      Parameters:
      index - the index
      value - the value
      defaultValue - the default value to fill empty spaces in the registry with.
      Returns:
      a new value into this registry with the given index.
    • freeze

      public void freeze()
      Mark this registry as unsuitable for new additions. The backing list will then be optimized for storage.
    • create

      public static <I, M> ListRegistry<M> create(RegistryLoader<I,List<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> ListRegistry<M> create(I input, RegistryLoader<I,List<M>> registryLoader)
      Creates a new integer mapped registry with the given RegistryLoader and input.
      Type Parameters:
      I - the input
      M - the type value
      Parameters:
      registryLoader - the registry loader
      Returns:
      a new registry with the given RegistryLoader
    • create

      public static <I, M> ListRegistry<M> create(I input, Supplier<RegistryLoader<I,List<M>>> registryLoader)
      Creates a new integer mapped registry with the given RegistryLoader and input.
      Type Parameters:
      I - the input
      M - the type value
      Parameters:
      registryLoader - the registry loader
      Returns:
      a new registry with the given RegistryLoader supplier