Package org.geysermc.geyser.registry
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.-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
VersionedRegistry(I input, RegistryLoader<I,it.unimi.dsi.fastutil.ints.Int2ObjectMap<V>> registryLoader)
-
Method Summary
Modifier and TypeMethodDescriptionstatic <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 givenRegistryLoader
supplier and input.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 givenRegistryLoader
and input.static <I, V> VersionedRegistry<V>
create(Supplier<RegistryLoader<I,it.unimi.dsi.fastutil.ints.Int2ObjectMap<V>>> registryLoader)
Creates a new versioned registry with the givenRegistryLoader
supplier.static <I, V> VersionedRegistry<V>
create(RegistryLoader<I,it.unimi.dsi.fastutil.ints.Int2ObjectMap<V>> registryLoader)
Creates a new versioned registry with the givenRegistryLoader
.forVersion(int version)
Gets the closest value for the specified version.Methods inherited from class org.geysermc.geyser.registry.AbstractMappedRegistry
get, getOrDefault, map, register
-
Constructor Details
-
VersionedRegistry
protected VersionedRegistry(I input, RegistryLoader<I,it.unimi.dsi.fastutil.ints.Int2ObjectMap<V>> registryLoader)
-
-
Method Details
-
forVersion
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 givenRegistryLoader
. 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 inputV
- 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 givenRegistryLoader
and input.- Type Parameters:
I
- the inputV
- 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 givenRegistryLoader
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 inputV
- 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 givenRegistryLoader
supplier and input.- Type Parameters:
I
- the inputV
- the map value- Parameters:
registryLoader
- the registry loader- Returns:
- a new registry with the given RegistryLoader supplier
-