Class VersionedRegistry<V>

java.lang.Object
org.geysermc.geyser.registry.Registry<M>
org.geysermc.geyser.registry.AbstractMappedRegistry<Integer,​V,​it.unimi.dsi.fastutil.ints.Int2ObjectMap<V>>
org.geysermc.geyser.registry.VersionedRegistry<V>
Type Parameters:
V - the value

public class VersionedRegistry<V> extends AbstractMappedRegistry<Integer,​V,​it.unimi.dsi.fastutil.ints.Int2ObjectMap<V>>
A versioned, mapped registry. Like SimpleMappedRegistry, the Map interface is not able to be specified here, but unlike it, it does not have support for specialized instances, and ONLY supports Int2ObjectMap for optimal performance to prevent boxing of integers.
  • Constructor Details

    • VersionedRegistry

      protected VersionedRegistry(I input, RegistryLoader<I,​it.unimi.dsi.fastutil.ints.Int2ObjectMap<V>> registryLoader)
  • Method Details

    • forVersion

      public V forVersion(int version)
      Gets the closest value for the specified version. Only returns versions higher up than the specified if one does not exist for the given one. Useful in the event that you want to get a resource which is guaranteed for older versions, but not on newer ones.
      Parameters:
      version - the version
      Returns:
      the closest value for the specified version
    • create

      public static <I,​ V> VersionedRegistry<V> create(RegistryLoader<I,​it.unimi.dsi.fastutil.ints.Int2ObjectMap<V>> registryLoader)
      Creates a new versioned 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
      V - the map value
      Parameters:
      registryLoader - the registry loader
      Returns:
      a new registry with the given RegistryLoader
    • create

      public static <I,​ V> VersionedRegistry<V> create(I input, RegistryLoader<I,​it.unimi.dsi.fastutil.ints.Int2ObjectMap<V>> registryLoader)
      Creates a new versioned registry with the given RegistryLoader and input.
      Type Parameters:
      I - the input
      V - the map value
      Parameters:
      registryLoader - the registry loader
      Returns:
      a new registry with the given RegistryLoader
    • create

      public static <I,​ V> VersionedRegistry<V> create(Supplier<RegistryLoader<I,​it.unimi.dsi.fastutil.ints.Int2ObjectMap<V>>> registryLoader)
      Creates a new versioned 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
      V - the map value
      Parameters:
      registryLoader - the registry loader
      Returns:
      a new registry with the given RegistryLoader supplier
    • create

      public static <I,​ V> VersionedRegistry<V> create(I input, Supplier<RegistryLoader<I,​it.unimi.dsi.fastutil.ints.Int2ObjectMap<V>>> registryLoader)
      Creates a new versioned registry with the given RegistryLoader supplier and input.
      Type Parameters:
      I - the input
      V - the map value
      Parameters:
      registryLoader - the registry loader
      Returns:
      a new registry with the given RegistryLoader supplier