Package org.geysermc.geyser.registry
Class ListRegistry<M>
-
Field Summary
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedListRegistry(I input, RegistryLoader<I, List<M>> registryLoader) Creates a new instance of this class with the given input andRegistryLoader. -
Method Summary
Modifier and TypeMethodDescriptionstatic <I,M> ListRegistry <M> create(I input, Supplier<RegistryLoader<I, List<M>>> registryLoader) Creates a new integer mapped registry with the givenRegistryLoaderand input.static <I,M> ListRegistry <M> create(I input, RegistryLoader<I, List<M>> registryLoader) Creates a new integer mapped registry with the givenRegistryLoaderand input.static <I,M> ListRegistry <M> create(RegistryLoader<I, List<M>> registryLoader) Creates a new array registry with the givenRegistryLoader.voidfreeze()Mark this registry as unsuitable for new additions.@Nullable Mget(int index) Returns the value registered by the given index.getOrDefault(int index, M defaultValue) Returns the value registered by the given index or the default value specified if null.Registers a new value into this registry with the given index.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.
-
Constructor Details
-
ListRegistry
Creates a new instance of this class with the given input andRegistryLoader. The input specified is what the registry loader needs to take in.- Parameters:
input- the inputregistryLoader- the registry loader
-
-
Method Details
-
get
Returns the value registered by the given index.- Parameters:
index- the index- Returns:
- the value registered by the given index.
-
getOrDefault
Returns the value registered by the given index or the default value specified if null.- Parameters:
index- the indexdefaultValue- the default value- Returns:
- the value registered by the given key or the default value specified if null.
-
register
Registers a new value into this registry with the given index.- Parameters:
index- the indexvalue- the value- Returns:
- a new value into this registry with the given index.
-
registerWithAnyIndex
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 indexvalue- the valuedefaultValue- 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
Creates a new array 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 input typeM- the returned mappings type- Parameters:
registryLoader- the registry loader- Returns:
- a new registry with the given RegistryLoader supplier
-
create
Creates a new integer mapped registry with the givenRegistryLoaderand input.- Type Parameters:
I- the inputM- 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 givenRegistryLoaderand input.- Type Parameters:
I- the inputM- the type value- Parameters:
registryLoader- the registry loader- Returns:
- a new registry with the given RegistryLoader supplier
-