Class VersionedDeferredRegistry<V>

java.lang.Object
org.geysermc.geyser.registry.AbstractMappedDeferredRegistry<Integer,V,it.unimi.dsi.fastutil.ints.Int2ObjectMap<V>,VersionedRegistry<V>>
org.geysermc.geyser.registry.VersionedDeferredRegistry<V>

public class VersionedDeferredRegistry<V> extends AbstractMappedDeferredRegistry<Integer,V,it.unimi.dsi.fastutil.ints.Int2ObjectMap<V>,VersionedRegistry<V>>
  • Constructor Details

    • VersionedDeferredRegistry

      protected VersionedDeferredRegistry(Function<RegistryLoader<I,it.unimi.dsi.fastutil.ints.Int2ObjectMap<V>>,VersionedRegistry<V>> registryLoader, RegistryLoader<I,it.unimi.dsi.fastutil.ints.Int2ObjectMap<V>> deferredLoader)
    • VersionedDeferredRegistry

      protected VersionedDeferredRegistry(Function<RegistryLoader<I,it.unimi.dsi.fastutil.ints.Int2ObjectMap<V>>,VersionedRegistry<V>> registryLoader, Supplier<RegistryLoader<I,it.unimi.dsi.fastutil.ints.Int2ObjectMap<V>>> deferredLoader)
    • VersionedDeferredRegistry

      protected VersionedDeferredRegistry(I input, org.geysermc.geyser.registry.DeferredRegistry.RegistryInitializer<it.unimi.dsi.fastutil.ints.Int2ObjectMap<V>,VersionedRegistry<V>> registryInitializer, RegistryLoader<I,it.unimi.dsi.fastutil.ints.Int2ObjectMap<V>> deferredLoader)
    • VersionedDeferredRegistry

      protected VersionedDeferredRegistry(I input, org.geysermc.geyser.registry.DeferredRegistry.RegistryInitializer<it.unimi.dsi.fastutil.ints.Int2ObjectMap<V>,VersionedRegistry<V>> registryInitializer, Supplier<RegistryLoader<I,it.unimi.dsi.fastutil.ints.Int2ObjectMap<V>>> deferredLoader)
  • Method Details

    • forVersion

      public @NonNull 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
      Throws:
      IllegalArgumentException - if no values exist at or above the given version
    • create

      public static <I, V> VersionedDeferredRegistry<V> create(Function<RegistryLoader<I,it.unimi.dsi.fastutil.ints.Int2ObjectMap<V>>,VersionedRegistry<V>> registryLoader, RegistryLoader<I,it.unimi.dsi.fastutil.ints.Int2ObjectMap<V>> deferredLoader)
      Creates a new deferred registry.
      Type Parameters:
      I - the input type
      Parameters:
      registryLoader - the registry loader
      deferredLoader - the deferred loader
      Returns:
      the new deferred registry
    • create

      public static <I, V> VersionedDeferredRegistry<V> create(Function<RegistryLoader<I,it.unimi.dsi.fastutil.ints.Int2ObjectMap<V>>,VersionedRegistry<V>> registryLoader, Supplier<RegistryLoader<I,it.unimi.dsi.fastutil.ints.Int2ObjectMap<V>>> deferredLoader)
      Creates a new deferred registry.
      Type Parameters:
      I - the input type
      Parameters:
      registryLoader - the registry loader
      deferredLoader - the deferred loader
      Returns:
      the new deferred registry
    • create

      public static <I, V> VersionedDeferredRegistry<V> create(I input, org.geysermc.geyser.registry.DeferredRegistry.RegistryInitializer<it.unimi.dsi.fastutil.ints.Int2ObjectMap<V>,VersionedRegistry<V>> registryInitializer, RegistryLoader<I,it.unimi.dsi.fastutil.ints.Int2ObjectMap<V>> deferredLoader)
      Creates a new deferred registry.
      Type Parameters:
      I - the input type
      Parameters:
      registryInitializer - the registry initializer
      deferredLoader - the deferred loader
      Returns:
      the new deferred registry
    • create

      public static <I, V> VersionedDeferredRegistry<V> create(I input, org.geysermc.geyser.registry.DeferredRegistry.RegistryInitializer<it.unimi.dsi.fastutil.ints.Int2ObjectMap<V>,VersionedRegistry<V>> registryInitializer, Supplier<RegistryLoader<I,it.unimi.dsi.fastutil.ints.Int2ObjectMap<V>>> deferredLoader)
      Creates a new deferred registry.
      Type Parameters:
      I - the input type
      Parameters:
      registryInitializer - the registry initializer
      deferredLoader - the deferred loader
      Returns:
      the new deferred registry
    • backingRegistry

      protected VersionedRegistry<V> backingRegistry()
    • get

      public it.unimi.dsi.fastutil.ints.Int2ObjectMap<V> get()
      Gets the underlying value held by this registry.
      Returns:
      the underlying value held by this registry
      Throws:
      IllegalStateException - if this deferred registry has not been loaded yet
    • set

      public void set(it.unimi.dsi.fastutil.ints.Int2ObjectMap<V> mappings)
    • register

      public void register(Consumer<it.unimi.dsi.fastutil.ints.Int2ObjectMap<V>> consumer)
      Registers what is specified in the given Consumer into the underlying value.
      Parameters:
      consumer - the consumer
      Throws:
      IllegalStateException - if this deferred registry has not been loaded yet
    • load

      public void load()
      Loads the registry.
    • loaded

      public boolean loaded()
      Whether this registry was loaded.